Q. 3 The following infinite series computes e^X . e^x =1 + x/1! + x^2/2! + x^3/3
ID: 3546544 • Letter: Q
Question
Q. 3 The following infinite series computes e^X .
e^x =1 + x/1! + x^2/2! + x^3/3! + .... , -infinity < x < infinity
Write a MATLAB script and use it to compute e^1.275 using a finite number of terms n.
(a) Submit your script.
(b) Use your script to compute e^1.275 using n=5, 10, 25. Copy and paste solution from the command window.
(c) Comment on the convergence rate
Explanation / Answer
clear all
clc
format long
n=5; % change it to 10 and 25
x=1.275;
fex=1;
for i=1:n
fex=fex+x^(i)/factorial(i);
end
fex
Result n=5 : fex =
3.571446732666015
Result n=10 : fex =
3.578701004794297
Result n=25 :fex =
3.578701410101580
As we increase the number of steps , the solution is converging to the accurate solution.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.