Numerical Derivative / Numerical Differentiation of unknown funct ion
A current version of this code is in the dseplus bundle in the devel section of CRAN. It does Richardson's extrapolation, which gives an accurate numerical estimate at the expense of speed. (It does a very large number of function evaluations.) That may not be what you want. Paul Gilbert
Uzuner, Tolga wrote:
Hi,
I have been trying to do numerical differentiation using R.
I found some old S code using Richardson Extrapolation which I managed to get
to work.
I am posting it here in case anyone needs it.
########################################################################
richardson.grad <- function(func, x, d=0.01, eps=1e-4, r=6, show=F){
# This function calculates a numerical approximation of the first
# derivative of func at the point x. The calculation
# is done by Richardson's extrapolation (see eg. G.R.Linfield and
J.E.T.Penny
# "Microcomputers in Numerical Analysis"). The method should be used if
# accuracy, as opposed to speed, is important.
#
# * modified by Paul Gilbert from orginal code by XINGQIAO LIU.
...