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

Problem 1 ) The Maclaurin series expansion for cos (x) ?s 6 cosx1- Starting with

ID: 3915313 • Letter: P

Question

Problem 1 ) The Maclaurin series expansion for cos (x) ?s 6 cosx1- Starting with the simplest version, cos x-1, add terms one at a time to estimate cos (?/3). After each a new term is added, compute the true and approximate percent relative errors. Use your calculator or MATLAB to determine the true value. Add terms until the absolute value of the approximate error estimate fall below an conforming to two significant figures. Problem 2) Develop a well-structured MATLAB function to compute the Maclaurin series expansion for the cosine function as described in the above problem.

Explanation / Answer

I have given true_percent_relative_error and approximate_percent_relative_error as output for each iteration.

Here is the running matlab code:

function [ answer ] = Maclaurian( x )
%my_function(x) to calculate cos(x) using Maclaurian expansion

term = 0;
abs_error=1; %define the term absolute error
true_percent_relative_error = 1; %define the term true_percent_relative_error
approximate_percent_relative_error =1; %define the term approximate_percent_relative_error
n=1;
while abs(abs_error)>0.001    %checking error criterion
    display(n,'iteration')
%     n
  
    term_old = term;
    term = term+((-1)^(n-1))*((x^(2*n-2))/factorial(2*n-2));
    abs_error = term-term_old;
    true_percent_relative_error = 100*(cos(x)-term)/cos(x)
    approximate_percent_relative_error = 100*abs_error/term
    n=n+1;
end
answer = term;
end

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