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

The Taylor series expansion for cos(x) is cos(x) = 1 - x^2/2! + x^4/4! - x^6/6!

ID: 3402415 • Letter: T

Question


The Taylor series expansion for cos(x) is cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! + ... = sigma_n = 0^infinity (-1)^n/(2n)! x^2n where x is in radians Write a user-defined function y = lastname_cos_taylor(x, n, er) where the input angle x is in degrees, n number of terms and er is error. Use loop to add the terms of the Taylor series. Calculate the error E = |sn - sn - 1/sn - 1| and stop when E lessthanorequalto 0.0000001 or when user provided n is reached. Input and output must be in the main program script.

Explanation / Answer

following is the matlab program

clc;
close all;
clear all;

theta=pi*60/180;

e=1;
n=1;
S(1)=1;

while abs(e)>=.000001
  
S(n+1)=S(n)+(-1)^(n).*theta^(2*(n))./factorial(2*(n));

e=(S(n+1)-S(n))/(S(n));
  
n=1+n;

  
end

disp(S);

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