differentiate symbolic expression or function -凯发k8网页登录
differentiate symbolic expression or function
syntax
description
differentiates df
= diff(f
)f
with respect to the symbolic scalar
variable determined by symvar(f,1)
.
differentiates df
= diff(f
,var1,...,varn
)f
with respect to the parameters
var1,...,varn
.
examples
input arguments
limitations
the
diff
function 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 thediff
function will error.
tips
when computing mixed higher-order derivatives with more than one variable, do not use
n
to specify the order of derivative. instead, specify all differentiation variables explicitly.to improve performance,
diff
assumes that all mixed derivatives commute. for example,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 todiff
anddiff(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 likediff(f,n)
, the differentiation variable is determined once bysymvar(f,1)
and used for all differentiation steps.if you differentiate an expression or function containing
abs
orsign
, the arguments must be real values. for complex arguments ofabs
andsign
, thediff
function formally computes the derivative, but this result is not generally valid becauseabs
andsign
are not differentiable over complex numbers.