generalized product that operates like a commutative, anticommutative, or noncommutative product depending on the parity of its operands - Maple Programming Help

Physics[*] - generalized product that operates like a commutative, anticommutative, or noncommutative product depending on the parity of its operands

Physics[^] - generalized exponentiation

 Calling Sequence a * b * c ... a ^ b ...

Parameters

 a, b, c, ... - arbitrary algebraic expressions that typically enter products

Description

 • When the Physics package is loaded, a more general product operator, represented by the same symbol *, is loaded. Unlike the default Maple * operator (herein called the commutative product operator), the * operator loaded with Physics does not assume commutativity of its operands and instead automatically operates like a commutative, anticommutative, or noncommutative product, depending on the corresponding commutation properties of its operands.
 • Similarly, a generalized exponentiation operator, ^, is loaded, that takes into account possible assumptions equal to 0, 1 and -1 on a and b, and handles among other things matrices, the Physics Bra and Ket commands transforming integer powers into products, the Physics Inverse command (equivalent to b = -1), and returns using the standard :-^ operator only when a and b are of type commutative, avoiding in this way what would otherwise be incorrect commutative products of noncommutative mathematical variables/expressions.
 • When computing with quantum-state vectors in Dirac notation, the Physics * operator also represents the tensor product of Bras and Kets, such as in $|A>* (a quantum operator) or $|A>*|B>$ (a Ket of the tensor product of spaces).
 • To expand Physics[*] products over sums, use expand or Physics[Expand]; to represent their inverses, use Physics/Inverse. Additionally, the rules for differentiating these products with respect to commutative or anticommutative differentiation variables, as well as the function application of a product construction, $\left(a*b\right)\left(x\right)\to a\left(x\right)*b\left(x\right)$, are all implemented, completing the computational representation of this generalized product operation.
 • To set the identifiers for noncommutative and anticommutative variables in the context of the Physics package, see Setup. Also, when using the Standard graphical user interface, you can set the mathematical display so that commutative, anticommutative, and noncommutative objects are displayed in different colors, which can also be customized. To set the display to mathematical notation, enter the command Setup(mathematicalnotation = true). See Setup for details.
 • In order to make zero recognition possible in the not commutative case, basic simplifications, unnesting, and sorting of arguments of these products are automatically performed. So the output of $a$*$b$ will be equal to the output of $b$*$a$ when a and/or b are commutative objects, and it will be equal to the output of $-b$*$a$ when a and b are anticommutative objects. If a and b are noncommutative, then for both $a$*$b$ and $b$*$a$, the respective outputs are just the products as entered. The form automatically returned is $*$ itself, built as follows:
 1 The sequence of operands of $*$ is split into two sequences: s1 and s2, containing the commutative and not commutative (anticommutative and noncommutative) operands, respectively.
 2 The elements of s1 are sorted by using machine ordering (table(symmetric)), resulting in sorted_s1.
 3 Each subsequence of anticommutative elements of s2 is sorted using machine ordering (table(antisymmetric)), resulting in sorted_s2.
 4 Both sorted_s1 and sorted_s2 are normalized by using normal.
 5 A result is built and returned as the normalized form of sorted_s1 times sorted_s2.
 • To simplify these products of noncommutative objects (such as quantum operators), taking into account that some of them may commute between themselves or satisfy commutation rules previously set, use the Physics/Simplify command.
 • In connection with applying a product to some arguments, as for instance in $\left(a*b\right)\left(x\right)\to \left(a\left(x\right)*b\left(x\right)\right)$, to have any of $a\left(x\right)$ or $b\left(x\right)$ returned just as $a$ or $b$, declare them first as parameters by using the Parameters command. To have only the quantum operators ($a$, $b$, or both) applied to $x$, use the . operator of the Physics package, as in$\left(a*b\right).x$.
 • After loading Physics, the original commutative product operator can still be invoked as the function :-$\mathrm{*}$, as in :-$ab$. However, note that it would be wrong to use :-$*\left(...\right)$ product constructions involving noncommutative or anticommutative operands.
 • Remark: to compute the scalar product between Bras, Kets, and quantum operators defined as such by using the Setup command or returned by the Annihilation and Creation commands, use the . operator in the Physics package, not the * generalized multiplication operator described in this page.

Examples

 > with(Physics):
 > Setup(mathematicalnotation = true);
 $\left[{\mathrm{mathematicalnotation}}{=}{\mathrm{true}}\right]$ (1)

First, set some identifiers to work with anticommutative and noncommutative variables.

 > Setup(anticommutativeprefix = {Q, theta}, noncommutativeprefix = Z);
 $\left[{\mathrm{anticommutativeprefix}}{=}\left\{{Q}{,}{\mathrm{\theta }}\right\}{,}{\mathrm{noncommutativeprefix}}{=}\left\{{Z}\right\}\right]$ (2)

So below, $a,b,c$, and $f\left(\mathrm{\theta }\right)$ are commutative, the latter contains the anticommutative object $\mathrm{\theta }$, $\mathrm{Q1}$ and $\mathrm{Q2}$ are of anticommutative type, and $\mathrm{Z1}$ is noncommutative. Use delay evaluation quotes to see the product before and after it is normalized.

 > ' a * f(theta) * b * Q1 * c * Q3 * Q2 ';
 ${a}{}{f}{}\left({\mathrm{\theta }}\right){}{b}{}{\mathrm{Q1}}{}{c}{}{\mathrm{Q3}}{}{\mathrm{Q2}}$ (3)
 > (3);
 ${-}{a}{}{b}{}{c}{}{f}{}\left({\mathrm{\theta }}\right){}{\mathrm{Q1}}{}{\mathrm{Q2}}{}{\mathrm{Q3}}$ (4)

Note that instead of using delay evaluation quotes as in the example above, you can also use the inert form of the product function, %*, to represent this product and then "perform the product" when you prefer using the value command: the differentiation and expansion rules for %* are the same as those for *.

 > %*(a, f(theta), b, Q1, c, Q3, Q2);
 ${\mathrm{%*}}{}\left({a}{,}{f}{}\left({\mathrm{θ}}\right){,}{b}{,}{\mathrm{Q1}}{,}{c}{,}{\mathrm{Q3}}{,}{\mathrm{Q2}}\right)$ (5)
 > value((5));
 ${-}{a}{}{b}{}{c}{}{f}{}\left({\mathrm{\theta }}\right){}{\mathrm{Q1}}{}{\mathrm{Q2}}{}{\mathrm{Q3}}$ (6)

The next example in a nested expression containing commutative, anticommutative, and noncommutative products and a sum. Due to the prefixes chosen, objects beginning with $Q$ and followed by an integer are anticommutative, and those beginning with $Z$ are noncommutative. In this example, the  symbol appears six times, nested in various ways (note the delay evaluation quotes):

 > ' *(a, *(h(theta), b, *(Q1,Z1,Q2) * Q4) * *(Z3 * Q5 , c * (Q3-Q6)), f(theta)) ';
 ${a}{}{h}{}\left({\mathrm{\theta }}\right){}{b}{}{\mathrm{Q1}}{}{\mathrm{Z1}}{}{\mathrm{Q2}}{}{\mathrm{Q4}}{}{\mathrm{Z3}}{}{\mathrm{Q5}}{}{c}{}\left({\mathrm{Q3}}{-}{\mathrm{Q6}}\right){}{f}{}\left({\mathrm{\theta }}\right)$ (7)

A canonical representation for this product with the commutative, anticommutative, and noncommutative operands, sorted according to the itemization in the Description:

 > (7);
 ${a}{}{b}{}{c}{}{f}{}\left({\mathrm{\theta }}\right){}{h}{}\left({\mathrm{\theta }}\right){}{\mathrm{Q1}}{}{\mathrm{Q2}}{}{\mathrm{Q4}}{}{\mathrm{Q5}}{}\left({\mathrm{Q3}}{-}{\mathrm{Q6}}\right){}{\mathrm{Z1}}{}{\mathrm{Z3}}$ (8)

The Commutator between two noncommutative objects, $\mathrm{Z1}$ and $\mathrm{Z2}$:

 > zz := Commutator(Z1, Z2);
 ${\mathrm{Commutator}}{}\left({\mathrm{Z1}}{,}{\mathrm{Z2}}\right)$ (9)
 > expand(zz);
 ${\mathrm{Z1}}{}{\mathrm{Z2}}{-}{\mathrm{Z2}}{}{\mathrm{Z1}}$ (10)

The above is the difference between two * products. Applying this difference to an argument distributes the application across the operands of the * products.

 > (10)(x);
 ${\mathrm{Z1}}{}\left({x}\right){}{\mathrm{Z2}}{}\left({x}\right){-}{\mathrm{Z2}}{}\left({x}\right){}{\mathrm{Z1}}{}\left({x}\right)$ (11)
 > zz(x);
 ${\mathrm{Commutator}}{}\left({\mathrm{Z1}}{}\left({x}\right){,}{\mathrm{Z2}}{}\left({x}\right)\right)$ (12)

To have, for example, $\mathrm{Z1}$ not applied to $x$ when applying the product $\mathrm{zz}$ as above, use the Parameters command.

 > Parameters(Z1);
 $\left\{{\mathrm{Z1}}\right\}$ (13)
 > zz(x);
 ${\mathrm{Commutator}}{}\left({\mathrm{Z1}}{,}{\mathrm{Z2}}{}\left({x}\right)\right)$ (14)
 > expand(zz);
 ${\mathrm{Z1}}{}{\mathrm{Z2}}{-}{\mathrm{Z2}}{}{\mathrm{Z1}}$ (15)
 > (15)(x);
 ${\mathrm{Z1}}{}{\mathrm{Z2}}{}\left({x}\right){-}{\mathrm{Z2}}{}\left({x}\right){}{\mathrm{Z1}}$ (16)

Set the Commutator between two quantum operators $A$ and $B$ to zero, so that $A$ and $B$ are noncommutative objects that commute between themselves.

 > Setup(mop = {A, B}, %Commutator(A, B) = 0);
 $\mathrm{* Partial match of \text{'}}{}\mathrm{mop}{}\mathrm{\text{'} against keyword \text{'}}{}\mathrm{quantumoperators}{}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{algebrarules}}{=}\left\{{\mathrm{%Commutator}}{}\left({A}{,}{B}\right){=}{0}\right\}{,}{\mathrm{quantumoperators}}{=}\left\{{A}{,}{B}\right\}\right]$ (17)

Their product is not automatically normalized when taking the algebra rules set.

A canonical form would be $AB$.

 > A*B;
 ${A}{}{B}$ (18)
 > B*A;
 ${B}{}{A}$ (19)

You can normalize these products by using Simplify directly, which applies various simplifications. Alternatively, in order to avoid further simplifications, use the $\mathrm{algebrarules}$ restricting option, which applies only the algebra rules set.

 > Simplify((19), algebrarules);
 ${B}{}{A}$ (20)
 >