I have a project on rounding errors and truncation error
7 views (last 30 days)
Show older comments
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 Comments
Zoltán Csáti
on 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.
Answers (1)
Arkayan Laha
on 16 Nov 2018
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);
0 Comments
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!