For differentiating an expression, use the diff command. Specify the expression you want to differentiate, and the differentiation variable. Specifying the differentiation variable is important even if your expression contains only one variable. For example, find the derivative of an expression with one variable:
diff(x^2 + sqrt(sin(x)), x)
Note: If you do not specify differentiation variable, diff(expr) returns the expression expr.
Find first-order partial derivatives of a multivariable expression by specifying differentiation variables:
diff(sin(x*cos(x*y)), x); diff(sin(x*cos(x*y)), y)
To take second and higher order derivatives, you can use nested calls to the diff function. More efficiently, use only one diff command and specify variables for each differentiation step. Calling diff only once is shorter and also can improve performance because MuPAD® internally converts nested calls to diff into a single call with multiple arguments:
diff(diff(sqrt(sin(x)), x), x); diff(sqrt(sin(x)), x, x)
When computing higher order derivatives with respect to one variable, use the sequence operator as a shortcut:
diff(sqrt(sin(x)), x $ 3) = diff(sqrt(sin(x)), x, x, x)
To compute mixed derivatives, specify differentiation variables for each step:
diff(x*cos(x*y), y, x)
This assumption suffices for most of engineering and scientific problems.