Professional Documents
Culture Documents
384 HW 1 Ss 15
384 HW 1 Ss 15
cos x
sin x
Notice that, for small x, the numerator consists of a subtraction of two numbers close to each
other in size (both near 1), and the denominator is also a small number.
(a) Find the solution for x = 0:001 to six digits, including zeros. Be sure to round your
result to 6 digits at each calculation step.
(b) Use MATLAB (format long) to calculate f (0:001). Consider this to be the true value.
Find the true relative error between cases (a) and (b).
(c) Multiply f (x) by
1+cos x
1+cos x
cos2 x = 1.) Then nd the value of the new f (x) for x = 0:001 to 6 digits. (Round at
each step in the calculation.) Find the true relative error, and compare with your results
in (b). Explain your result.
4. Write a MATLAB program to nd cos x to a prescribed error input by the user. Use the series
solution, given by
1
X
( 1)n (2n)
cos x =
x
(2n)!
n=0
(Recall that 0! = 1.) Find cos( 3 ) to within a relative error of 0.0001. Use an estimated
relative approximation error given by
"a =
Sn
Sn
Sn
Note that Sn is the value of the summation for n terms in the series.
You should present your solution to this problem formally: