Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 %

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

(a) Modify the provided IterMeth code so that instead of passing scalar values, it accumulates vectors containing all values of the estimated value, Va, the true relative percent error, t%, and approximate relative percent error, a%. (b) Generate a script that uses your modied IterMeth function and then plots both t% and a% as a function of iteration number. (c) How many iterations (and therefore how many terms in the Maclaurin series expansion) does it require to generate an estimated value with 11 signicant digits? (Use s = (0.510(2n))%)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions