Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have created a Matlab function that approximates e^x using the infinite series and truncating it to n terms I specifically need to modify this

I have created a Matlab function that approximates e^x using the infinite series

image text in transcribed and truncating it to n terms

I specifically need to modify this code so for n = 10, the relative error between the approximation and actual value is

Here is the code:

function [err] = approx(n,x)

if(x

s = x * (-1);

else

s = x;

end

t = zeros(1, n+1);

for ii = 0:n

t(ii + 1) = (s.^ii)/factorial(ii);

end

tSum = sum(t);

if(x

finalSum = 1/tSum;

else

finalSum = tSum;

end

err = abs(exp(x) - finalSum)/finalSum

end

lim nex ito

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

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions

Question

How do we organise for international logistics?

Answered: 1 week ago

Question

What are the logistics implications of internationalisation?

Answered: 1 week ago