Question: Required information Skip to question The MATLAB function to compute the Maclaurin series expansion for the exponential function is given by function [fx,ea,iter] = IterMeth(x,es,maxit)

Required information

Skip to question

The MATLAB function to compute the Maclaurin series expansion for the exponential function is given by

function [fx,ea,iter] = IterMeth(x,es,maxit) % Maclaurin series of exponential function % [fx,ea,iter] = IterMeth(x,es,maxit) % input: % x = value at which series evaluated % es = stopping criterion (default = 0.0001) % maxit = maximum iterations (default = 50) % output: % fx = estimated value % ea = approximate relative error (%) % iter = number of iterations % defaults: if nargin < 2|isempty(es),es = 0.0001;end if nargin < 3|isempty(maxit),maxit = 50;end % initialization iter = 1; sol = 1; ea = 100; % iterative calculation while (1) solold = sol; sol = sol + x ^ iter / factorial(iter); iter = iter + 1; if sol~= 0 ea = abs((sol - solold)/sol)*100; end if ea<=es | iter>=maxit,break,end end fx = sol; end

The Maclaurin series expansion for the cosine function is

cosx=1x22+x44!x66!+x88!...

As the same pattern in the given M-file, develop a well-structured MATLAB function to compute the Maclaurin series expansion for the cosine function.

(Please upload your response/solution using the controls below.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!