This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
Mathematica TutorialTutorials »

The Representation of Derivatives

Derivatives in Mathematica work essentially the same as in standard mathematics. The usual mathematical notation, however, often hides many details. To understand how derivatives are represented in Mathematica, we must look at these details.
The standard mathematical notation f (0) is really a shorthand for , where t is a "dummy variable". Similarly, f (x2) is a shorthand for . As suggested by the notation f, the object can in fact be viewed as a "pure function", to be evaluated with a particular choice of its parameter t. You can think of the operation of differentiation as acting on a function f, to give a new function, usually called f.
With functions of more than one argument, the simple notation based on primes breaks down. You cannot tell for example whether g (0, 1) stands for or , and for almost any g, these will have totally different values. Once again, however, t is just a dummy variable, whose sole purpose is to show with respect to which "slot" g is to be differentiated.
In Mathematica, as in some branches of mathematics, it is convenient to think about a kind of differentiation that acts on functions, rather than expressions. We need an operation that takes the function f, and gives us the derivative function f. Operations such as this that act on functions, rather than variables, are known in mathematics as operators.
The object f' in Mathematica is the result of applying the differentiation operator to the function f. The full form of f' is in fact Derivative[1][f]. Derivative[1] is the Mathematica differentiation operator.
The arguments in the operator Derivative[n1, n2, ...] specify how many times to differentiate with respect to each "slot" of the function on which it acts. By using operators to represent differentiation, Mathematica avoids any need to introduce explicit "dummy variables".
This is the full form of the derivative of the function f.
Click for copyable input
Here an argument x is supplied.
Click for copyable input
This is the second derivative.
Click for copyable input
This gives a derivative of the function g with respect to its second "slot".
Click for copyable input
Here is the full form.
Click for copyable input
Here is the second derivative with respect to the variable y, which appears in the second slot of g.
Click for copyable input
This is a mixed derivative.
Click for copyable input
Since Derivative only specifies how many times to differentiate with respect to each slot, the order of the derivatives is irrelevant.
Click for copyable input
Here is a more complicated case, in which both arguments of g depend on the differentiation variable.
Click for copyable input
This is the full form of the result.
Click for copyable input
The object f' behaves essentially like any other function in Mathematica. You can evaluate the function with any argument, and you can use standard Mathematica /. operations to change the argument. (This would not be possible if explicit dummy variables had been introduced in the course of the differentiation.)
This is the Mathematica representation of the derivative of a function f, evaluated at the origin.
Click for copyable input
The result of this derivative involves f' evaluated with the argument x^2.
Click for copyable input
You can evaluate the result at the point x=2 by using the standard Mathematica replacement operation.
Click for copyable input
There is some slight subtlety when you need to deduce the value of f' based on definitions for objects like f[x_].
Here is a definition for a function h.
Click for copyable input
When you take the derivative of h[x], Mathematica first evaluates h[x], then differentiates the result.
Click for copyable input
You can get the same result by applying the function h' to the argument x.
Click for copyable input
Here is the function h' on its own.
Click for copyable input
The function f' is completely determined by the form of the function f. Definitions for objects like f[x_] do not immediately apply however to expressions like f'[x]. The problem is that f'[x] has the full form Derivative[1][f][x], which nowhere contains anything that explicitly matches the pattern f[x_]. In addition, for many purposes it is convenient to have a representation of the function f' itself, without necessarily applying it to any arguments.
What Mathematica does is to try and find the explicit form of a pure function which represents the object f'. When Mathematica gets an expression like Derivative[1][f], it effectively converts it to the explicit form D[f[#], #]& and then tries to evaluate the derivative. In the explicit form, Mathematica can immediately use values that have been defined for objects like f[x_]. If Mathematica succeeds in doing the derivative, it returns the explicit pure-function result. If it does not succeed, it leaves the derivative in the original f' form.
This gives the derivative of Tan in pure-function form.
Click for copyable input
Here is the result of applying the pure function to the specific argument y.
Click for copyable input