D  Differential operator

Calling Sequence


D(f)
D[i](f)
D[i](f)(x, y, ...)


Parameters


f



expression which can be applied as a function

i



positive integer or expression or sequence of such

x, y, ...



application point





Description


•

The D command serves different purposes. It is primarily a differentiation command, like diff (see also comparison), but it is more general than diff in two aspects: it can represent derivatives evaluated at a point and can differentiate procedures.

•

As a differentiation command, given f, the name of an unknown function of one argument, the call represents the derivative of f(x) with respect to x. That is, . To switch between these two representations use convert/D and convert/diff.

•

In the case of partial derivatives, D identifies the differentiation variables by their numerical position. D[i](f) computes the partial derivative of f with respect to its ith argument. For example,

 (1) 
 (2) 
•

The D command can represent derivatives evaluated at a point. For example, the derivative of evaluated at is represented by

 (3) 

The evaluation point can be any algebraic expression, not necessarily a constant. Derivatives evaluated at a point can also be expressed using a composition of eval and diff.

 (4) 
•

The D command is appropriate to represent partial derivatives at fixed values of certain functions. For example, the partial derivative of with respect to t at fixed is represented by

 (5) 

A diff representation for this derivative also requires the composition with eval

 (6) 
•

In the same manner, D can be used to represent the derivative of "with respect to ", a function.

 (7) 
 (8) 
•

The D command can differentiate procedures, typically used to represent mathematical mappings, as well as arbitrary algebraic expressions understood as mappings, in the sense that in Maple algebraic expressions are appliable. This functionality is unique to D; it cannot be emulated using the diff command.

•

The derivative of a procedure or mapping of n variables is another mapping of the same number of variables. For example, D(sin) returns cos. In the general case, represents the mapping

>

D(f) = (q > eval(diff(f(t),t), t=q));

 (9) 

so that when is applied to some variable, say x, or some expression, you have

 (10) 
 (11) 
•

When differentiating an arbitrary mapping represented by an algebraic expression, say F, the expression can contain constants, known function names such as sin, exp (not the applied function exp(x)), unknown function names such as f, g, arrow operators such as , and the arithmetic and functional operators. On such expressions, D recursively applies the rules


Note: The composition of functions, say f and g, should be entered using the notation , not . To specify that a symbol, say g, is a constant and not a function name, use the assuming command, like in D(f*g) assuming g::constant; see also assume.

•

When F is a name to which a procedure of n arguments is assigned, D can compute the mappings representing the partial derivatives of F (restrictions apply). The procedure F can have assignments to local variables, if statements, for loops, while loops, etc.

•

It is an error to specify a call to the derivative of a function with respect to the kth variable and apply it to fewer than k variables. For instance, yields an error.



Examples


The D and diff commands can both compute derivatives.
>


 (12) 
When differentiating arbitrary functions, D and diff return expressions involving themselves. To switch between the two representations use convert/D and convert/diff.
>


 (13) 
>


 (14) 
>


 (15) 
When differentiating a symbol representing a mathematical mapping (the simplest algebraic expression), the derivative mapping is computed whenever it is known, as in the case of all the mathematical functions of the Maple language for which a differentiation rule is known; otherwise, the input is echoed unevaluated.
>


 (16) 
nth derivative mapping
>


 (17) 
>


 (18) 
Derivative mapping for unknown f.
>


 (19) 
>


 (20) 
>


 (21) 
Partial derivative mapping of order n+m
>


 (22) 
Partial derivatives are assumed to commute.
>


 (23) 
Derivative mapping of a derivative mapping.
>


 (24) 
For mathematical functions accepting different number of arguments, the following conventions regarding the input are adopted. This is the derivative mapping of the "arctan of one variable" mapping.
>


 (25) 
To represent the partial derivative with respect to the first argument of the "arctan of two variables" mapping use the indexed notation:
>


 (26) 
The Zeta function accepts one, two, or three arguments. The partial derivative of the "Zeta mapping" with respect to its second argument has an ambiguous meaning: the argument to D could be the Zeta mapping of two or of three variables. The derivative is thus returned uncomputed:
>


 (27) 
This ambiguity gets resolved when evaluating the previous result on two or three arguments, resulting in mathematically different output.
>


 (28) 
Differentiating more elaborated algebraic expressions representing mathematical mappings:
>


 (29) 
>


 (30) 
>


 (31) 
Differentiating procedures:
>


 (32) 
>


 (33) 
>


 (34) 
>


 (35) 
An example illustrating the use of D and diff to respectively compute partial and total derivatives. This is a mapping representing the Hamiltonian function H (the energy) of a harmonic oscillator, expressed as a function of the momentum p(t) and the position x(t); t represents the time.
>


 (36) 
The equations of motion are Hamilton's equations; together they form Newton's second law. The first Hamilton's equation involves the partial derivative of H with respect to p(t).
>


 (37) 
The second equation involves the partial derivative of H with respect to x(t).
>


 (38) 
Newton's second law applied to the harmonic oscillator is obtained combining these equations into one. (See simplify with respect to side relations.)
>


 (39) 
The energy of a harmonic oscillator is constant. To see that, take the total derivative of the Hamiltonian (the energy E) with respect to the time t.
>


 (40) 
Evaluating this result using Hamilton's equations, you find that E is a constant.
>


 (41) 

