Consider the function. f(x)=(1-cosx)/sinx Notice that, for small x, the numerato
ID: 2965030 • Letter: C
Question
Consider the function.
f(x)=(1-cosx)/sinx
Notice that, for small x, the numerator consists of a subtraction of two numbers close to each other in size (both near 1).
(a) Find the solution for x = 0:005 to six signicant digits. Be sure to round your result to 6 digits at each calculation step.
(b) Use MATLAB (format long) to calculate f(0:005). Consider this to be the true value.
Find the true relative error between cases (a) and (b).
(c) Multiply f(x) by 1+cosx/1+cosx and be sure to simplify your expression. (Recall that sin^2 x + cos^2 x = 1.) Then nd the value of the new f(x) for x = 0:005 to 6 signicant digits. (Round at each step in the calculation.) Find the true relative error, and compare with your results in (b). Explain your result.
Explanation / Answer
a)
cos(0.005)=0.999988
sin(0.005)=0.005000
f(x)=(1-cosx)/sinx at x=0.005 is =(1-0.999988)/0.005000=0.002400
b)
By using matlab long format we get f(0.005) = 0.002500005208347
so the relative error between case (a) and (b) is = 0.000100005208347
c)
By multiplying f(x) with 1+cosx/1+cosx we get f(x) = sinx/1+cosx
we get f(0.005) = 0.002500
from matlab we get f(0.005) = 0.002500005208346
so we get the relative error as = 0.00000005208346
Thus we can see the relative error in case 2 is lower