deriv: Differentiation of 'mvp' objects

derivR Documentation

Differentiation of mvp objects

Description

Differentiation of mvp objects

Usage

## S3 method for class 'mvp'
deriv(expr, v, ...)
## S3 method for class 'mvp'
aderiv(expr, ...)

Arguments

expr

Object of class mvp

v

Character vector. Elements denote variables to differentiate with respect to

...

Further arguments. In deriv(), a non-negative integer argument specifies the order of the differential, and in aderiv() the argument names specify the differentials and their values their respective orders

Details

deriv(S,v) returns \frac{\partial^r S}{\partial v_1\partial v_2\ldots\partial v_r}. Here, v is a (character) vector of symbols.

deriv(S,v,n) returns the n-th derivative of S with respect to symbol v, \frac{\partial^n S}{\partial v^n}.

aderiv() uses the ellipsis construction with the names of the argument being the variable to be differentiated with respect to. Thus aderiv(S,x=1,y=2) returns \frac{\partial^3 S}{\partial x\partial y^2}.

Author(s)

Robin K. S. Hankin

See Also

taylor

Examples


(p <- rmvp(10,4,15,5))
deriv(p,"a")
deriv(p,"a",3)
deriv(p,letters[1:3])
deriv(p,rev(letters[1:3]))  # should be the same

aderiv(p,a=1,b=2,c=1)

## verify the chain rule:
x <- rmvp(7,symbols=6)
v <- allvars(x)[1]
s <- as.mvp("1  +  y  -  y^2 zz  +  y^3 z^2")
LHS <- subsmvp(deriv(x,v)*deriv(s,"y"),v,s)   # dx/ds*ds/dy
RHS <- deriv(subsmvp(x,v,s),"y")              # dx/dy

LHS - RHS # should be zero


mvp documentation built on April 4, 2025, 3:48 a.m.