Site menu:




R functions for complex-step differentiation

The complex-step method is a clever way of obtaining a numerical approximation to the first derivative of a function, avoiding the round-off error that plagues standard first difference approximations [Ref 1]. An extension of the method allows second derivatives to be calculated with reduced round-off error. An overview of the method with statistical examples is available here (see also reference [3] below for the published version).

Here are the R programs for the examples in that article. The examples are all from the book by Brazzale, Davison and Reid [Ref 2].

bdr23.txt     bdr35exp.txt     bdr35ln.txt     bdr43.txt    
bdr46.txt     bdr52.txt          bdr52t4.txt     bdr54.txt

You will also need the file hessian.txt which contains various functions.

References

[1] Squire, W. and Trapp, G. (1998). Using complex variables to estimate derivatives of real functions. SIAM Review, 40, 110-112.

[2] Brazzale, A.R., Davison, A.C. and Reid, N. (2007). Applied Asymptotics: Case Studies in Small-Sample Statistics, Cambridge: Cambridge University Press.

[3] Ridout, M.S. (2009) Statistic applications of the complex-step method of numerical differentiation. The American Statistician, 63, 66-74. [Journal link]