Someone with Matlab experience... so confused The Maclaurin scries expansion for
ID: 2270513 • Letter: S
Question
Someone with Matlab experience... so confused
The Maclaurin scries expansion for the exponential function is: cos x = 1 - x2/2! + x4/4! - x6/6! + x8/8! - ... Write an m-file that, starting from the simplest version (cos x = I), adds one term at a time to estimate cos(5pi/3). After each new term is added, compute the relative true error (epsilont) and relative approximate error (epsilona). Use MATLAB's built-in cosine function to calculate the true value. Use a while loop to continue adding terms until | epsilon |Explanation / Answer
function cosx = mycos1(x,n) %Evaluate and sum the first n terms of the cosx Taylor Series. if n~=round(n) disp('Error: n must be an integer value.') cosx = 0; return end if nRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.