diff
Differentiate symbolic expression or function
Syntax
Description
Df = diff(f)f with respect to the symbolic scalar
                    variable in the definition of f. The variable of
                    differentiation is determined by symvar(f,1).
Df = diff(f,var1,...,varN)f with respect to the parameters
                        var1,...,varN.
Examples
Input Arguments
Limitations
- The - difffunction does not support tensor derivatives when using a symbolic matrix variable as the differentiation parameter. If the derivative is a tensor, or the derivative is a matrix in terms of tensors, then the- difffunction generates an error.
Tips
- When computing mixed higher-order derivatives with more than one variable, do not use - nto specify the order of the derivative. Instead, specify all differentiation variables explicitly.
- To improve performance, - diffassumes that all mixed derivatives commute. For example,- This assumption suffices for most engineering and scientific problems. 
- If you differentiate a multivariate expression or function - fwithout specifying the differentiation variable, then a nested call to- diffand- diff(f,n)can return different results. The reason is that 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 - absor- sign, the arguments must be real values. For complex arguments of- absand- sign, the- difffunction formally computes the derivative, but this result is not generally valid because- absand- signare not differentiable over complex numbers.
Version History
Introduced before R2006aSee Also
Functions
- curl|- divergence|- functionalDerivative|- gradient|- hessian|- int|- jacobian|- laplacian|- symvar