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 at a fixed ) 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.

•

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


 diff, when all of the mathematical objects involved in the derivand are commutative and the differentiation variable is of type name.


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 (for details, see convert,diff).

•

Special rules for the evaluation of partial derivatives of userdefined 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 Phyiscs[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 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 .



Examples


Load the Physics diff and Define commands to define objects with tensorial properties.
>


>


 (1) 
diff can differentiate with respect to functions.
>


 (2) 
Different formats for derivatives, such as diff and D, are recognized as mathematically equal.
>


 (3) 
>


 (4) 
>


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


 (6) 
>


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


 (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 at fixed , then in general, and finally,.
>


 (8) 
>


 (9) 
>


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


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


 (12) 
>


 (13) 
>


 (14) 
Consider now an indexed object for which the sum rule for repeated indices should be applied when computing derivatives: these objects are first defined as such by using the Define command.
First, tell the system that is a spacetime tensor. Then the derivative of is if , and the sum of over when .
>


 (15) 
>


 (16) 
If the indices are repeated, then the sum rule for them is automatically applied.
>


 (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 is not a tensor:
>


 (18) 
and so the derivative of with respect to is just zero.
>


 (19) 
If you now define it as a tensor, the same derivative is returned.
>


 (20) 
>


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


>




References



ChebTerrab, E.S. "Maple procedures for partial and functional derivatives." Computer Physics Communications, Vol. 79. (1994): 409424.


