I have a project on rounding errors and truncation error
Afficher commentaires plus anciens
Project 1 (Rounding vs. Truncation Errors)
1. Apply the backward difference schemes to approximate the derivative of the function, f(x)=e^x , at x = 1. 2. To investigate the effect of spacing of discrete points, h, a series of values of h are adopted, that is, h = 1/2n (n = 1, 2, …, 100). 3. Calculate and list the absolute error, eabs, for each choice of h (or n). Plot log10(eabs) vs. log10(h) and explain what you observe. Also derive the order of accuracy by calculating the slope in the truncation-error dominated part.
How can I solve this Project? I need to be calculate by hand and use MATLAB.
2 commentaires
Zoltán Csáti
le 7 Jan 2015
This is a very simple task. You will experience that by reducing the step-size, the rounding error will grow, while the truncation error will be smaller and smaller. Show what you have done so far.
Ming-Yi Sun
le 8 Jan 2015
Modifié(e) : Ming-Yi Sun
le 8 Jan 2015
Réponses (1)
Arkayan Laha
le 16 Nov 2018
0 votes
x=1.2; %value at which error has to be determined
f=@(x) exp(x); %defining the function
true_derivative=exp(x);%exact derivative result
for i=1:20
h(i,1)=0+.01*i;
n_d(i,1)=(f(x+h(i,1))-f(x))/h(i,1);%numerical derivative
e(i,1)=n_d(i,1)-true_derivative; %error
err(i,1)=abs(e(i,1)); %absolute error
end
plot(h,err);
Catégories
En savoir plus sur Calculus dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!