Diff Function

diff('expression','variable','order') differentiates. If order is omitted, the first-order derivative is assumed.

The function is used to perform symbolic or numeric derivatives. It can be inserted by typing diff( or from the Function palette, under the Derivative template (this is simpler).

Choose the Derivative template and insert x in the 'variable' placeholder and x² in the 'expression' placeholder. Then press CTRL+. (symbolic calculation). You should get this result:

basic derivative

We could also have first defined the expression f in terms of x and y, for instance:

defining f(x, y)

and then found the first derivatives with respect to each variable (partial derivatives, in this case):

partial derivatives

To get higher-order derivatives, press comma after the 'variable' and insert the 'order' (an integer) in the resulting placeholder. Here are the second derivatives:

second derivatives

Mixed derivatives work the same way:

mixed derivatives

Instead of an expression, you could define a function and repeat the procedure:

derivative of a function

Numerical derivatives are evaluated at the given values. For instance:

numerical derivative

A very important SMath feature is the ability to find derivatives over the elements of a vector (matrix). Here is an example of finding the Jacobi matrix and the Jacobian:

Jacobi matrix and Jacobian

This page is based on a legacy wiki article by Radovan Omorjan.