Determine the number of terms necessary to approximate cos x

Determine the number of terms necessary to approximate cos x to 8 significant figures using the Maclaurin series approximation cos x = 1 - x^2/2 + x^4/4! - x^6/6! + x^8/8! - ... Calculate the approximation using a value of x = 0.3 pi. Write a program to determine your result.

Solution

function approx(sig_fig)

e_criterion = (0.5*10^(2-sig_fig))*100;

x = 0.3 * pi;

e_absolute == (0.5*10^(2-sig_fig)+1)*100;

i = 0;

while e_absolute > e_criterion

i = i + 1;

result(i)=((-1)^(i-1)*(x^(2*(i-1))))/(factorial(2*(i-1)));

while i > 1;

e_absolute = ( result(i) - result(i-1) ) / result(i);

end

if e_absolute < e_criterion

disp(result (i));

end

end

a=appro(0.3*pi)

a:

0.587

 Determine the number of terms necessary to approximate cos x to 8 significant figures using the Maclaurin series approximation cos x = 1 - x^2/2 + x^4/4! - x^6

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site