Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

% define the range nn = 2 0 ; % define the loop for calculation of error sum 1 = 0 ;sum 2 = 0

%define the range
nn=20;
% define the loop for calculation of error
sum1=0;sum2=0;
for ii=1:nn;
% formula 1 and 2 values
sum1=0;sum2=0
for jj=1:ii
sum1=sum1+(-1)^(jj-1)*4^(jj-1)/factorial(jj-1);
sum2=sum2+4^(jj-1)/factorial(jj-1);
end
f_1_val(ii)=sum1;
f_2_val(ii)=1/sum2;
% formula 1 and 2 true errors
e_t_1(ii)=abs(f_1_val(ii)-exp(-4))/exp(-4)*100;
e_t_2(ii)=abs(f_2_val(ii)-exp(-4))/exp(-4)*100;
end;
% formula 1 and 2 relative approxilate errors
e_a_1=[];
e_a_2=[];
e_a_1(1)=0;
e_a_2(1)=0;
for kk=2:nn;
e_a_1(kk)=abs(f_1_val(kk-1)-f_1_val(kk))/exp(-4)*100;
e_a_2(kk)=abs(f_2_val(kk-1)-f_2_val(kk))/exp(-4)*100;
end
T=table(f_1_val',e_t_1',e_a_1',f_2_val',e_t_2',e_a_2');
filename='C:\Users\user\Documents\MATLAB\rel_tru_error.xlsx';
writetable(T,filename,'sheet',1,'WriteVariableNames',false);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions