# Precision when dividing two functions going against zero

2 views (last 30 days)

Show older comments

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 Comments

David Young
on 28 Jul 2014

### Answers (2)

Patrik Ek
on 28 Jul 2014

Edited: Patrik Ek
on 28 Jul 2014

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 Comment

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!