Precision when dividing two functions going against zero

조회 수: 1 (최근 30일)
T
T 2014년 7월 28일
편집: Matt J 2014년 7월 28일
Hi, I have two functions A=sinc(c1*x)-cos(c2*x) whichs is Zero for x=0. Now I want to calculate A/(c3*x). The expected result is exactly 1 at x=0. But numerically I get 1.05 Is there a way to increase precision in matlab? Format Long didn't work. I want to plot the behaviour of the function for a variety of x values, from large to very small
Thanks!
  댓글 수: 2
Michael Haderlein
Michael Haderlein 2014년 7월 28일
Hm, how did you get 1.05? I'd do something like this (since I don't know your c1,2,3, I set all to 1):
x=logspace(-10,0);
semilogx(x,(sinc(x)-cos(x) )./x)
This way, it converges towards 0 (for x-> 0).
David Young
David Young 2014년 7월 28일
MATLAB computes in double precision by default. It is most unlikely that your problem is anything to do with the precision of the computation. If you show the code you used to get the value of 1.05 it may be possible to explain what is happening.

댓글을 달려면 로그인하십시오.

답변 (2개)

Matt J
Matt J 2014년 7월 28일
편집: Matt J 2014년 7월 28일
Use a Taylor expansion of A(x) around x=0 to evaluate A(x)/(c3*x) at x in the near neighborhood of zero.

Patrik Ek
Patrik Ek 2014년 7월 28일
편집: Patrik Ek 2014년 7월 28일
I think that you should try to do the calculations manually. I did the calculations manually and got that the value should converge towards 0, using a 3rd order taylor expansion. When manually evaluating:
f(x) = ( sinc(c1*x)-cos(c2*x) ) / (c3*x)
the expression I got was:
f(x) = x / ( c3*factorial(3) ) * (3*c2^2-c1^2)
This will converge towards 0 which the expression did for me when x was small enough. Notice that
sinc(c1*x) = sin(c1*x) / (c1*x)
If you plot sinc(x), cos(x), 1-x, 1+x in the same plot (using hold on) around 0 ( (-0.2, 0.2) is enough I think), it becomes quite clear that it should converge towards something small. It can be seen that cos(x) ans sinc(x) is similar at that point, but not the lines.
  댓글 수: 1
Matt J
Matt J 2014년 7월 28일
편집: Matt J 2014년 7월 28일
L'hopital's rule also confirms that the value should go to zero at x=0.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by