I cannot make a calculation with the command int
이전 댓글 표시
Hello, I am doing a calculation, but matlab doesn't want to do it with the command int. I have found the solution with other software or using the command trapz, but it is linger and less accurate.
this is the code
syms x
a=int((72290819601*x^2*(x - 1)^10*(x + 1)^10*(261*x^4 - 90*x^2 + 5)^2)/(134217728*(x - 4752731968273649/18014398509481984)^2),x,-1,1)
It gives infinity as result, whereas it is equal to 3831.098 (all the digits in my formula comes from a simplify command in matlab.
I am running Matlab 2010b
Thanks a lot for any suggestion for fixing the problem, otherwise I'll use the longer procedure from trapz
댓글 수: 1
Sean de Wolski
2012년 5월 2일
+1, good question in both content and description!
답변 (5개)
Honglei Chen
2012년 5월 2일
0 개 추천
looks to me you have a singular point between -1 and 1 at 4752731968273649/18014398509481984. This might be why
댓글 수: 5
mortain
2012년 5월 3일
John D'Errico
2012년 5월 3일
How is it not singular? The divide by zero works for you? Wow. It must be nice to live in a world where 1/0 has a finite value. I wonder when that changed? The numerator is not zero at that point. Sorry. It IS singular.
mortain
2012년 5월 3일
Walter Roberson
2012년 5월 3일
You are not plotting at a fine-enough resolution to see the infinity.
mortain
2012년 5월 3일
Walter Roberson
2012년 5월 2일
0 개 추천
Try increasing your Digits setting. The integral has some large intermediate terms.
댓글 수: 4
mortain
2012년 5월 3일
Walter Roberson
2012년 5월 3일
http://www.mathworks.com/help/toolbox/symbolic/digits.html
mortain
2012년 5월 3일
Walter Roberson
2012년 5월 3일
Sorry, I had a disk problem at home a few days ago and had to wipe my disk; I haven't reinstalled my software yet, so I cannot test at the moment.
Sean de Wolski
2012년 5월 2일
When x = 4752731968273649/18014398509481984 or 0.26ish, the denominator is zero, the numerator is not zero and the value is infinite.
In the numerical world, it would fail if this point was evaluated. You just don't have this in your trapz calculation:
Let's make the function in the happy numerical world:
f = str2func(vectorize('@(x)(72290819601*x^2*(x - 1)^10*(x + 1)^10*(261*x^4 - 90*x^2 + 5)^2)/(134217728*(x - 4752731968273649/18014398509481984)^2)'));
And then evaluate it at our trouble point:
f(4752731968273649/18014398509481984)
Boom!
댓글 수: 6
mortain
2012년 5월 3일
John D'Errico
2012년 5월 3일
Just because trapz gives a finite result, this does not make that result correct. You should recognize that this integral has no finite result. int is telling you that. Listen to what it says.
John D'Errico
2012년 5월 3일
Mortain, your friend is wrong here. Since the numerator is not truly zero at that point, it is not 0/0. A really small value does not count. At that location, the numerator evaluates to (roughly) 0.000000000000000000063950710191408455365893342257719, not zero.
Walter Roberson
2012년 5월 3일
http://www.wolframalpha.com/input/?i=Limit[%2872290819601*x^2*%28x+-+1%29^10*%28x+%2B+1%29^10*%28261*x^4+-+90*x^2+%2B+5%29^2%29%2F%28134217728*%28x+-+4752731968273649%2F18014398509481984%29^2%29%2Cx-%3E4752731968273649%2F18014398509481984]
The result there is infinity.
Richard Brown
2012년 5월 3일
I can add Maple to the list of software packages confirming this :)
mortain
2012년 5월 3일
mortain
2012년 5월 3일
댓글 수: 2
Walter Roberson
2012년 5월 11일
For that last integral, Maple indicates the answer is
(7186705221432913/36028797018963968)*sqrt(Pi)*sqrt(2)
bym
2012년 5월 11일
FWIW, in matlab (I just learned the simplify 'trick' for integrals)
int((7186705221432913*(x^2 - 1)^2)/(18014398509481984*exp(x^2/2)*(x + 1)^2), -Inf,Inf)/4
Warning: Explicit integral could not be found.
> In sym.int at 64
ans =
int((7186705221432913*(x^2 - 1)^2)/(18014398509481984*exp(x^2/2)*(x + 1)^2), x = -Inf..Inf)/4
>> simplify(ans)
ans =
(7186705221432913*2^(1/2)*pi^(1/2))/36028797018963968
Walter Roberson
2012년 5월 11일
> Digits := 50;
50
> plot(72290819601*x^2*(x-1)^10*(x+1)^10*(261*x^4-90*x^2+5)^2/(134217728*(x-4752731968273649/18014398509481984)^2), x = .2638296 .. .2638297);

The singularity is clearly present, and with 50 digits of precision being calculated, it sure isn't just round-off error in calculating the plot.
Perhaps you are trying to say that round-off error in your generating calculations led to an incorrect formula that you then asked us to integrate? If so then what is the correct formula?
카테고리
도움말 센터 및 File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!