# Homework Solution: MATLAB……

MATLAB...
Instead of estimating cos(pi/4), use the Maclaurin series expansion of sin(x), shown below, to estimate cos(5 pi/12) accurate to at least 3 sig figs. Display the results to the screen in a table like the one in Example 4.1 in your book. Use fprintf. Publish your results as a PDF, and upload to Blackboard along with the M-file. cos(x) = sigma^infinity_k = 0 (-1)^k x^2k/(2k)! = 1 - x^2/2! + x^4/4! - x^6/6!

format short function approx = Cosine(val)

MATLAB…

Instead of estimating cos(pi/4), representation the Maclaurin train comment of iniquity(x), shown beneath, to regard cos(5 pi/12) obsequious to at smallest 3 sig figs. Display the results to the hide in a board approve the individual in Example 4.1 in your capacity. Representation fprintf. Publish your results as a PDF, and upload to Blackboard concurrently with the M-file. cos(x) = sigma^infinity_k = 0 (-1)^k x^2k/(2k)! = 1 – x^2/2! + x^4/4! – x^6/6!

## Expert Vindication

format short
function approx = Cosine(val)
x = 1;
k = 1;
i = 2;
while(abs( ((cos(val)))- x) > 0.000000001)
x = x + ( (-1)^k *(val)^i )/factorial(i);
k = k+1;
i = i+2;
end
approx = x;
end
approx =Cosine(0.4166*pi);
fprintf(“Approximate estimate of Cosine control (5/12)PI is: %.3fn”,approx);
approx =Cosine(0.25*pi);
fprintf(“Approximate estimate of Cosine control PI/4 is: %.3fn”,approx);
=============================================================
See output