WOLFRAM LANGUAGE TUTORIAL

The Representation of Derivatives

Derivatives in the Wolfram System work essentially the same as in standard mathematics. The usual mathematical notation, however, often hides many details. To understand how derivatives are represented in the Wolfram System, you must look at these details.

The standard mathematical notation is really a shorthand for , where is a "dummy variable". Similarly, is a shorthand for . As suggested by the notation , the object can in fact be viewed as a "pure function", to be evaluated with a particular choice of its parameter . You can think of the operation of differentiation as acting on a function , to give a new function, usually called .

With functions of more than one argument, the simple notation based on primes breaks down. You cannot tell, for example, whether stands for or , and for almost any , these will have totally different values. Once again, however, is just a dummy variable, whose sole purpose is to show with respect to which "slot" is to be differentiated.

In the Wolfram System, as in some branches of mathematics, it is convenient to think about a kind of differentiation that acts on functions, rather than expressions. An operation is needed that takes the function , and gives the derivative function . Operations such as this that act on functions, rather than variables, are known in mathematics as operators.

The object in the Wolfram System is the result of applying the differentiation operator to the function . The full form of is in fact Derivative[1][f]. Derivative[1] is the Wolfram System 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, the Wolfram System avoids any need to introduce explicit "dummy variables".

This is the full form of the derivative of the function .
In[1]:=
Click for copyable input
Out[1]//FullForm=
Here an argument is supplied.
In[2]:=
Click for copyable input
Out[2]//FullForm=
This is the second derivative.
In[3]:=
Click for copyable input
Out[3]//FullForm=
This gives a derivative of the function with respect to its second "slot".
In[4]:=
Click for copyable input
Out[4]=
Here is the full form.
In[5]:=
Click for copyable input
Out[5]//FullForm=
Here is the second derivative with respect to the variable , which appears in the second slot of .
In[6]:=
Click for copyable input
Out[6]//FullForm=
This is a mixed derivative.
In[7]:=
Click for copyable input
Out[7]//FullForm=
Since Derivative only specifies how many times to differentiate with respect to each slot, the order of the derivatives is irrelevant.
In[8]:=
Click for copyable input
Out[8]//FullForm=
Here is a more complicated case, in which both arguments of depend on the differentiation variable.
In[9]:=
Click for copyable input
Out[9]=
This is the full form of the result.
In[10]:=
Click for copyable input
Out[10]//FullForm=

The object behaves essentially like any other function in the Wolfram System. You can evaluate the function with any argument, and you can use standard the Wolfram System 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 Wolfram System representation of the derivative of a function , evaluated at the origin.
In[11]:=
Click for copyable input
Out[11]//FullForm=
The result of this derivative involves evaluated with the argument .
In[12]:=
Click for copyable input
Out[12]=
You can evaluate the result at the point by using the standard Wolfram System replacement operation.
In[13]:=
Click for copyable input
Out[13]=

There is some slight subtlety when you need to deduce the value of based on definitions for objects like .

Here is a definition for a function .
In[14]:=
Click for copyable input
When you take the derivative of , the Wolfram System first evaluates , then differentiates the result.
In[15]:=
Click for copyable input
Out[15]=
You can get the same result by applying the function to the argument .
In[16]:=
Click for copyable input
Out[16]=
Here is the function on its own.
In[17]:=
Click for copyable input
Out[17]=

The function is completely determined by the form of the function . Definitions for objects like do not immediately apply, however, to expressions like . The problem is that has the full form Derivative[1][f][x], which nowhere contains anything that explicitly matches the pattern . In addition, for many purposes it is convenient to have a representation of the function itself, without necessarily applying it to any arguments.

What the Wolfram System does is to try and find the explicit form of a pure function which represents the object . When the Wolfram System 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, the Wolfram System can immediately use values that have been defined for objects like . If the Wolfram System succeeds in doing the derivative, it returns the explicit purefunction result. If it does not succeed, it leaves the derivative in the original form.

This gives the derivative of Tan in purefunction form.
In[18]:=
Click for copyable input
Out[18]=
Here is the result of applying the pure function to the specific argument .
In[19]:=
Click for copyable input
Out[19]=