Numerical Differentiation. What is the best method? - MathOverflow most recent 30 from http://mathoverflow.net 2013-06-19T16:35:44Z http://mathoverflow.net/feeds/question/64302 http://www.creativecommons.org/licenses/by-nc/2.5/rdf http://mathoverflow.net/questions/64302/numerical-differentiation-what-is-the-best-method Numerical Differentiation. What is the best method? Yrogirg 2011-05-08T14:28:25Z 2011-05-08T15:33:31Z <p>What is the best method for 1D numeric differentiation? Something as glorious as Gaussian quadrature for numeric integration.</p> <p>Maybe differential quadrature is such a method? What is its accuracy?</p> <p>I'm well aware that it is really easy to have symbolic differentiation in the program (automatic differentiation or truly symbolic algorithm). However to use such methods it is necessary to rewrite all functions to be differentiated. Thus one can't differentiate functions imported from libraries.</p> <p>I need differentiation almost with the machine precision.</p> http://mathoverflow.net/questions/64302/numerical-differentiation-what-is-the-best-method/64306#64306 Answer by J. M. for Numerical Differentiation. What is the best method? J. M. 2011-05-08T15:33:31Z 2011-05-08T15:33:31Z <p>If your function is badly behaved (e.g. noisy, very oscillatory), no method will perform properly (differentiation is numerically very <em>unstable</em>). That being said, for "nice functions", I have good experience with polynomial (Richardson) extrapolation methods. <a href="http://dx.doi.org/10.1007/BF02166671" rel="nofollow">This paper</a> and <a href="http://dx.doi.org/10.1007/BF01933664" rel="nofollow">this paper</a> give hints on how you might write your own implementation. I will note that this is the method implemented in the <a href="http://nag.co.uk/numeric/numerical_libraries.asp" rel="nofollow">NAG numerical libraries</a> (with of course a few wrinkles of their own).</p> <p>There are two possible alternatives if for some reason you don't want to use Richardsonian methods. One is to use Cauchy's differentiation formula:</p> <p>$$f^\prime(x)=\frac1{2\pi i}\oint_\gamma \frac{f(t)}{(t-x)^2}\mathrm dt$$</p> <p>where it is up to you to choose a suitable counterclockwise contour $\gamma$ (a circle is customary); the other is to use the <a href="http://www.jstor.org/pss/2589707" rel="nofollow">"Lanczos derivative"</a>:</p> <p>$$f^\prime(x)=\lim_{h\to 0}\frac{3}{2h^3}\int_{-h}^h t\;f(x+t)\mathrm dt$$</p> <p>where you either will have to experiment with an appropriate step size $h$, or use some extrapolative procedure.</p> <p>You will have to experiment with your computing environment to choose.</p>