Main Content

Differentiate symbolic expression or function

differentiates `Df`

= diff(`f`

)`f`

with respect to the symbolic variable
determined by `symvar(f,1)`

.

differentiates `Df`

= diff(`f`

,`var1,...,varN`

)`f`

with respect to the parameters
`var1,...,varN`

.

When computing mixed higher-order derivatives with more than one variable, do not use

`n`

to specify the differentiation order. Instead, specify all differentiation variables explicitly.To improve performance,

`diff`

assumes that all mixed derivatives commute. For example,$$\frac{\partial}{\partial x}\frac{\partial}{\partial y}f\left(x,y\right)=\frac{\partial}{\partial y}\frac{\partial}{\partial x}f\left(x,y\right)$$

This assumption suffices for most engineering and scientific problems.

If you differentiate a multivariate expression or function

`f`

without specifying the differentiation variable, then a nested call to`diff`

and`diff(f,n)`

can return different results. This is because in a nested call, each differentiation step determines and uses its own differentiation variable. In calls like`diff(f,n)`

, the differentiation variable is determined once by`symvar(f,1)`

and used for all differentiation steps.If you differentiate an expression or function containing

`abs`

or`sign`

, ensure that the arguments are real values. For complex arguments of`abs`

and`sign`

, the`diff`

function formally computes the derivative, but this result is not generally valid because`abs`

and`sign`

are not differentiable over complex numbers.

`curl`

| `divergence`

| `functionalDerivative`

| `gradient`

| `hessian`

| `int`

| `jacobian`

| `laplacian`

| `symvar`