evaluate total and partial derivatives, with respect to commutative and noncommutative variables, functions, tensors, or tensor functions, using the sum rule for repeated indices - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Physics : Physics/diff

Physics[diff] - evaluate total and partial derivatives, with respect to commutative and noncommutative variables, functions, tensors, or tensor functions, using the sum rule for repeated indices

Calling Sequence

diff(expression, x, t, ... )

diff(expression, x, t, ..., {f1(x, ...), f2(t, ...), ....})

Parameters

expression

-

any mathematical expression or relation between expressions

x, t, ...

-

the derivation variables; (tensorial or not) names or functions, commutative or anticommutative

{f(x, ...), ...}

-

(optional) to compute the derivative with respect to x at fixed f(x, ...), and in this way compute true partial derivatives

Description

• 

The diff command computes total or partial derivatives (with respect to t at a fixed ft) of algebraic expressions with respect to commutative or anticommutative variables or functions, commonly used in physics and in formulations based on variational principles. diff accepts an indexed tensor function as its differentiation variable, in which case its symmetry properties and the sum rule for repeated indices are taken into account when computing the derivative. To define an indexed object as a tensor function, see Define.

• 

Diff and %diff are the inert forms of diff; that is, they represent the same mathematical operation while displaying the operation unevaluated. To evaluate the operation, use the value command.

• 

For details regarding differentiation with respect to anticommutative objects, see diff, anticommutative; the rest of this help page discusses the case of differentiation with respect to commutative objects.

• 

In order to evaluate "partial derivatives," for instance, the partial derivative of Lt,qt with respect to t, at a fixed point qt, an indication of which functions depending on the differentiation variable must be fixed is required. This indication is always given to diff as the last argument, and must be in a set (enclosed by { }). The functions of t indicated inside the braces, as well as their derivatives, are fixed (considered as not depending on t) during the calculation of the partial derivative.

• 

If the algebraic expression (derivand) is given with the functional dependence indicated but in implicit form (for example, fx,y,z with unknown form for f), then the result returned by diff is expressed by using:

  

- the standard diff command (not the Physics diff), when all of the mathematical objects involved in the derivand are commutative and the differentiation variable is of type name.

  

- the Physics diff command, when the derivand involves anticommutative objects or the differentiation variable is of type function (the display of the Physics diff is the same as that of the standard diff).

  

- D, otherwise.

  

When the output is returned in terms of D (that is, it involves D derivatives of unknown functions), this result can be transformed into one free of D derivatives by using the convert(expr, diff) command after defining the explicit form of the functions entering the derivand through a direct assignment, not requiring the use of mappings (see the Examples section).

• 

Special rules for the evaluation of partial derivatives of user-defined functions can be stated by indicating the differentiation rule to the standard Maple diff command as usual.

• 

It makes no difference whether you use the :-diff, :-Diff, or D command in the arguments passed to the Physics[diff] command; it takes into account the mathematical equivalence between them. For example, diff(L, diff(q(t),t)), diff(L, Diff(q(t),t)), and diff(L, D(q)(t)) all return the same result.

• 

As a rule, diff always tries not to change the format (diff, Diff, or D) of derivatives appearing in the input. Nevertheless, when more than one of these formats is present and representing the same mathematical object, the format used in the output will be that of the derivatives found in the "differentiation variable." If the latter does not involve derivatives and the derivand uses more than one format to represent the same mathematical object, the result is returned using the D format for that object.

• 

When a mathematical formulation involving diff or D can be expressed in terms of the other differentiation operator or their inert versions, that conversion can be achieved by using the convert command, as in convert(expr, diff_command), where diff_command is diff or D.

Examples

withPhysics:

Setupmathematicalnotation=true

mathematicalnotation=true

(1)

diff can differentiate with respect to functions.

diffcosqt,qt

sinqt

(2)

Different formats for derivatives, such as diff and D, are recognized as mathematically equal.

diffⅆⅆtqt12,Dqt

12Dqt

(3)

ⅆⅆtqt12+Dqt3

q.t+Dqt3

(4)

diff,ⅆⅆtqt

12q.t+3q.t2

(5)

Regarding the choice of format (diff or D) in the output above, see the Description section of this page.

Set an alias for this generic functionality.

Q=t,qt,ⅆⅆtqt

Q=t,qt,q.t

(6)

alias:

The total derivative with respect to t of a function of Q is given by:

dL_dttLQ

dL_dtD1LQ+D2LQq.t+D3LQq..t

(7)

Now in typical frameworks, Q is a function of three variables (for example, time, position, and velocity), and you want to compute the partial derivatives of Q with respect to each of the three variables. First, compute the partial derivative with respect to t at fixed qt, then qt in general, and finally,ⅆqⅆt.

pdL_dtdiffLQ,t,qt

pdL_dtD1LQ

(8)

pdL_dqdiffLQ,qt

pdL_dqD2LQ

(9)

pdL_ddqdiffLQ,ⅆⅆtqt

pdL_ddqD3LQ

(10)

Now assign a value to L(Q), without using mappings.

LQ1ⅆⅆtqt221kqt22coswt

LQq.t22kqt22coswt

(11)

Each of the three partial derivatives computed above (when L(Q) was still unassigned) can be transformed into concrete results by using the convert, diff command.

convertpdL_dt,diff

wsinwt

(12)

convertpdL_dq,diff

kqt

(13)

convertpdL_ddq,diff

q.t

(14)

Consider now an indexed object representing a spacetime tensor, so one for which the sum rule for repeated indices should be applied when computing derivatives. Spacetime tensors are defined as such by using the Define command

DefineA

Defined objects with tensor properties

A,γμ,σμ,μ,gμ,ν,εα,β,μ,ν

(15)

So now the derivative of Aμ with respect to Aν is 0 if μν, and g_μ,μ summed over μ, that is the dimension of spacetime when ν=μ.

AνAμ

g_μνμν

(16)

If the indices are repeated, then the sum rule for them is automatically applied.

ⅆⅆAμAμ

4

(17)

Note that the behavior above does not happen when the differentiation variable was not defined as an object with tensorial properties (that is, having tensor properties with respect to its indices) by the Define command. For example, so far B is not a tensor:

DefineB,query

Not defined as a tensor within the framework of the Physics package

(18)

and so the derivative of Bμ with respect to Bν is just zero.

BνBμ

0

(19)

If you now define it as a tensor, a result as with A is returned.

DefineB

Defined objects with tensor properties

B,Aν,γμ,σμ,μ,gμ,ν,εα,β,μ,ν

(20)

BνBμ

g_μνμν

(21)

Note also that the information on B has been updated in the background: now the system knows that B is a tensor with only one index, so an error interruption will occur if it is used with more indices.

Bν,βBμ,α

Error, (in Physics:-Define) found B with 2 spacetime indices, [nu, beta], contradicting a previous definition with 1 such indices. You can use Define with the 'clear' or 'redo' options to discard the previous definition.

See Also

Define, diff and D notations and conversions, Physics, Physics conventions, Physics examples, Physics Updates, Tensors - a complete guide, Mini-Course Computer Algebra for Physicists, Physics,diff,anticommutative, Setup

References

  

Cheb-Terrab, E.S. "Maple procedures for partial and functional derivatives." Computer Physics Communications, Vol. 79. (1994): 409-424.