D[i](f)(x, y, ...)
expression which can be applied as a function
positive integer or expression or sequence of such
x, y, ...
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 D⁡f⁡x represents the derivative of f(x) with respect to x. That is, D⁡f⁡x=ⅆⅆxf⁡x. 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,
Note: It is assumed that partial derivatives commute so that Di,j⁡g=Dj,i⁡g. In the univariate case, D1⁡f⁡x automatically simplifies to D⁡f⁡x. The zeroth order derivative is represented by D(g)(x,y) = diff⁡g⁡x,y, = g⁡x,y.
The D command can represent derivatives evaluated at a point. For example, the derivative of f⁡x evaluated at x=0 is represented by
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.
The D command is appropriate to represent partial derivatives at fixed values of certain functions. For example, the partial derivative of F⁡t,v⁡t with respect to t at fixed v⁡t is represented by
A diff representation for this derivative also requires the composition with eval
In the same manner, D can be used to represent the derivative of F⁡t,v⁡t "with respect to v⁡t", a function.
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, D⁡f represents the mapping
D(f) = (q -> eval(diff(f(t),t), t=q));
so that when D⁡f is applied to some variable, say x, or some expression, you have
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 x→x2, 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 f@g, not f⁡g. 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 k-th variable and apply it to fewer than k variables. For instance, D2⁡f⁡x yields an error.
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:
f ≔ x,y→ⅇx⁢y
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.
H ≔ p,x→p22⁢m+1⁢k⁢x22
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).
eq1 ≔ ⅆⅆt⁢x⁡t=D1⁡H⁡p⁡t,x⁡t
The second equation involves the partial derivative of H with respect to x(t).
eq2 ≔ ⅆⅆt⁢p⁡t=−D2⁡H⁡p⁡t,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.
Download Help Document