Calculus Commands in Mathematica - A Tutorial for Derivatives and Integrals
by Dianna Hrabovsky, MAST
Here we will look at some of the Mathematica commands associated with Calculus. These will include derivatives, partial and total derivatives, integrals and definite integrals, as well as a look at limits.
The Mathematica commands Derivative and D take the derivative of the function. The form that D uses is D[function, variable]. Depending on what goes in the variable spot, you can do different types of differentiations.
This took the derivative of the function with respect to a. If you wanted to do differentiation multiple times on some function, you could include the “a” and the “number of times” in curley brackets. This example will take the second derivative.
Differentiating with respect to different variables can also be done. It is put in the form of D[function, variable1, variable2, etc].
If you wanted to differentiate a scalar function with respect to more than one variable then the list of variables is enclosed in curley brackets. This example is a 3rd order derivative tensor. Note the two expressions seperated by the comma. The stuff in the curley brackets in the output is when Mathematica does the 3rd derivative of the matrix in respect to each variable. The first derivative produces a 2x2 matrix then the second derivative produces a 2x2 of 2 element vectors and finally the third derivative produces a 2x2 of 2x2 matricies.
This is a vector derivative of a scalar function whose result is a tensor. The expression does not have a comma but a plus instead. I have also included a special form called MatrixForm to the end of the expression to have the output displayed in a matrix rather than list form.
It is also possible to take the total derivative by using Dt. Dt in the output is a differential form. The total derivative is the sum of all partial derivatives rather than just assuming all the other variables are constants as with the D or Derivative command. The total differential is the total derivative where each term is multiplied by the relevant differential as you can see here.
It is the same form as the Derivative command and you can take the total derivative with respect to one or more variables. The command takes this form with respect to x and the 2nd total derivative.
To see the answer in a more understandable or traditional form, the TraditionalForm command can be applied after the expression.
Before going on to Integration and Definite Integration, we will cover Limit. The Limit command allows you to bypass doing all the algebraic calculations required to examine the behavior of a function as the independent variable or variables approach a specific value. It can be used for plotting and other examinations of functions where direct substitutions of values will not work. Limits use the “goes to” → symbol whose shortcut is [ESC]->[ESC].
Integrate is the command that can provide the indefinite integral (where there are no limits of integration), the definite integral (which is the integral with respect to limits of integration), and also multiple integration (which is integration with respect to more than one variable). These are all very similar in form to differentiation.
This is an example of the indefinite integral with respect to x,
the definite integral with respect to x from 0 to 1,
and finally the multiple variables.
To make the more traditional looking symbols you can use [ESC]int[ESC] for the ∫ Summa and [ESC]dd[ESC] for the d differential symbols. If you want to put limits on the Summa symbol then it would be [ESC]int[ESC] [CTRL]_ minvalue [CTRL]5 maxvalue . Here is an example of the expression above using these symbols. As you can see, the output is the same.
Return to the MAST Mathematica Consulting Home Page.