It is known that the exponential function is analytic and can be expressed as: e
ID: 3883814 • Letter: I
Question
It is known that the exponential function is analytic and can be expressed as: e^x = sigma^infinity_i = 0 x^i/i! Truncate the series to compute five different estimates (i.e. sum to 1, 2, 3, 4 and 5th terms) for x = 0.25. For each estimate determine the true error and approximate percent relative error. Arrange your results in a table (use fprintf - see workshop 5) that has column 1 as the 'number of terms' included in the estimate, the second column the 'estimate', the third column the 'true error' and the fourth column the Approximate Relative Percent Error 'APRE'. Express in decimal format with 10 digits after the decimal point.Explanation / Answer
clc
clear all
close all
true_value = exp(0.25);
> twoterm= 1+0.25+(0.25)^2/2;
threeterm=1+0.25+(0.25)^2/2!+(0.25)^3/3!;
fourterm= 1+0.25+(0.25)^2/2!+(0.25)^3/3!+(0.25)^4/4!;
true_error1 = true_value-oneterm;
true_error2 = true_value-twoterm;
true_error3 = true_value-threeterm;
true_error4 = true_value-fourterm;
percent_rel_error1 = (true_value-oneterm)*100/true_value;
percent_rel_error2 = (true_value-twoterm)*100/true_value;
percent_rel_error3 = (true_value-threeterm)*100/true_value;
percent_rel_error4 = (true_value-fourterm)*100/true_value;
M(1,1)= oneterm;
M(2,1)=twoterm;
M(3,1)=threeterm;
M(4,1)=fourterm;
M(1,2)= true_error1;
M(2,2)=true_error2;
M(3,2)=true_error3;
M(4,2)=true_error4;
M(1,3)= percent_rel_error1;
M(2,3)=percent_rel_error2;
M(3,3)=percent_rel_error3;
M(4,3)=percent_rel_error4;
printmat(M, 'Result Table', '1 2 3 4 ', 'Estimate TrueError RelativePercentError' )
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.