Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The Maclaurin Series expansion for cost) i cos(x) = 1-22 + x4-r6+ (-1) 2m (2n)!

ID: 3144512 • Letter: T

Question

The Maclaurin Series expansion for cost) i cos(x) = 1-22 + x4-r6+ (-1) 2m (2n)! = Write a program that determines cosx) using the Maclaurin series expansion. The program asks the user to type a value for angle in degrees. Then the program uses a loop for adding the terms of the Maclaurin Series. 1) During execution enter 540 when prompted in the command window. The program should output to the command window in the following format: Number of Terms Approximation of Cosine 1.000000000000 -48.485099844351 359.644084589877 -986-776811484873 1392.786491185817 -1223.945233672233 738.012806789600 -328.884880272825 111.077941127100 -31.220125178636 5.841106499245 -2.098195448523 -0.674727515263 -0.891467370040 -0.863093313549 5 7 10 12 13 14 15 16 17 18 19 20 -0.866321113591 -0.865999081318 -0.866027487377 -0.866025256145 -0.866025413204 2) Run your program again, enter 25 (degrees) and append the output as run #2

Explanation / Answer

fprintf('Taylor series of cos(x) '); N = input('Enter the number of terms in the expansion: '); x = input('Enter the value of angle x in degrees to evaluate the function: '); % Taylor series of cos(x) approx = 0; for n=0:N-1 approx = approx + (-1)^n * x^(2*n) / factorial(2*n); end % Display the Taylor approximation and error fprintf(' ') fprintf('Approximation of Cosine = %.7g ',approx) fprintf('actual value = %.7g ',cos(x)); fprintf('error = %.3g ',approx-cos(x));

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote