integration computation in R,computing the accumulation,derivatives,partial derivatives of various higher order function

求二元二次方程的偏导数:
> fun=expression(x^2+y^2+x*y)
> D(fun,"x")
2 * x + y
> D(fun,"y")
2 * y + x
> D(D(fun,"x"),"x")
[1] 2
> D(D(fun,"x"),"y")
[1] 1

继续:要求函数x 2 +y 2 +x?y 在(2,3)处的关于x 的一阶偏导数

> x=2;y=3
> eval(D(expression(x^2+y^2+x*y),"x"))
[1] 7

trig.exp <- expression(sin(cos(x + y^2)))
D.sc <- D(trig.exp, "x")
all.equal(D(trig.exp[[1]], "x"), D.sc)


## Higher derivatives
deriv3(y ~ b0 + b1 * 2^(-x/th), c("b0", "b1", "th"), c("b0", "b1", "th", "x") )

## Higher derivatives(更高维的导数)
DD <- function(expr,name, order = 1) {
if(order < 1) stop("'order' must be >= 1")
if(order == 1) D(expr,name)
else DD(D(expr, name), name, order - 1)
}
DD(expression(sin(x^2)), "x", 3)

 矩阵的求导法则:

 两个常用的两个矩阵的求导法则公式:

原文地址:https://www.cnblogs.com/beckygogogo/p/9224360.html