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

Any programming genius? The exponential function can be evaluated by the followi

ID: 3550931 • Letter: A

Question

Any programming genius?


The exponential function can be evaluated by the following infinite series: ex = exp (x) = 1 + x + x2 / 2! + x3 / 3! + x4 / 4! +... Write a MatLab code to implement this formula so that it computes and prints out the values of exp(x) as each term in the series is added. In other words, compute and print in sequence the values for: S1 = 1 Sz= 1 + x S3 = 1 + x + x2 / 2! Sn = 1 = X + x2 / 2! + ... + xn / n! Your algorithm will not ask the user for the number of terms to consider for the calculations, but it will ask for the acceptable (error). So, the while loop will be repeated till the time that error is less than the given acceptable error (for example 1%). At each stage error can be calculated using the following formula: relative % error = true - Series Approximation / true

Explanation / Answer

function s = expex(t)

% EXPEX Experimental version of EXP(T)

s = 1;

term = 1;

n = 0;

r = 0;

while r ~= s

r = s;

n = n + 1;

term = (t/n)*term;

s = s + 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