Problem 46918. Numerical differentiation with high precision
A basic approach for numerical differentiation is by calculating the difference quotient , see for example Problem 2892. Unfortunately, this approach leads to the problem that for small step sizes h a subtractive cancellation error occurs, while for large step sizes the truncation error of the numerical scheme dominates. The same problem occurs also for similar numerical schemes of higher order.
Task: Can you find a numerical approach that eliminates the subtractive cancellation error and enables accuracies up to machine accuracy for small step sizes? Inputs to your function are a function handle fun to a scalar function, as well as the point x0, at which the numerical derivative should be calculated.
Hint: If you do not have any idea, check out Cleve's Corner. Back in the year 2013, you will find an interesting article.
Solution Stats
Problem Comments
-
2 Comments
Rafael S.T. Vieira
on 23 Oct 2020
Nice problem. And thanks for the tip about Cleve's article and paper.
ChrisR
on 12 Dec 2020
I enjoy Cody most when it teaches me something. Thanks, Alex.
Solution Comments
Show commentsProblem Recent Solvers10
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
6232 Solvers
-
Find the sum of the elements in the "second" diagonal
1149 Solvers
-
Detect a number and replace with two NaN's
190 Solvers
-
80 Solvers
-
1402 Solvers
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!