D - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


D

Differential operator

 

Calling Sequence

Parameters

Description

Examples

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 Dfx represents the derivative of f(x) with respect to x. That is, Dfx=ⅆⅆxfx. 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,2gx,y

(1)

convert((1), diff);

3x2ygx,y

(2)
  

Note: It is assumed that partial derivatives commute so that Di,jg=Dj,ig. In the univariate case, D1fx automatically simplifies to Dfx. The zeroth order derivative is represented by D[](g)(x,y) = diffgx,y, = gx,y.

• 

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

D(f)(0);

Df0

(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.

convert((3), diff);

ⅆⅆt1ft1t1=0|ⅆⅆt1ft1t1=0

(4)
• 

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

D[1](F)(t,v(t));

D1Ft,vt

(5)
  

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

convert((5), diff);

tFt,t1t1=vt|tFt,t1t1=vt

(6)
• 

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

D[2](F)(t,v(t));

D2Ft,vt

(7)

convert((7), diff);

t1Ft,t1t1=vt|t1Ft,t1t1=vt

(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, Df represents the mapping

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

Df=qⅆⅆtftt=q|ⅆⅆtftt=q

(9)
  

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

(9)(x);

Dfx=ⅆⅆxfx

(10)

(9)(x+1);

Dfx+1=Dfx+1

(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 xx2, and the arithmetic and functional operators. On such expressions, D recursively applies the rules

Df+g=Df+Dg

Dfg=Dfg+Dgf

Df@g=Df@gDg

Dfc=cDffc1,c::constant

  

Note: The composition of functions, say f and g, should be entered using the notation f@g, not fg.  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, D2fx yields an error.

Examples

The D and diff commands can both compute derivatives.

Dlnx=difflnx,x

1x=1x

(12)

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

Dyx

Dyx

(13)

convert,diff

ⅆⅆxyx

(14)

convert,D

Dyx

(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.

Dsin

cos

(16)

nth derivative mapping

Dnsin

zsinz+nπ2

(17)

D`$`1,nsin

zsinz+nπ2

(18)

Derivative mapping for unknown f.

Df

Df

(19)

DDf

D2f

(20)

D2f

D2f

(21)

Partial derivative mapping of order n+m

D`$`1,n,`$`2,mg

D1,...,1n times,2,...,2m timesg

(22)

Partial derivatives are assumed to commute.

Di,jgDj,ig

0

(23)

Derivative mapping of a derivative mapping.

D1D2,1g

D1,1,2g

(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.

Darctan

z1z2+1

(25)

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

D1arctan

y,x1x1+y2x2

(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:

D2Ζ

D2Ζ

(27)

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

x,yx,y,z

ζx+1yζx+1y,z

(28)

Differentiating more elaborated algebraic expressions representing mathematical mappings:

Dexp+cos2+π+tan

2sincos+tan2+exp+1

(29)

D2fsin

2Dfsin+2fcos

(30)

D2fsinassumingf::constant

2fcos

(31)

Differentiating procedures:

fx,yexpyx

fx,yⅇyx

(32)

Df

f

(33)

D1f

x,yyⅇyx

(34)

D2f

x,yxⅇyx

(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.

Hp,xp22m+kx22

Hp,xp22m+kx22

(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).

eq1diffxt,t=D1Hpt,xt

eq1ⅆⅆtxt=ptm

(37)

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

eq2diffpt,t=D2Hpt,xt

eq2ⅆⅆtpt=kxt

(38)

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

simplifyeq2,eq1,pt

ⅆ2ⅆt2xtm=kxt

(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.

diffEt=Hpt,xt,t

ⅆⅆtEt=ptⅆⅆtptm+kxtⅆⅆtxt

(40)

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

eval,eq1,eq2

ⅆⅆtEt=0

(41)

See Also

@

@@

assuming

diff

operator

operators[D]

taylor

unapply