Find the MacLaurin series for cos(5x), and use it to estimate cos (0.5) with at
ID: 670952 • Letter: F
Question
Find the MacLaurin series for cos(5x), and use it to estimate cos (0.5) with at least 4 significant figures (by hand). As part of your answer, add terms one at a time until an appropriate stopping criterion for the approximate relative error gives you an estimate of the desired accuracy. Use the MacLaurin series for cos (5x) from part, to estimate cos 5 with at least 3 significant figures (using MATLAB). Include a printout or write-up of the commands and/or M-functions used in MATLAB, and of the output generated. Indicate dearly what your corresponding estimate for cos 5 is, mid the stopping criterion used.Explanation / Answer
we have the series as:
f (x) = f(0) + x f'(0) + 1/2! x2 f''(0) + 1/3 x3 f'''(0) + ...
given function cos(5x)
f(x) = cos 5x
f'(x) = - 5sin x
f'' (x) = - 25cos x
f'''(x) = - (- sin x) =125 sin x
f''''(x) =625 cos x
f'''''(x) = -3125 sin x
caluclating cos(0.5)
1 - (1/2)^2/2 + (1/2)^4/24 - (1/2)^6/720 +...
1 - 1/8 + 1/384 - 1/(720*64) + ...
1-0.125+0.0026041-0.000022+..
Ans=0.87758
when corrected to nearest four digits 0.8776.
here the series has been stopped since next value is less than the 0.000022.
matlab code:
clear all;
clc;
%matlab code for MacLaurin series
% cos(x) = 1 - x^2/2! + x^4/4! - ...
% Find: number of terms needed to represent cos(x) to
% 3 significant figures at the point where: x = 0.3 pi
x = 0.3 * pi;
es = 0.5e-03;
%approximation
cosi = 1;
j = 1;
% j=terms counter
fprintf('j= %2.0f cos(x)= %0.10f ', j,cosi)
fact = 1;
while(1)
j = j + 1;
i = 2 * j - 2;
fact = fact * i * (i - 1);
cosn = cosi + ((-1) ^ (j + 1)) * ((x) ^ i) / fact;
ea = abs((cosn - cosi) / cosn);
fprintf('j= %2.0f cos(x)= %0.10f ea = %0.1e ',j,cosn,ea)
if ea < es, break, end
cosi = cosn;
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.