[R] Problems about Derivaties

Duncan Murdoch murdoch at stats.uwo.ca
Tue Mar 20 21:25:51 CET 2007


On 3/20/2007 3:17 PM, enrico.foscolo wrote:
> Dear participants to the list,
> 
> this is my problem: I want to obtain an expression that represents the second
> derivative of one function.
> With "deriv3" (package "stats") it is possible to evaluate the second
> derivative, but I do not know how I can get the (analytical) expression of this
> derivative.
> 
> For example: Suppose that I have a function of this form:
> f(x,y)=x^3+y^3+(x^2)*(y^2). With "deriv3" I can evaluate the first derivative
> and the hessian matrix, as follows:

R isn't the package I'd choose for symbolic calculations, but you can 
get what you want with D:

 > e <- expression(x^3+y^3+(x^2)*(y^2))
 > D(D(e, "x"), "y")
2 * x * (2 * y)


Duncan Murdoch



More information about the R-help mailing list