Symbolic Math Toolbox | ![]() ![]() |
The Symbolic Math Toolboxes provide functions to do the basic operations of calculus; differentiation, limits, integration, summation, and Taylor series expansion. The following sections outline these functions.
Differentiation
Let's create a symbolic expression:
differentiates f
with respect to its symbolic variable (in this case x
), as determined by findsym
:
To differentiate with respect to the variable a
, type
To calculate the second derivatives with respect to x
and a
, respectively, type
Define a
, b
, x
, n
, t
, and theta
in the MATLAB workspace, using the sym
command. The table below illustrates the diff
command.
f |
diff(f) |
x^n |
x^n*n/x |
sin(a*t+b) |
cos(a*t+b)*a |
exp(i*theta) |
i*exp(i*theta) |
To differentiate the Bessel function of the first kind, besselj(nu,z)
, with respect to z
, type
The diff
function can also take a symbolic matrix as its input. In this case, the differentiation is done element-by-element. Consider the example
You can also perform differentiation of a column vector with respect to a row vector. Consider the transformation from Euclidean (x, y, z) to spherical coordinates as given by
,
, and
. Note that
corresponds to elevation or latitude while
denotes azimuth or longitude.
To calculate the Jacobian matrix, J, of this transformation, use the jacobian
function. The mathematical notation for J is
For the purposes of toolbox syntax, we use l
for and
f
for . The commands
J = [ cos(l)*cos(f), -r*sin(l)*cos(f), -r*cos(l)*sin(f)] [ cos(l)*sin(f), -r*sin(l)*sin(f), r*cos(l)*cos(f)] [ sin(l), r*cos(l), 0]
Notice that the first argument of the jacobian
function must be a column vector and the second argument a row vector. Moreover, since the determinant of the Jacobian is a rather complicated trigonometric expression, we used the simple
command to make trigonometric substitutions and reductions (simplifications). The section Simplifications and Substitutions discusses simplification in more detail.
A table summarizing diff
and jacobian
follows.
Mathematical Operator |
MATLAB Command |
![]() |
diff(f) or diff(f,x) |
![]() |
diff(f,a) |
![]() |
diff(f,b,2) |
![]() |
J = jacobian([r:t],[u,v]) |
![]() | Using the Symbolic Math Toolbox | Limits | ![]() |