. - Maple Help

Physics[.] - scalar product between Bras, Kets, and quantum operators, and simplification of contracted indices in spacetime tensors

 Calling Sequence Bra(A, ...) . Ket(B, ...) Q . Ket(B, ...) Bra(A, ...) . Q A[mu, ...] . B[mu,...]

Parameters

 Ket(B, ...) - a Ket vector; represents the quantum state of a system in Dirac's notation Bra(A, ...) - a Bra vector; represents the quantum state of a system in Dirac's notation Q - a quantum operator, set to be so by the Setup command, assumed to be a linear functional operator regarding Bras and Kets A, B - both A and B a spacetime tensors defined as such with the Define command of the Physics package; to perform a simplification of the contracted (repeated) indices.

Description

 • The Physics[.] command is a computational representation for the scalar product operation between Bras, Kets, and quantum operators set to be so by the Setup command, or returned by the Annihilation, Creation, and Projector commands.
 • Independent of that, Physics[.] is also a handy shortcut for performing simplification of contracted indices in tensor products; for instance if A[mu] is Defined as a tensor, g_[mu, nu] . A[nu] returns A[mu], equivalent to performing Simplify(g_[mu, nu] * A[nu], indices) (see Simplify and the end of the Examples section).
 • When taking the scalar product between Bras, Kets, or quantum operator, generally speaking, two situations can happen: 1) there is not enough information to perform the operation (for example, $⟨A|B⟩$ for two generic unknown Kets), in which case it is returned unevaluated; or 2) the information available permits performing the operation.
 • In the following situations, the scalar product is returned unevaluated:
 – The scalar product between a Bra and a Ket, with or without a quantum operator in between, is returned in terms of the Bracket function.
 – A product involving only a quantum operator and either a Ket or a Bra is returned as entered, in terms of Physics[.].
 – A product with two or more Kets only (or two or more Bras only) is returned in terms of Physics[*], and represents a state vector of the tensor product of the respective spaces.
 • In the following situations, the scalar product can be performed:
 – The Kets belong to the same basis: if the basis, represented by the Ket's first argument, is discrete, then the result involves KroneckerDelta; if the basis is continuous, then it involves the Dirac function. To indicate that a basis is continuous, use the Setup command. Remark: when the discrete or continuous character of the basis has not been set, it is assumed that the basis is discrete.
 – The label A, entered as the first argument of the Ket, has also been set as a quantum operator by the Setup command; for example, a Ket $\mathrm{Ket}\left(A,n,m\right)$ is an eigenvector of ${A}_{1}$ with eigenvalue $n$ and of ${A}_{2}$ with eigenvalue $m$.
 – The quantum operator is an annihilation or creation operator, and the Ket (or the Bra) belongs to the basis on which the operator acts.
 – A bracket rule, for example, for $⟨A|B⟩$ or $⟨A|H|B⟩$, where $H$ represents a generic quantum operator, has been previously set by Setup, and so determines the result.

Examples

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

When there is not enough information to perform the scalar product, the result is returned unevaluated, depending on the case, in terms of the Bracket function.

 > $\mathrm{Bra}\left(A,n\right)·\mathrm{Ket}\left(B,m\right)$
 ${\mathrm{Bracket}}{}\left({\mathrm{Bra}}{}\left({A}{,}{n}\right){,}{\mathrm{Ket}}{}\left({B}{,}{m}\right)\right)$ (2)
 > $\mathrm{Setup}\left(\mathrm{op}=H\right)$
 $\mathrm{* Partial match of \text{'}}{}\mathrm{op}{}\mathrm{\text{'} against keyword \text{'}}{}\mathrm{quantumoperators}{}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{quantumoperators}}{=}\left\{{H}\right\}\right]$ (3)
 > $\mathrm{Bra}\left(A,n\right)·H·\mathrm{Ket}\left(B,m\right)$
 ${\mathrm{Bracket}}{}\left({\mathrm{Bra}}{}\left({A}{,}{n}\right){,}{H}{,}{\mathrm{Ket}}{}\left({B}{,}{m}\right)\right)$ (4)

When the Bra and Ket belong to the same basis, unless this basis is specified as a continuous basis by the Setup command, it is assumed that the basis is discrete, and the scalar product is returned in terms of KroneckerDelta.

 > $\mathrm{Bra}\left(A,n\right)·\mathrm{Ket}\left(A,m\right)$
 ${{\mathrm{\delta }}}_{{m}{,}{n}}$ (5)
 > $\mathrm{Setup}\left(\mathrm{continuousbasis}=C\right)$
 $\mathrm{* Partial match of \text{'}}{}\mathrm{continuousbasis}{}\mathrm{\text{'} against keyword \text{'}}{}\mathrm{quantumcontinuousbasis}{}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{quantumcontinuousbasis}}{=}\left\{{C}\right\}\right]$ (6)
 > $\mathrm{Bra}\left(C,x\right)·\mathrm{Ket}\left(C,y\right)$
 ${\mathrm{\delta }}{}\left({-}{y}{+}{x}\right)$ (7)

In the output above, you see a Dirac delta function. If, in $Q·\mathrm{Ket}\left(C,y\right)$, the symbol $Q$ does not represent a quantum operator, the operation is transformed into a commutative or noncommutative product, according to whether or not $Q$ is commutative. If $Q$ has been set to represent a quantum operator, or was returned as such by the Annihilation or Creation commands, then $Q$ is applied to the Ket as follows:

 > $Q·\mathrm{Ket}\left(C,y\right)$
 ${Q}{}{\mathrm{Ket}}{}\left({C}{,}{y}\right)$ (8)
 > $\mathrm{Setup}\left(\mathrm{quantumop}=Q\right)$
 $\mathrm{* Partial match of \text{'}}{}\mathrm{quantumop}{}\mathrm{\text{'} against keyword \text{'}}{}\mathrm{quantumoperators}{}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{quantumoperators}}{=}\left\{{H}{,}{Q}\right\}\right]$ (9)
 > $Q·\mathrm{Ket}\left(C,y\right)$
 ${Q}{·}{\mathrm{Ket}}{}\left({C}{,}{y}\right)$ (10)

Kets using $Q$ as a label (first argument) are eigenvectors of the operator $Q$; to identify the quantum number entered as an eigenvalue, indicate its position as an index to the operator $Q$.

 > $Q\left[1\right]·\mathrm{Ket}\left(Q,m,n\right)$
 ${m}{}{\mathrm{Ket}}{}\left({Q}{,}{m}{,}{n}\right)$ (11)
 > $Q\left[2\right]·\mathrm{Ket}\left(Q,m,n\right)$
 ${n}{}{\mathrm{Ket}}{}\left({Q}{,}{m}{,}{n}\right)$ (12)

Note that there is an inert form for the scalar product operation, represented, as in the case of the other Physics commands, by the operator preceded by %. The inert form is activated by using the value command.

 > $\mathrm{%.}\left({Q}_{1},\mathrm{Ket}\left(Q,m,n\right)\right)$
 ${\mathrm{%.}}{}\left({{Q}}_{{1}}{,}{\mathrm{Ket}}{}\left({Q}{,}{m}{,}{n}\right)\right)$ (13)
 > $\mathrm{value}\left(\right)$
 ${m}{}{\mathrm{Ket}}{}\left({Q}{,}{m}{,}{n}\right)$ (14)

By setting the bracket rules, you can also control the result of the corresponding scalar products; note the use of the default abbreviation $\mathrm{KroneckerDelta}$ for KroneckerDelta.

 > $\mathrm{%Bracket}\left(\mathrm{Bra}\left(Q,m,n\right),\mathrm{Ket}\left(A,r,s\right)\right)=A\left(q\right)\mathrm{kd_}\left[m,r\right]\mathrm{kd_}\left[n,s\right]$
 ${\mathrm{%Bracket}}{}\left({\mathrm{Bra}}{}\left({Q}{,}{m}{,}{n}\right){,}{\mathrm{Ket}}{}\left({A}{,}{r}{,}{s}\right)\right){=}{A}{}\left({q}\right){}{{\mathrm{KroneckerDelta}}}_{{m}{,}{r}}{}{{\mathrm{KroneckerDelta}}}_{{n}{,}{s}}$ (15)
 > $\mathrm{Setup}\left(\right)$
 $\left[{\mathrm{bracketrules}}{=}\left\{{\mathrm{%Bracket}}{}\left({\mathrm{%Bra}}{}\left({Q}{,}{m}{,}{n}\right){,}{\mathrm{%Ket}}{}\left({A}{,}{r}{,}{s}\right)\right){=}{A}{}\left({q}\right){}{{\mathrm{KroneckerDelta}}}_{{m}{,}{r}}{}{{\mathrm{KroneckerDelta}}}_{{n}{,}{s}}\right\}\right]$ (16)
 > $\mathrm{%Bracket}\left(\mathrm{Bra}\left(Q,i,j\right),\mathrm{Ket}\left(A,k,l\right)\right)$
 ${\mathrm{%Bracket}}{}\left({\mathrm{Bra}}{}\left({Q}{,}{i}{,}{j}\right){,}{\mathrm{Ket}}{}\left({A}{,}{k}{,}{l}\right)\right)$ (17)
 > $\mathrm{value}\left(\right)$
 ${A}{}\left({q}\right){}{{\mathrm{\delta }}}_{{i}{,}{k}}{}{{\mathrm{\delta }}}_{{j}{,}{l}}$ (18)
 > $\mathrm{Bra}\left(Q,r,s\right)·\mathrm{Ket}\left(A,t,s\right)$
 ${A}{}\left({q}\right){}{{\mathrm{\delta }}}_{{r}{,}{t}}$ (19)

Note that the implementation of Physics[.] is that of an overloaded procedure. Thus if the arguments are not of type algebraic, for example, if they are of type Matrix, and other related packages are loaded, then the operation is automatically forwarded to these other packages. The same happens if you load the Vectors subpackage of Physics, which has its own scalar product operator, which is also implemented as an overloaded procedure. So provided that Physics or Physics[Vectors] is loaded last, these packages can be loaded together with everything working as expected.

For example, load the VectorCalculus and Physics[Vectors] packages to work with Matrix and algebraic representations of vectors, respectively.

 > $\mathrm{with}\left(\mathrm{VectorCalculus}\right):$
 > $\mathrm{with}\left(\mathrm{Physics}:-\mathrm{Vectors}\right):$

Try performing the operations between Bra and Ket vectors belonging to spaces of quantum states: everything continues working.

 > $\mathrm{Bra}\left(A,n\right)·\mathrm{Ket}\left(A,m\right)$
 ${{\mathrm{\delta }}}_{{m}{,}{n}}$ (20)
 > $\mathrm{Bra}\left(C,x\right)·\mathrm{Ket}\left(C,y\right)$
 ${\mathrm{\delta }}{}\left({-}{y}{+}{x}\right)$ (21)
 > $Q·\mathrm{Ket}\left(C,y\right)$
 ${Q}{·}{\mathrm{Ket}}{}\left({C}{,}{y}\right)$ (22)

Now the symbols $\mathrm{A_}$ and $\mathrm{B_}$ are algebraic representations for vectors because you loaded the Vectors package, so the following operation is automatically forwarded to be performed by that package.

Scalar product between 3-D non-projected vectors:

 > $\mathrm{AB}≔\mathrm{A_}·\mathrm{B_}$
 ${\mathrm{AB}}{≔}\stackrel{{\to }}{{A}}{·}\stackrel{{\to }}{{B}}$ (23)

Algebraic sum:

 > $\mathrm{A_},\mathrm{B_}≔\mathrm{_i}+2\mathrm{_j}+3\mathrm{_k},4\mathrm{_i}+5\mathrm{_j}+6\mathrm{_k}$
 $\stackrel{{\to }}{{A}}{,}\stackrel{{\to }}{{B}}{≔}\stackrel{{\wedge }}{{i}}{+}{2}{}\stackrel{{\wedge }}{{j}}{+}{3}{}\stackrel{{\wedge }}{{k}}{,}{4}{}\stackrel{{\wedge }}{{i}}{+}{5}{}\stackrel{{\wedge }}{{j}}{+}{6}{}\stackrel{{\wedge }}{{k}}$ (24)
 > $\mathrm{lprint}\left(\mathrm{A_}\right)$
 _i+2*_j+3*_k
 > $\mathrm{type}\left(\mathrm{A_},\mathrm{algebraic}\right)$
 ${\mathrm{true}}$ (25)
 > $\mathrm{AB}$
 ${32}$ (26)

In the next example, $A$ and $B$ are Matrix representation of vectors because you loaded the VectorCalculus package. This operation is automatically forwarded to be performed by that package's subroutines.

$\mathrm{A_}$ is not an algebraic object:

 > $\mathrm{A_},\mathrm{B_}≔⟨1|2|3⟩,⟨4|5|6⟩$
 $\stackrel{{\to }}{{A}}{,}\stackrel{{\to }}{{B}}{≔}\left({1}\right){{e}}_{{x}}{+}\left({2}\right){{e}}_{{y}}{+}\left({3}\right){{e}}_{{z}}{,}\left({4}\right){{e}}_{{x}}{+}\left({5}\right){{e}}_{{y}}{+}\left({6}\right){{e}}_{{z}}$ (27)
 > $\mathrm{lprint}\left(\mathrm{A_}\right)$
 Vector[row](3,{1 = 1, 2 = 2, 3 = 3},datatype = anything,storage = rectangular, order = Fortran_order,attributes = [coords = cartesian],shape = [])
 > $\mathrm{type}\left(\mathrm{A_},\mathrm{algebraic}\right)$
 ${\mathrm{false}}$ (28)
 > $\mathrm{A_}·\mathrm{B_}$
 ${32}$ (29)

The Physics[.] operator is also a handy shortcut for performing simplification of contracted indices in tensor products. Define first some spacetime tensors.

 > $\mathrm{Define}\left(A,B\right)$
 $\mathrm{Defined objects with tensor properties}$
 $\left\{{A}{,}{B}{,}{{\mathrm{\gamma }}}_{{\mathrm{\mu }}}{,}{{\mathrm{\sigma }}}_{{\mathrm{\mu }}}{,}{{\partial }}_{{\mathrm{\mu }}}{,}{{g}}_{{\mathrm{\mu }}{,}{\mathrm{\nu }}}{,}{{\mathrm{\epsilon }}}_{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}}\right\}$ (30)

Compare the difference between * and .

 > $\mathrm{g_}\left[\mathrm{\alpha },\mathrm{\mu }\right]A\left[\mathrm{\mu }\right]$
 ${{A}}_{{\mathrm{\mu }}}{}{{\mathrm{g_}}}_{{\mathrm{\alpha }}\phantom{{\mathrm{\mu }}}}^{\phantom{{\mathrm{\alpha }}}{\mathrm{\mu }}}$ (31)
 > $\mathrm{g_}\left[\mathrm{\alpha },\mathrm{\mu }\right]·A\left[\mathrm{\mu }\right]$
 ${{A}}_{{\mathrm{\alpha }}}$ (32)

So is g_[alpha, mu] . A[mu] equivalent to Simplify(g_[alpha, mu] * A[mu], indices). This functionality is particularly useful when handling larger expressions where you want contraction to be simplified only in some places. Consider the following product

 > $\mathrm{g_}\left[\mathrm{\alpha },\mathrm{\mu }\right]A\left[\mathrm{\mu }\right]\mathrm{g_}\left[\mathrm{\alpha },\mathrm{\nu }\right]B\left[\mathrm{\nu }\right]$
 ${{A}}_{{\mathrm{\mu }}}{}{{B}}_{{\mathrm{\nu }}}{}{{\mathrm{g_}}}_{{\mathrm{\alpha }}\phantom{{\mathrm{\mu }}}}^{\phantom{{\mathrm{\alpha }}}{\mathrm{\mu }}}{}{{g}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}\phantom{{,}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\alpha }}{,}{\mathrm{\nu }}}$ (33)

You can always Simplify the whole product, as in

 > $\mathrm{Simplify}\left(,\mathrm{indices}\right)$
 ${{A}}_{{\mathrm{\nu }}}{}{{B}}_{\phantom{{}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\nu }}}$ (34)

Using Physics[.], however, you can achieve either the same, or any more selective simplification. Replacing the first * by .,

 > $\left(\mathrm{g_}\left[\mathrm{\alpha },\mathrm{\mu }\right]·A\left[\mathrm{\mu }\right]\right)\mathrm{g_}\left[\mathrm{\alpha },\mathrm{\nu }\right]B\left[\mathrm{\nu }\right]$
 ${{A}}_{{\mathrm{\alpha }}}{}{{B}}_{{\mathrm{\nu }}}{}{{g}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}\phantom{{,}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\alpha }}{,}{\mathrm{\nu }}}$ (35)

Likely (note the parenthesis to indicate the desired order of precedence between . and *)

 > $\mathrm{g_}\left[\mathrm{\alpha },\mathrm{\mu }\right]A\left[\mathrm{\mu }\right]\left(\mathrm{g_}\left[\mathrm{\alpha },\mathrm{\nu }\right]·B\left[\mathrm{\nu }\right]\right)$
 ${{B}}_{{\mathrm{\alpha }}}{}{{A}}_{{\mathrm{\mu }}}{}{{g}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}\phantom{{,}}\phantom{{\mathrm{\mu }}}}^{\phantom{{}}{\mathrm{\alpha }}{,}{\mathrm{\mu }}}$ (36)

and replacing * and . in the middle of the expression,

 > $\left(\left(\mathrm{g_}\left[\mathrm{\alpha },\mathrm{\mu }\right]A\left[\mathrm{\mu }\right]\right)·\mathrm{g_}\left[\mathrm{\alpha },\mathrm{\nu }\right]\right)B\left[\mathrm{\nu }\right]$
 ${{A}}_{{\mathrm{\nu }}}{}{{B}}_{\phantom{{}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\nu }}}$ (37)

When one of the sides of . is a nested expression, the simplification of contracted indices is performed recursively, compare for instance

 > $\mathrm{g_}\left[\mathrm{\alpha },\mathrm{\mu }\right]\left(A\left[\mathrm{\mu }\right]+B\left[\mathrm{\mu }\right]\right)$
 $\left({{A}}_{{\mathrm{\mu }}}{+}{{B}}_{{\mathrm{\mu }}}\right){}{{\mathrm{g_}}}_{{\mathrm{\alpha }}\phantom{{\mathrm{\mu }}}}^{\phantom{{\mathrm{\alpha }}}{\mathrm{\mu }}}$ (38)
 > $\mathrm{g_}\left[\mathrm{\alpha },\mathrm{\mu }\right]·\left(A\left[\mathrm{\mu }\right]+B\left[\mathrm{\mu }\right]\right)$
 ${{A}}_{{\mathrm{\alpha }}}{+}{{B}}_{{\mathrm{\alpha }}}$ (39)

Set the spacetime metric to be the Schwarzschild metric and consider the contraction of all the indices of the Riemann tensor

 > $\mathrm{g_}\left[\mathrm{sc}\right]$
 ${}{}\mathrm{_______________________________________________________}$
 ${}{}\mathrm{Systems of spacetime coordinates are:}{}{}{}\left\{X=\left(r{,}\mathrm{\theta }{,}\mathrm{\phi }{,}t\right)\right\}$
 ${}{}\mathrm{Default differentiation variables for d_, D_ and dAlembertian are:}{}{}{}\left\{X=\left(r{,}\mathrm{\theta }{,}\mathrm{\phi }{,}t\right)\right\}$
 $\mathrm{Setting}{}\mathrm{lowercaselatin_is}{}\mathrm{letters to represent}{}\mathrm{space}{}\mathrm{indices}$
 ${}{}\mathrm{The Schwarzschild metric in coordinates}{}{}{}\left[r{,}\mathrm{\theta }{,}\mathrm{\phi }{,}t\right]$
 $\mathrm{Parameters:}{}\left[m\right]$
 $\mathrm{Signature:}{}\left(\mathrm{- - - +}\right)$
 ${}{}\mathrm{_______________________________________________________}$
 ${{\mathrm{g_}}}_{{\mathrm{μ}}{,}{\mathrm{ν}}}{=}\left(\left[\begin{array}{cccc}\frac{r}{2{}m-r}& 0& 0& 0\\ 0& -{r}^{2}& 0& 0\\ 0& 0& -{r}^{2}{}{\mathrm{sin}{}\left(\mathrm{θ}\right)}^{2}& 0\\ 0& 0& 0& \frac{r-2{}m}{r}\end{array}\right]\right)$ (40)
 > $\mathrm{Riemann}\left[\mathrm{\alpha },\mathrm{\beta },\mathrm{\mu },\mathrm{\nu }\right]\mathrm{Riemann}\left[\mathrm{\alpha },\mathrm{\beta },\mathrm{\mu },\mathrm{\nu }\right]$
 ${{R}}_{{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}}{}{{R}}_{\phantom{{}}\phantom{{\mathrm{\alpha }}}\phantom{{,}}\phantom{{\mathrm{\beta }}}\phantom{{,}}\phantom{{\mathrm{\mu }}}\phantom{{,}}\phantom{{\mathrm{\nu }}}}^{\phantom{{}}{\mathrm{\alpha }}{,}{\mathrm{\beta }}{,}{\mathrm{\mu }}{,}{\mathrm{\nu }}}$ (41)
 > $\mathrm{Riemann}\left[\mathrm{\alpha },\mathrm{\beta },\mathrm{\mu },\mathrm{\nu }\right]·\mathrm{Riemann}\left[\mathrm{\alpha },\mathrm{\beta },\mathrm{\mu },\mathrm{\nu }\right]$
 $\frac{{48}{}{{m}}^{{2}}}{{{r}}^{{6}}}$ (42)
 > 

References

 Cohen-Tannoudji, C.; Diu, B.; and Laloe, F. Quantum Mechanics. Chapter II. Paris, France: Hermann, 1977.