Download presentation
Presentation is loading. Please wait.
Published byΕΞΟΞΌαΎΆΟ ΞΞ±ΞΌΟΟΟΟΞΏΟ Ξ»ΞΏΟ Modified over 6 years ago
1
Sec:4.3 Total Numerical Error
2
Sec:4.3 Total Numerical Error
a centered difference approximation of the first derivative can be written as forward finite difference π π π+π βπ π π π β π β² π π = π π (π) π π Finite-difference Approximation True value Truncation Error We are using digital computers, the function values do include round-off error as in π π π = π π π + π π π π π+π = π π π+π + π π+π π π π+π βπ π π π β π β² π π = π π+π β π π π + π π (π) π π Finite-difference Approximation True value Round-off error Truncation Error Total Numerical Error
3
Sec:4.3 Total Numerical Error
π π π+π βπ π π π β π β² π π β€ π π+π β π π π + π π (π) π π We can see that the total error of the finite-difference approximation consists of a round-off error which increases with step size and a truncation error that decreases with step size. Finite-difference Approximation True value Round-off error Truncation Error Total Numerical Error Assuming that the absolute value of each component of the round-off error has an upper bound of Ξ΅ Round-off error = π π+π β π π π β€ ππΊ π π π+π β€πΊ , π π β€πΊ π π+π β π π β€ππΊ assume that the second derivative has a maximum absolute value of M. Truncation Error = π π (π) π πβ€ π΄ π π π π (π) β€π΄ β€ ππΊ π + π΄ π π β πππ‘ = 4 π π Total Numerical Error An optimal step size can be determined by differentiating setting the result equal to zero and solving for h
4
Sec:4.3 Total Numerical Error
Example: use forward difference approximation of O(h) to estimate the first derivative of the following function at x = 0.5, π (π₯) = β0.1 π₯ 4 β 0.15 π₯ 3 β 0.5 π₯ 2 β 0.25π₯ + 1.2 (a) Perform the same computation starting with h = 1. Then progressively divide the step size by a factor of 10 to demonstrate how round-off becomes dominant as the step size is reduced. Recall that the true value of the derivative is β At first, round-off is minimal and the estimate is dominated by truncation error. A minimum error is reached at h = 10 β8 . Beyond this point, the error increases as round-off dominates. step size finite difference true error β πππ‘ = 4 π π (b) Relate your results to Because MATLAB has a precision of about 15 to 16 digits, a rough estimate of the upper bound on round-off would be about π=0.5Γ 10 β16 . πβ²β² π₯ = β(1.2 π₯ π₯ + 1) πβ πβ²β² =1.75 β πππ‘ = 4 π π = 4β0.5Γ 10 β =1.07Γ 10 β8
5
Sec:4.3 Total Numerical Error
Example: use forward difference approximation of O(h) to estimate the first derivative of the following function at x = 0.5, π (π₯) = β0.1 π₯ 4 β 0.15 π₯ 3 β 0.5 π₯ 2 β 0.25π₯ + 1.2 Perform the same computation starting with h = 1. Then progressively divide the step size by a factor of 10 to demonstrate how round-off becomes dominant as the step size is reduced. Relate your results to Eq. (4.31). Recall that the true value of the derivative is β format long fun -0.1*x^4-0.15*x^3-0.5*x^2-0.25*x+1.2; dfun -0.4*x^3-0.45*x^2-x-0.25; x=0.5; exact = dfun(0.5); h =1; for i=1:11 h_vec(i) = h; [bd,fd,cd] = num_diff(fun,x,h); fd_vec(i) = fd; error(i) = exact - fd; h = h/10; end res = [h_vec' fd_vec' error']; fprintf(' step size finite difference true error\n'); fprintf('%14.10f %16.14f %16.13f\n', res'); plot(log10(h_vec),log10(error)),xlabel('Log(Step Size)'),ylabel('Log(Error)') title('Plot of Error Versus Step Size') grid on
6
Problems 1) (a) Use Taylor series to express π( π₯ πβ2 ) and π( π₯ πβ1 ) with center π₯ π . (b) Use problem (1) to show that the following formula is of order πΆ π . π π π βππ π πβπ +π π πβπ π π 2) Drive a formula for the condition number π πβ²( π ) π π 3) Drive a formula for the optimal step size β πππ‘ for a centered difference approximation of the first derivative β πππ‘ = 3 3 π π
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.