Need the matlab code 1 is known that the exponential function is analytic and ca
ID: 2074389 • Letter: N
Question
Need the matlab code
1 is known that the exponential function is analytic and can be expressed as: Truncate the series to compute the first seven estimates (ie. for l = 0, 1, 2, 3, 4, 5, and 6) for x 1.5. For each estimate determine the magnitude of the true error and approximate percent relative error. Arrange your results in a table (use printf-see workshop 5) that has column 1 as the ‘# of terms' included in the estimate, the second column the 'estimate', the third column the 'true error and the fourth column the Magnitude of the Approximate Percent Relative Error, 'MAPRE'. Express everything, except the number of terms, in decimal format with 10 digits after the decimal pointExplanation / 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.