KroneckerDelta - Maple Help

Physics[KroneckerDelta] - the Kronecker delta

 Calling Sequence KroneckerDelta[m, n]

Parameters

 m, n - the indices, as names representing integer numbers or the numbers themselves

Description

 • KroneckerDelta[m, n], displayed as $\mathrm{δ__m,n}$, is a computational representation for the Kronecker Delta, that is: it returns 1 or 0, according to whether the indices are equal or different, or so assumed using assuming. When equality cannot be proved or disproved KroneckerDelta[m, n] returns unevaluated, echoing the input.
 • Note: Since Maple 2019, KroneckerDelta[m, n] is not implemented as a tensor (of type Physics:-Library:-PhysicsType:-Tensor), even if $m$ and $n$ are letters representing spacetime or space tensor indices, unless:
 – one of such spacetime or space indices is contravariant, preceded with ~, as in ~n, while the other remains covariant, in which case KroneckerDelta[m, ~n] is automatically transformed into the spacetime metric g_[m, n] which is a tensor;
 – the indices are of type Physics:-Library:-PhysicsType:-, in which case KroneckerDelta[m, ~n] represents the (tensor) metric of the corresponding space and is used to contract the corresponding indices.
 Consequently $\mathrm{δ__m,m}$ with the two indices equal and covariant, returns the number 1 when KroneckerDelta is not a tensor, and Einstein's sum rule for repeated indices is applied otherwise, resulting in the trace, the dimension of the space to which the indices belong (e.g. for su3 indices the dimension is 8 and for su3matrix indices the dimension is 3).
 • If, on the other hand, you prefer to work with KroneckerDelta[m, n] always as a tensor, for example in quantum mechanics by setting the spacetime to be Euclidean and of dimension 3 (something you can accomplish using Setup), you can set a macro, or Define a tensor representing the Kronecker $\mathrm{\delta }$ tensor also for space or spacetime indices. See the example at the end of the Examples section.
 • The %KroneckerDelta command is the inert form of KroneckerDelta, so it represents the same mathematical operation but without performing it. To perform the operation, use value.
 • Some automatic checking and normalization are carried out each time you enter KroneckerDelta[...]. The checking is concerned with possible syntax errors. The automatic normalization takes into account the symmetry of KroneckerDelta[m,n] with respect to interchanging the positions of the indices m and n.
 • The %KroneckerDelta command is the inert form of KroneckerDelta, so it represents the same thing but entering it does not result in performing any computation. To perform the related computations as if %KroneckerDelta were KroneckerDelta, use value.

Examples

 > $\mathrm{with}\left(\mathrm{Physics}\right):$
 > $\mathrm{Setup}\left(\mathrm{mathematicalnotation}=\mathrm{true}\right)$
 $\left[{\mathrm{mathematicalnotation}}{=}{\mathrm{true}}\right]$ (1)
 > $\mathrm{KroneckerDelta}\left[2,2\right]=\mathrm{KroneckerDelta}\left[m,m\right]$
 ${1}{=}{1}$ (2)
 > $\mathrm{KroneckerDelta}\left[2,3\right]$
 ${0}$ (3)
 > $\mathrm{KroneckerDelta}\left[m,n\right]$
 ${{\mathrm{\delta }}}_{{m}{,}{n}}$ (4)

KroneckerDelta is sensitive to assumptions:

 > $\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{assuming}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}m=n$
 ${1}$ (5)
 > $\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{assuming}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}m\ne n$
 ${0}$ (6)

The symmetry property of KroneckerDelta is automatically taken into account when the indices have symbolic values

 > $\mathrm{KroneckerDelta}\left[m,n\right]-\mathrm{KroneckerDelta}\left[n,m\right]$
 ${0}$ (7)

By default, spacetime indices are represented by greek letters and the dimension of spacetime is 4 - you can query about that via

 > $\mathrm{Setup}\left(\mathrm{spacetimeindices},\mathrm{dimension}\right)$
 $\left[{\mathrm{dimension}}{=}{4}{,}{\mathrm{spacetimeindices}}{=}{\mathrm{greek}}\right]$ (8)

Note: Since Maple 2019, KroneckerDelta[m, n] is not considered a tensor (of type Physics:-Library:-PhysicsType:-Tensor), even if $m$ and $n$ are letters representing space or spacetime tensor indices, unless the indices are of type Physics:-Library:-PhysicsType:-<spinorindex, su2index, su2matrixindex, su3index, su3matrixindex, or gaugeindex>. Consequently, the following calls to KroneckerDelta with repeated indices return the dimension

 > $\mathrm{Setup}\left(\mathrm{su2indices}=\mathrm{lowercaselatin_ah},\mathrm{su3indices}=\mathrm{lowercaselatin_is}\right)$
 $\left[{\mathrm{su2indices}}{=}{\mathrm{lowercaselatin_ah}}{,}{\mathrm{su3indices}}{=}{\mathrm{lowercaselatin_is}}\right]$ (9)
 > $\mathrm{KroneckerDelta}\left[a,a\right]$
 ${3}$ (10)
 > $\mathrm{type}\left(a,\mathrm{Physics}:-\mathrm{Library}:-\mathrm{PhysicsType}:-\mathrm{su2index}\right)$
 ${\mathrm{true}}$ (11)
 > $\mathrm{type}\left(\mathrm{KroneckerDelta}\left[a,b\right],\mathrm{Physics}:-\mathrm{Library}:-\mathrm{PhysicsType}:-\mathrm{Tensor}\right)$
 ${\mathrm{true}}$ (12)
 > $\mathrm{KroneckerDelta}\left[j,j\right]$
 ${8}$ (13)
 > $\mathrm{type}\left(j,\mathrm{Physics}:-\mathrm{Library}:-\mathrm{PhysicsType}:-\mathrm{su3index}\right)$
 ${\mathrm{true}}$ (14)
 > $\mathrm{type}\left(\mathrm{KroneckerDelta}\left[j,k\right],\mathrm{Physics}:-\mathrm{Library}:-\mathrm{PhysicsType}:-\mathrm{Tensor}\right)$
 ${\mathrm{true}}$ (15)

and the following does not return the trace, but the number 1

 > $\mathrm{KroneckerDelta}\left[\mathrm{\mu },\mathrm{\mu }\right]$
 ${1}$ (16)
 > $\mathrm{type}\left(\mathrm{KroneckerDelta}\left[\mathrm{\mu },\mathrm{\nu }\right],\mathrm{Physics}:-\mathrm{Library}:-\mathrm{PhysicsType}:-\mathrm{Tensor}\right)$
 ${\mathrm{false}}$ (17)
 > $\mathrm{type}\left(\mathrm{\mu },\mathrm{Physics}:-\mathrm{Library}:-\mathrm{PhysicsType}:-\mathrm{spacetimeindex}\right)$
 ${\mathrm{true}}$ (18)

Care should be taken, however, if you happen to index KroneckerDelta with a space or spacetime index such that one index is covariant and the other contravariant (preceded by ~). In those cases KroneckerDelta is automatically transformed, respectively into the space or spacetime metric, gamma_ or g_ (all displayed with the $\mathrm{\delta }$ greek letter as is standard in physics textbooks), for which the index repeated represents the trace, respectively equal to the space or spacetime dimension.

 > $\mathrm{KroneckerDelta}\left[\mathrm{\mu },\mathrm{~nu}\right]=\mathrm{g_}\left[\mathrm{\mu },\mathrm{~nu}\right]$
 ${{\mathrm{g_}}}_{{\mathrm{\mu }}\phantom{{\mathrm{\nu }}}}^{\phantom{{\mathrm{\mu }}}{\mathrm{\nu }}}{=}{{\mathrm{g_}}}_{{\mathrm{\mu }}\phantom{{\mathrm{\nu }}}}^{\phantom{{\mathrm{\mu }}}{\mathrm{\nu }}}$ (19)
 > $\mathrm{lprint}\left(\right)$
 Physics:-g_[mu,~nu] = Physics:-g_[mu,~nu]
 > $\mathrm{eval}\left(,\mathrm{\mu }=\mathrm{\nu }\right)$
 ${4}{=}{4}$ (20)
 > $\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{assuming}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{\mu }=\mathrm{\nu }$
 ${4}{=}{4}$ (21)

There is one scenario, typical in quantum mechanics, in which KroneckerDelta is however used as a tensor to represent the metric of an Euclidean space, often of dimension 3, and that representation is used when expressing commutator rules. For example,

 > $\mathrm{Setup}\left(\mathrm{metric}=\mathrm{Euclidean},\mathrm{dimension}=3,\mathrm{su2indices}=\mathrm{none},\mathrm{su3indices}=\mathrm{none},\mathrm{spacetimeindices}=\mathrm{lowercaselatin}\right)$
 $\mathrm{The dimension and signature of the tensor space are set to}{}\left[3{,}{}{}\left(\mathrm{+ + +}\right)\right]$
 ${}{}\mathrm{_______________________________________________________}$
 ${}{}\mathrm{Systems of spacetime coordinates are:}{}{}{}\left\{X=\left(\mathrm{x1}{,}\mathrm{x2}{,}\mathrm{x3}\right)\right\}$
 ${}{}\mathrm{Default differentiation variables for d_, D_ and dAlembertian are:}{}{}{}\left\{X=\left(\mathrm{x1}{,}\mathrm{x2}{,}\mathrm{x3}\right)\right\}$
 ${}{}\mathrm{The Euclidean metric in coordinates}{}{}{}\left[\mathrm{x1}{,}\mathrm{x2}{,}\mathrm{x3}\right]$
 ${}{}\mathrm{_______________________________________________________}$
 ${{\mathrm{g_}}}_{{\mathrm{μ}}{,}{\mathrm{ν}}}{=}\left(\left[\begin{array}{rrr}1& 0& 0\\ 0& 1& 0\\ 0& 0& 1\end{array}\right]\right)$
 ${}{}\mathrm{_______________________________________________________}$
 $\left[{\mathrm{dimension}}{=}{3}{,}{\mathrm{metric}}{=}\left\{\left({1}{,}{1}\right){=}{1}{,}\left({2}{,}{2}\right){=}{1}{,}\left({3}{,}{3}\right){=}{1}\right\}{,}{\mathrm{spacetimeindices}}{=}{\mathrm{lowercaselatin}}{,}{\mathrm{su2indices}}{=}{\mathrm{none}}{,}{\mathrm{su3indices}}{=}{\mathrm{none}}\right]$ (22)

Define now ${q}_{j}$ and ${p}_{k}$ as tensors respectively representing position and momentum

 > $\mathrm{Setup}\left(\mathrm{quantumoperators}=\left\{p,q\right\},\mathrm{tensors}=\left\{p\left[k\right],q\left[j\right]\right\},\mathrm{metric}=\mathrm{Euclidean},\mathrm{dimension}=3\right)$
 ${}{}\mathrm{_______________________________________________________}$
 ${}{}\mathrm{The Euclidean metric in coordinates}{}{}{}\left[\mathrm{x1}{,}\mathrm{x2}{,}\mathrm{x3}\right]$
 ${}{}\mathrm{_______________________________________________________}$
 ${{\mathrm{g_}}}_{{a}{,}{b}}{=}\left(\left[\begin{array}{rrr}1& 0& 0\\ 0& 1& 0\\ 0& 0& 1\end{array}\right]\right)$
 ${}{}\mathrm{_______________________________________________________}$
 $\left[{\mathrm{dimension}}{=}{3}{,}{\mathrm{metric}}{=}\left\{\left({1}{,}{1}\right){=}{1}{,}\left({2}{,}{2}\right){=}{1}{,}\left({3}{,}{3}\right){=}{1}\right\}{,}{\mathrm{quantumoperators}}{=}\left\{{p}{,}{q}\right\}{,}{\mathrm{tensors}}{=}\left\{{{\mathrm{\gamma }}}_{{a}}{,}{{\mathrm{\sigma }}}_{{a}}{,}{{\partial }}_{{a}}{,}{{g}}_{{a}{,}{b}}{,}{{p}}_{{k}}{,}{{q}}_{{j}}{,}{{\mathrm{\epsilon }}}_{{a}{,}{b}{,}{c}}{,}{{X}}_{{a}}\right\}\right]$ (23)

Set the standard commutator rules using tensor notation $\left[{p}_{j},{q}_{k}\right]={\mathrm{KroneckerDelta}}_{j,k}$ there the right-hand side is expressed using KroneckerDelta[j,k]

 > $\mathrm{Setup}\left(\mathrm{%Commutator}\left(p\left[j\right],q\left[k\right]\right)=\mathrm{KroneckerDelta}\left[j,k\right]\right)$
 ${\mathbit{Warning, since Maple 2019 KroneckerDelta is not implemented as a tensor unless the indices are of type indices, not space or spacetime. Thus, the right-hand side of the algebra rule}}{}\left({\mathrm{?}}{\mathbf{=}}{{\mathbf{\delta }}}_{{\mathbit{j}}{\mathbf{,}}{\mathbit{k}}}\right){}{\mathbit{has for free tensor indices}}{}{\mathbit{\varnothing }}{}{\mathbit{, while the left-hand side has}}{}\left\{{\mathbit{j}}{,}{\mathbit{k}}\right\}{}{\mathbit{, of which}}{}\left\{{\mathbit{j}}{,}{\mathbit{k}}\right\}{}{\mathbit{appear in}}{}\left\{{{\mathbf{\delta }}}_{{\mathbit{j}}{\mathbf{,}}{\mathbit{k}}}\right\}{}{\mathbit{. To resolve this problem you can: 1. If the dimension of the tensor indices on the left-hand side is 3, then use su2indices that you can define via}}{}{\mathbit{Setup}}{}\left({\mathbit{su2indices}}{\mathbf{=}}{\mathbit{lowercaselatin}}\right){}{\mathbit{. 2. Use the spacetime metric g_, or the space metric gamma_, instead of KroneckerDelta. If so, check the value of:}}{}{\mathbit{Setup}}{}\left({\mathbit{signature}}\right){}{\mathbit{. 3. Enter:}}{}{\mathbit{macro}}{}\left({\mathbit{KroneckerDelta}}{\mathbf{=}}{\mathbit{g_}}\right){}{\mathbit{; or use gamma_ instead of g_. 4. Define a Kronecker}}{}{\mathbf{\delta }}{}{\mathbit{tensor. In the following, type \text{'}delta\text{'} on the left and \text{'}KroneckerDelta\text{'} on the right, or copy and paste:}}{}{\mathbit{Define}}{}\left({{\mathbf{\delta }}}_{{\mathbit{a}}{\mathbf{,}}{\mathbit{b}}}{\mathbf{=}}{\mathbit{Matrix}}{}\left({\mathbf{3}}{,}{\mathbf{3}}{,}\left({\mathbit{j}}{,}{\mathbit{k}}\right){\mathbf{↦}}{{\mathbf{\delta }}}_{{\mathbit{j}}{\mathbf{,}}{\mathbit{k}}}\right)\right){}{\mathbit{. After any of the above it is recommended that you set this algebra rule again, with the corrected right-hand side, to avoid problems due to having different free indices on each side of the rule.}}$
 $\left[{\mathrm{algebrarules}}{=}\left\{{\mathrm{%Commutator}}{}\left({{p}}_{{j}}{,}{{q}}_{{k}}\right){=}{{\mathrm{KroneckerDelta}}}_{{j}{,}{k}}\right\}\right]$ (24)

The warning message explains the problem: the free indices are not the same at each side of the algebra rule because KroneckerDelta[j, k] is not representing a tensor, even when in an Euclidean space (only) its components do transform like tensor components and are equal to the identity matrix. From the four options indicated, if you are adapting a worksheet written before Maple 2019, the simplest is option 3:

 > $\mathrm{macro}\left(\mathrm{KroneckerDelta}=\mathrm{g_}\right):$

After that, all occurrences of KroneckerDelta[m, m], now representing g_[m, m] with Einstein's sum over the repeated indices, will automatically return the trace of the metric instead of the number 1:

 > $\mathrm{KroneckerDelta}\left[m,m\right]$
 ${3}$ (25)

You can undo this mapping of KroneckerDelta into g_ at any time via

 > $\mathrm{macro}\left(\mathrm{KroneckerDelta}=\mathrm{KroneckerDelta}\right):$

If you are not adapting worksheets of previous releases, however, the best is option 3, because it gives you access to both the tensor and the non-tensor versions of Kronecker $\mathrm{\delta }$. Directly copying from the message above and pasting on an input line,

 > $\mathrm{Define}\left(\mathrm{\delta }\left[a,b\right]=\mathrm{Matrix}\left(3,3,\left(j,k\right)↦\mathrm{KroneckerDelta}\left[j,k\right]\right)\right)$
 $\mathrm{Defined objects with tensor properties}$
 $\left\{{{\mathrm{\gamma }}}_{{a}}{,}{{\mathrm{\sigma }}}_{{a}}{,}{{\partial }}_{{a}}{,}{{\mathrm{δ}}}_{{a}{,}{b}}{,}{{g}}_{{a}{,}{b}}{,}{{p}}_{{k}}{,}{{q}}_{{j}}{,}{{\mathrm{\epsilon }}}_{{a}{,}{b}{,}{c}}{,}{{X}}_{{a}}\right\}$ (26)

Check now the components and behavior of this Kronecker $\mathrm{delta}$ tensor

 > $\mathrm{\delta }\left[\right]$
 ${{\mathrm{δ}}}_{{a}{,}{b}}{=}\left(\left[\begin{array}{rrr}1& 0& 0\\ 0& 1& 0\\ 0& 0& 1\end{array}\right]\right)$ (27)
 > $\mathrm{\delta }\left[1,1\right]$
 ${1}$ (28)
 > $\mathrm{SumOverRepeatedIndices}\left(\mathrm{\delta }\left[m,m\right]\right)$
 ${3}$ (29)

while you still have the non-tensor version

 > $\mathrm{KroneckerDelta}\left[m,m\right]$
 ${1}$ (30)

You can now reenter the algebra rules in tensor notation, with the right-hand side corrected using the tensor version delta[j, k]

 > $\mathrm{Setup}\left(\mathrm{%Commutator}\left(p\left[j\right],q\left[k\right]\right)=\mathrm{\delta }\left[j,k\right]\right)$
 $\left[{\mathrm{algebrarules}}{=}\left\{{\mathrm{%Commutator}}{}\left({{p}}_{{j}}{,}{{q}}_{{k}}\right){=}{{\mathrm{δ}}}_{{j}{,}{k}}\right\}\right]$ (31)
 > $\mathrm{Matrix}\left(3,\left(m,n\right)↦\left(\mathrm{%Commutator}=\mathrm{Commutator}\right)\left(p\left[m\right],q\left[n\right]\right)\right)$
 $\left[\begin{array}{ccc}\mathrm{%Commutator}{}\left({p}_{1},{q}_{1}\right)=1& \mathrm{%Commutator}{}\left({p}_{1},{q}_{2}\right)=0& \mathrm{%Commutator}{}\left({p}_{1},{q}_{3}\right)=0\\ \mathrm{%Commutator}{}\left({p}_{2},{q}_{1}\right)=0& \mathrm{%Commutator}{}\left({p}_{2},{q}_{2}\right)=1& \mathrm{%Commutator}{}\left({p}_{2},{q}_{3}\right)=0\\ \mathrm{%Commutator}{}\left({p}_{3},{q}_{1}\right)=0& \mathrm{%Commutator}{}\left({p}_{3},{q}_{2}\right)=0& \mathrm{%Commutator}{}\left({p}_{3},{q}_{3}\right)=1\end{array}\right]$ (32)
 > $\left(\mathrm{%Commutator}=\mathrm{Commutator}\right)\left(p\left[a\right],q\left[b\right]\right)$
 ${\mathrm{%Commutator}}{}\left({{p}}_{{a}}{,}{{q}}_{{b}}\right){=}{{\mathrm{δ}}}_{{a}{,}{b}}$ (33)
 > $\mathrm{expand}\left(\mathrm{eval}\left(,a=b\right)\right)$
 ${{p}}_{{b}}{}{{q}}_{{b}}{-}{{q}}_{{b}}{}{{p}}_{{b}}{=}{{\mathrm{δ}}}_{{b}{,}{b}}$ (34)
 > $\mathrm{SumOverRepeatedIndices}\left(\right)$
 ${{p}}_{{1}}{}{{q}}_{{1}}{+}{{p}}_{{2}}{}{{q}}_{{2}}{+}{{p}}_{{3}}{}{{q}}_{{3}}{-}{{q}}_{{1}}{}{{p}}_{{1}}{-}{{q}}_{{2}}{}{{p}}_{{2}}{-}{{q}}_{{3}}{}{{p}}_{{3}}{=}{3}$ (35)
 > $\mathrm{Simplify}\left(\right)$
 ${3}{=}{3}$ (36)
 > 

Compatibility

 • The Physics[KroneckerDelta] command was updated in Maple 2020.