[R] how to get higher derivatives with "deriv"

Wu Gong wg2f at mtmail.mtsu.edu
Thu Jul 29 23:27:59 CEST 2010


## specify the function string
f.str <- "x^alpha"

## higher derivatives 
DD <- function(f.str, x = 2, alpha=3,order = 1){
expr.s <- parse(text=f.str)
while(order>=1) {
expr.s <- D(expr.s,"x")
order <- order-1}
eval(expr.s)
}

compute
DD(f.str,x=1,alpha=0.5,order=1)

-----
A R learner.
-- 
View this message in context: http://r.789695.n4.nabble.com/how-to-get-higher-derivatives-with-deriv-tp2306711p2307241.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list