Physics[diff] - differentiate with respect to commutative and anticommutative variables
Calling Sequence
diff(expression, x, θ, ... )
Parameters
expression
-
any mathematical expression or relation between expressions
x, θ, ...
the derivation variables, commutative or anticommutative
Description
The diff command of the Physics package is a differentiation command that works with commutative (C) and anticommutative (AC) differentiation variables; that is, it takes into account the possible anticommutative character of the differentiation variables x,θ,.... Differentiation with respect to noncommutative (NC) variables is not implemented. Note that higher order derivatives with respect to AC variables do not commute, so their evaluation by the standard diff command (not the diff that loads when you load Physics) would lead to an incorrect result. For the conventions adopted to represent NC and AC objects, see the Physics package conventions.
The %diff command is the inert form of diff; that is, it represents the same mathematical operation while displaying the operation unevaluated. To evaluate the operation, use the value command.
All of the differentiating knowledge of the top level diff command is taken into account when evaluating derivatives with diff, and all differentiation rules defined by the user as `diff/...` routines are also automatically taken into account.
The syntax for the input of the Physics diff is equal to that of the standard diff and they both have the same display. Higher order derivatives with respect to commutative and anticommutative variables are displayed in separate groups. For example, after setting θ to be the prefix identifying anticommutative variables using Setup(anticommutativeprefix = theta),
∂4∂x∂y∂θ1∂θ2f⁡θ1,θ2,x,y
As with the standard diff command, if the result of a requested derivative cannot be expressed in terms of diff, then the D operator is used to express it. The equivalence between derivatives written in terms of diff and D is as follows:
∂2∂θ1∂θ2f⁡θ1,θ2=D1,2⁡f⁡θ1,θ2
where the derivative above should be interpreted as: first differentiate with respect to θ1, then with respect to θ2 (or the opposite times −1); and the right hand side is not interpreted as a commutative higher order derivative.
To convert between formats, use the convert command with diff, Diff, or D as the second argument. Although an equivalence between diff and D always exists, note that there is no equivalence between the Physics and top level versions of diff when there are anticommutative objects in the derivand.
Examples
with⁡Physics:
Setup⁡mathematicalnotation=true
mathematicalnotation=true
First set the symbols Q and θ as prefixes identifying anticommutative variables (see Setup for details).
Setup⁡anticommutativeprefix=Q,θ
anticommutativeprefix=Q,θ
So the following is an anticommutative function of two anticommutative variables.
AC≔Q1⁡θ1,θ2:
The second derivative with respect to the same anticommutative variable is equal to zero.
diff⁡AC,θ1,θ1
0
All second order mixed derivatives anticommute.
d12≔diff⁡AC,θ1,θ2
d12≔∂2∂θ1∂θ2Q1⁡θ1,θ2
d21≔diff⁡AC,θ2,θ1
d21≔−∂2∂θ1∂θ2Q1⁡θ1,θ2
Convert to the D format.
convert⁡d12,D
D1,2⁡Q1⁡θ1,θ2
Derivatives of composite anticommutative functions with respect to anticommutative variables:
Q2⁡θ1,θ2,Q1⁡θ1,θ2
diff⁡,θ1
D1⁡Q2⁡θ1,θ2,Q1⁡θ1,θ2+∂∂θ1Q1⁡θ1,θ2⁢D3⁡Q2⁡θ1,θ2,Q1⁡θ1,θ2
Derivatives of anticommutative products with respect to an anticommutative variable:
pr≔Q1⁡θ1,θ2⁢Q2⁡θ1,θ2,Q1⁡θ1,θ2
diff⁡pr,θ1
∂∂θ1Q1⁡θ1,θ2⁢Q2⁡θ1,θ2,Q1⁡θ1,θ2−D1⁡Q2⁡θ1,θ2,Q1⁡θ1,θ2+∂∂θ1Q1⁡θ1,θ2⁢D3⁡Q2⁡θ1,θ2,Q1⁡θ1,θ2⁢Q1⁡θ1,θ2
The mixed second order derivatives anticommute. These operations sometimes require normalizing and expanding the noncommutative products; for that purpose, use the expand command (if the intention is to expand only noncommutative products, use Physics/Expand).
diff⁡pr,θ1,θ2+diff⁡pr,θ2,θ1
−D1,2⁡Q2⁡θ1,θ2,Q1⁡θ1,θ2+∂∂θ2Q1⁡θ1,θ2⁢D1,3⁡Q2⁡θ1,θ2,Q1⁡θ1,θ2+D3⁡Q2⁡θ1,θ2,Q1⁡θ1,θ2⁢∂2∂θ1∂θ2Q1⁡θ1,θ2−∂∂θ1Q1⁡θ1,θ2⁢D2,3⁡Q2⁡θ1,θ2,Q1⁡θ1,θ2⁢Q1⁡θ1,θ2−−D1,2⁡Q2⁡θ1,θ2,Q1⁡θ1,θ2+∂∂θ1Q1⁡θ1,θ2⁢D2,3⁡Q2⁡θ1,θ2,Q1⁡θ1,θ2−D3⁡Q2⁡θ1,θ2,Q1⁡θ1,θ2⁢∂2∂θ1∂θ2Q1⁡θ1,θ2−∂∂θ2Q1⁡θ1,θ2⁢D1,3⁡Q2⁡θ1,θ2,Q1⁡θ1,θ2⁢Q1⁡θ1,θ2
expand⁡
You can use C and AC variables together. If the output contains derivatives with respect to both C and AC variables, then they are displayed in separate groups.
diff⁡f⁡θ1,θ2,x,y,θ1,θ2,`$`⁡x,3,`$`⁡y,2
∂7∂x3∂y2∂θ1∂θ2f⁡θ1,θ2,x,y
When the derivand contains both commutative and anticommutative variables and functions, using the top level diff command may result in incorrect calculations, even when the differentiation variable is commutative.
See Also
D, diff, diff and D notations and conversions, Expand, Physics, Physics conventions, Physics examples, Physics Updates, Tensors - a complete guide, Mini-Course Computer Algebra for Physicists, Physics,diff, Physics[*], Setup
References
Cheb-Terrab, E.S. "Symbolic Computing with Anti-commutative and Non-commutative Variables." MapleTech, Vol. 5, No. 1. (1998): 16-22.
Download Help Document