D
Differential operator
Calling Sequence
Parameters
Description
Examples
D(f)
D[i](f)
D[i](f)(x, y, ...)
f
-
expression which can be applied as a function
i
positive integer or expression or sequence of such
x, y, ...
application point
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,
D[1,1,2](g)(x,y);
D1,1,2⁡g⁡x,y
convert((1), diff);
∂3∂x2∂yg⁡x,y
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
D(f)(0);
D⁡f⁡0
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.
convert((3), diff);
ⅆⅆt1f⁡t1t1=0|ⅆⅆt1f⁡t1t1=0
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
D[1](F)(t,v(t));
D1⁡F⁡t,v⁡t
A diff representation for this derivative also requires the composition with eval
convert((5), diff);
∂∂tF⁡t,t1t1=v⁡t|∂∂tF⁡t,t1t1=v⁡t
In the same manner, D can be used to represent the derivative of F⁡t,v⁡t "with respect to v⁡t", a function.
D[2](F)(t,v(t));
D2⁡F⁡t,v⁡t
convert((7), diff);
∂∂t1F⁡t,t1t1=v⁡t|∂∂t1F⁡t,t1t1=v⁡t
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));
D⁡f=q↦ⅆⅆtf⁡tt=q|ⅆⅆtf⁡tt=q
so that when D⁡f is applied to some variable, say x, or some expression, you have
(9)(x);
D⁡f⁡x=ⅆⅆxf⁡x
(9)(x+1);
D⁡f⁡x+1=D⁡f⁡x+1
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
D⁡f+g=D⁡f+D⁡g
D⁡f⁢g=D⁡f⁢g+D⁡g⁢f
D⁡f@g=D⁡f@g⁢D⁡g
D⁡fc=c⁢D⁡f⁢fc−1,c::constant
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.
D⁡ln⁡x=diff⁡ln⁡x,x
1x=1x
When differentiating arbitrary functions, D and diff return expressions involving themselves. To switch between the two representations use convert/D and convert/diff.
D⁡y⁡x
convert⁡,diff
ⅆⅆxy⁡x
convert⁡,D
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.
D⁡sin
cos
nth derivative mapping
Dn⁡sin
z↦sin⁡z+n⋅π2
D`$`⁡1,n⁡sin
Derivative mapping for unknown f.
D⁡f
D⁡D⁡f
D2⁡f
Partial derivative mapping of order n+m
D`$`⁡1,n,`$`⁡2,m⁡g
D1,...,1⏟n times,2,...,2⏟m times⁡g
Partial derivatives are assumed to commute.
Di,j⁡g−Dj,i⁡g
0
Derivative mapping of a derivative mapping.
D1⁡D2,1⁡g
D1,1,2⁡g
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.
D⁡arctan
z↦1z2+1
To represent the partial derivative with respect to the first argument of the "arctan of two variables" mapping use the indexed notation:
D1⁡arctan
y,x↦1x⋅1+y2x2
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:
D2⁡Ζ
This ambiguity gets resolved when evaluating the previous result on two or three arguments, resulting in mathematically different output.
⁡x,y≠⁡x,y,z
ζx+1⁡y≠ζx+1⁡y,z
Differentiating more elaborated algebraic expressions representing mathematical mappings:
D⁡exp+cos2+π+tan
−2⁢sin⁢cos+tan2+exp+1
D⁡2⁢f⁢sin
2⁢D⁡f⁢sin+2⁢f⁢cos
D⁡2⁢f⁢sinassumingf::constant
2⁢f⁢cos
Differentiating procedures:
f≔x,y↦exp⁡y⋅x
f≔x,y↦ⅇy⋅x
D1⁡f
x,y↦y⋅ⅇy⋅x
x,y↦x⋅ⅇy⋅x
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+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≔diff⁡x⁡t,t=D1⁡H⁡p⁡t,x⁡t
eq1≔ⅆⅆtx⁡t=p⁡tm
The second equation involves the partial derivative of H with respect to x(t).
eq2≔diff⁡p⁡t,t=−D2⁡H⁡p⁡t,x⁡t
eq2≔ⅆⅆtp⁡t=−k⁢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.)
simplify⁡eq2,eq1,p⁡t
ⅆ2ⅆt2x⁡t⁢m=−k⁢x⁡t
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.
diff⁡E⁡t=H⁡p⁡t,x⁡t,t
ⅆⅆtE⁡t=p⁡t⁢ⅆⅆtp⁡tm+k⁢x⁡t⁢ⅆⅆtx⁡t
Evaluating this result using Hamilton's equations, you find that E is a constant.
eval⁡,eq1,eq2
ⅆⅆtE⁡t=0
See Also
@
@@
assuming
diff
operator
operators[D]
taylor
unapply
Download Help Document