The D and diff commands can both compute derivatives.
When differentiating arbitrary functions, D and diff return expressions involving themselves. To switch between the two representations use convert/D and convert/diff.
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.
nth derivative mapping
Derivative mapping for unknown f.
Partial derivative mapping of order n+m
Partial derivatives are assumed to commute.
Derivative mapping of a derivative mapping.
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.
To represent the partial derivative with respect to the first argument of the "arctan of two variables" mapping use the indexed notation:
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:
This ambiguity gets resolved when evaluating the previous result on two or three arguments, resulting in mathematically different output.
Differentiating more elaborated algebraic expressions representing mathematical mappings:
Differentiating procedures:
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.
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).
The second equation involves the partial derivative of H with respect to x(t).
Newton's second law applied to the harmonic oscillator is obtained combining these equations into one. (See simplify with respect to side relations.)
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.
Evaluating this result using Hamilton's equations, you find that E is a constant.