Using matlab create program to show the following -Display the amount of terms u
ID: 3541863 • 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
The Taylor series for ex at point x = 0 is given by ex = 1 + x + x2 / 2! + x3 / 4! + 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
n=15
sum=1
x=1
for i=1:n
sum=sum+(power(x,i)/factorial(i));
end
series_sum=sum
disp('e^1:')
exact_value= e^1
Error=exact_value-series_sum
disp('For error to be less than 10^-6')
x=1;
error=100000;
i=1;
sum=1;
while(error>0.000001)
sum=sum+(power(x,i)/factorial(i));
error=exact_value-sum;
i=i+1;
end
n=i
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.