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

Using matlab create program to show the following -Display the amount of terms u

ID: 3541871 • Letter: U

Question

Using matlab create program to show the following

-Display the amount of terms used.

-Display value of e^1

-Display relative approximate error of less than 10^-9 instead of 10^-6

The Taylor series for ex at point x = 0 is given by ex = 1 + x + x2 / 2! + x3 / 3! + x4 / 4! + x5 / 5! +... It can be seen that as the number of terms used increases, the error bound decreases and hence a better estimate of the function can be found. How many terms would it require to get an approximation of e1 within a magnitude of true error of less than 10-6.

Explanation / Answer

z = 10^(-9);

estimate = 0;

term = 1;

x = 1;

n = 1;

while exp(x)-estimate>z;

estimate = estimate+term;

term = term*x/n;

n = n+1;

end

fprintf(' No. of terms used = %d ',n);

fprintf(' value of e^1 = %f ',exp(x));

fprintf(' relative approximate ');

error = (exp(x)-estimate)/estimate


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