# deriv

From spray v1.0-6
by Robin K S Hankin

##### Partial differentiation of spray objects

Partial differentiation of spray objects interpreted as multivariate polynomials

- Keywords
- mathsymbol

##### Usage

```
# S3 method for spray
deriv(expr, i , derivative = 1, ...)
aderiv(S,orders)
```

##### Arguments

- expr
A spray object, interpreted as a multivariate polynomial

- i
Dimension to differentiate with respect to

- derivative
How many times to differentiate

- ...
Further arguments, currently ignored

- S
spray object

- orders
The orders of the differentials

##### Details

Function `deriv.spray()`

is the method for generic `spray()`

;
if `S`

is a spray object, then `spray(S,i,n)`

returns
\(\partial^n S/\partial x_i^n = S^{\left(x_i,\ldots,x_i\right)}\).

Function `aderiv()`

is the generalized derivative; if `S`

is a
spray of arity 3, then `aderiv(S,c(i,j,k))`

returns
\(\frac{\partial^{i+j+k} S}{\partial x_1^i\partial
x_2^j\partial x_3^k}\).

##### Value

Both functions return a spray object.

##### See Also

##### Examples

```
# NOT RUN {
S <- spray(matrix(sample(-2:2,15,replace=TRUE),ncol=3),addrepeats=TRUE)
deriv(S,1)
deriv(S,2,2)
# differentiation is invariant under order:
aderiv(S,1:3) == deriv(deriv(deriv(S,1,1),2,2),3,3)
# Leibniz's rule:
S1 <- spray(matrix(sample(0:3,replace=TRUE,21),ncol=3),sample(7),addrepeats=TRUE)
S2 <- spray(matrix(sample(0:3,replace=TRUE,15),ncol=3),sample(5),addrepeats=TRUE)
S1*deriv(S2,1) + deriv(S1,1)*S2 == deriv(S1*S2,1)
# Generalized Leibniz:
aderiv(S1*S2,c(1,1,0)) == (
aderiv(S1,c(0,0,0))*aderiv(S2,c(1,1,0)) +
aderiv(S1,c(0,1,0))*aderiv(S2,c(1,0,0)) +
aderiv(S1,c(1,0,0))*aderiv(S2,c(0,1,0)) +
aderiv(S1,c(1,1,0))*aderiv(S2,c(0,0,0))
)
# }
```

*Documentation reproduced from package spray, version 1.0-6, License: GPL (>= 2)*

### Community examples

Looks like there are no examples yet.