Physics for Maple 2019 - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Physics : Updates : Physics for Maple 2019

 Physics

Maple provides a state-of-the-art environment for algebraic computations in Physics, with emphasis on ensuring that the computational experience is as natural as possible. The theme of the Physics project for Maple 2019 has been the consolidation of the functionality introduced in previous releases, together with significant enhancements to further strengthen the functionality mainly in three areas:

 1 Quantum Mechanics: coherent states, tensor products of states, taylor series of expressions involving anticommutative variables and functions, and several improvements in the normalization and simplification of Commutator and AntiCommutator algebra rules.
 2 Tensor computations in general, making Maple 2019 unmatched in the field, covering classical and quantum mechanics, and special and general relativity, using natural tensor input notation and textbook-like display of results. The functionality for tensors is tightly integrated with the full Maple computation system and extensively documented in "A Complete Guide for performing tensor computations using Physics".
 3 Documentation: besides the new guide for tensor computations, two other new pages, linked in all the help pages of Physics commands, are
 a. Physics Updates organizes and presents in one place all formerly scattered links to updates and presentations with examples on the use of Physics.
 b. Mini-Course: Computer Algebra for Physicists, is a course that can be used as a tutorial, with 10 sections to be covered in 5 hands-on guided experiences of 2 hours each. The first part, 5 sections, is about Maple 101, while the remaining 5 sections is all about using the Physics package.

Overall, the enhancements throughout the entire package increase robustness, versatility and functionality, extending furthermore the range of Physics-related algebraic computations that can be done naturally in a worksheet. The presentation below illustrates both the novelties and the kind of mathematical formulations that can now be performed.

As part of its commitment to providing the best possible environment for algebraic computations in Physics, Maplesoft launched a Maple Physics: Research and Development website with Maple 18, which enabled users to download research versions, ask questions, and provide feedback. The results from this accelerated exchange with people around the world have been incorporated into the Physics package in Maple 2019.

Tensor product of Quantum States using Dirac's Bra-Ket Notation

Tensor products of Hilbert spaces and related quantum states are relevant in a myriad of situations in quantum mechanics, and in particular regarding quantum information. Tensor products are key in the mathematical formulation of entanglement. Below is a presentation of the design and implementation introduced in Maple 2019, with input/output and examples, organized in four sections:

 1 The basic ideas and design
 2 Tensor product notation and the hideketlabel option
 3 Entangled States and the Bell basis
 4 Entangled States, Operators and Projectors

 References [1] Cohen-Tannoudji, C.; Diu, B.; and Laloe,F. Quantum Mechanics, Chapter 2, section F. [2] Griffiths, Robert B. Hilbert Space Quantum Mechanics. Quantum Computation and Quantum Information Theory Course, Physics Department, Carnegie Mellon University, 2014.

The basic ideas and design implemented in Maple 2019

Suppose ${A}$ and ${B}$ are quantum operators and $\mathrm{Ket}\left(A,n\right),\mathrm{et}\left(B,m\right)$ are, respectively, their eigenkets. The following works since the introduction of the Physics package in Maple

 > $\mathrm{with}\left(\mathrm{Physics}\right):$
 > $\mathrm{Setup}\left(\mathrm{op}=\left\{A,B\right\}\right)$
 $\mathrm{* Partial match of \text{'}}\mathrm{op}\mathrm{\text{'} against keyword \text{'}}\mathrm{quantumoperators}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{quantumoperators}}{=}\left\{{A}{,}{B}\right\}\right]$ (1)
 >
 ${A}{}{\mathrm{Ket}}{}\left({A}{,}{\mathrm{α}}\right){=}{\mathrm{\alpha }}{}{\mathrm{Ket}}{}\left({A}{,}{\mathrm{α}}\right)$ (2)
 >
 ${B}{}{\mathrm{Ket}}{}\left({B}{,}{\mathrm{β}}\right){=}{\mathrm{\beta }}{}{\mathrm{Ket}}{}\left({B}{,}{\mathrm{β}}\right)$ (3)

In previous Maple releases, all quantum operators are supposed to act on the same Hilbert space. New in Maple 2019: suppose that ${A}$ and ${B}$ act on different, disjointed, Hilbert spaces.

1) To represent that situation, a new keyword in Setup, $\mathrm{hilbertspaces}$, is introduced. With it you can indicate the quantum operators that act on a Hilbert space, say as in $\mathrm{hilbertspaces}=\left\{\left\{{A}\right\},\left\{{B}\right\}\right\}$ with the meaning that the operator ${A}$ acts on one Hilbert space while ${B}$ acts on another one.

The Hilbert space thus has no particular name (as in 1, 2, 3 ...) and is instead identified by the operators that act on it. There can be one or more, and operators acting on one space can act on other spaces too. The disjointedspaces keyword is a synonym for hilbertspaces and hereafter all Hilbert spaces are assumed to be disjointed.

NOTE: noncommutative quantum operators acting on disjointed spaces commute between themselves, so after setting - for instance - $\mathrm{hilbertspaces}=\left\{\left\{{A}\right\},\left\{{B}\right\}\right\}$, automatically, ${A},{B}$ become quantum operators satisfying (see comment (ii) on page 156 of ref.[1])

${\left[{A},{B}\right]}_{-}=0$

2) Product of Kets and Bras that belong to different Hilbert spaces are understood as tensor products satisfying (see footnote on page 154 of ref.[1]):

$\mathrm{Ket}\left(A,\mathrm{α}\right)\otimes \mathrm{Ket}\left(B,\mathrm{β}\right)=\mathrm{Ket}\left(B,\mathrm{β}\right)\otimes \mathrm{Ket}\left(A,\mathrm{α}\right)$

$\mathrm{Bra}\left(A,\mathrm{α}\right)\otimes \mathrm{Ket}\left(B,\mathrm{β}\right)=\mathrm{Ket}\left(B,\mathrm{β}\right)\otimes \mathrm{Bra}\left(A,\mathrm{α}\right)$

while

$\mathrm{Bra}\left(A,\mathrm{α}\right)\mathrm{Ket}\left(A,\mathrm{α}\right)\ne \mathrm{Ket}\left(A,\mathrm{α}\right)\mathrm{Bra}\left(A,\mathrm{α}\right)$

3) All the operators of one Hilbert space act transparently over operators, Bras, and Kets of other Hilbert spaces. For example

${A}\mathrm{Ket}\left(B,n\right)=\mathrm{Ket}\left(B,n\right){A}$

and the same for the Dagger of this equation, that is

$\mathrm{Bra}\left(B,n\right)\mathrm{Dagger}\left(A\right)=\mathrm{Dagger}\left(A\right)\mathrm{Bra}\left(B,n\right)$

Hence, when we write the left-hand sides of the two equations above and press enter, they are automatically rewritten (returned) as the right-hand sides.

4) Every other quantum operator, set as such using Setup, and not indicated as acting on any particular Hilbert space, is assumed to act on all spaces.

5) Notation:

 • Tensor products formed with operators, or Bras and Kets belonging to different Hilbert spaces (set as such using Setup and the keyword hilbertspaces), are now displayed with the symbol ⊗ in between, as in $\mathrm{Ket}\left(A,n\right)\mathrm{Ket}\left(B,n\right)$ instead of $\mathrm{Ket}\left(A,n\right)\mathrm{Ket}\left(B,n\right)$, and ${A}\otimes {B}$ instead of ${A}{B}$. The product of an operator ${A}$ of one space and a Ket of another space $\mathrm{Ket}\left(B,n\right)$ however, is displayed ${A}$, without ⊗.
 • A new Setup option hideketlabel , makes all the labels in Kets and Bras to be hidden when displaying Kets, Bras, and Bracket, so when you set it entering $\mathrm{Setup}\left(\mathrm{hideketlabel}=\mathrm{true}\right)$,

$\mathrm{Ket}(A,m,n,l$

is displayed as

 This is the notation frequently used when working with angular momentum or in quantum information, where tensor products of Hilbert spaces are used.

Design details

The commutativity of the eigenkets of ${A}$ and ${B}$ is consistent with ${\left[{A},{B}\right]}_{-}=0$, see footnote on page 154 of ref. [1].

Taking advantage of this commutativity of Bras and Kets belonging to disjointed spaces, during the computer algebra session (on the worksheet) the ordering of their products in the output happens automatically and systematically, it is always the same, and according to the following rules: suppose there are two Hilbert subspaces, then:

 1 Within a product, contiguous Kets are grouped per Hilbert subspace
 2 The Hilbert subspaces are ordered by sorting, alphabetically, the operators that act on that subspace.

Example: if one Hilbert subspace has operators $\left\{{A},{E}\right\}$ acting on it and the other has operators $\left\{{B},{C}\right\}$ then a product of contiguous eigenkets of these operators is sorted as

$\mathrm{Ket}\left(A\right)\otimes \mathrm{Ket}\left(E\right)\otimes \mathrm{Ket}\left(B\right)\otimes \mathrm{Ket}\left(C\right)$

Where the first pair of Kets belong to the first Hilbert subspace and the other pair to the second subspace, and where the first subspace is the one whose operands are alphabetically sorted first than the operands of the second subspace (in this example ${A}$ is sorted before ${B}$) and within a subspace, the Kets are also sorted alphabetically (so ${A}$ before ${E}$, then in the second subspace ${B}$ before ${C}$).

Regarding the notation for the Dagger of a tensor product of states, say $\mathrm{Dagger}\left(\mathrm{*}\left(\mathrm{Ket}\left(A,\mathrm{α}\right),\mathrm{Ket}\left(B,\mathrm{β}\right)\right)\right)$ the standard convention for tensor products is to preserve the order, as in representing an exception to the “reverse the order” rule of the Dagger operation. This is conventional, in that Kets and Bras belonging to disjointed spaces actually commute. This convention, however is notationally important for two reasons

 1. Frequently, tensor product of states are written not as a product of Kets but as a single ket with many quantum numbers (multidimensional Hilbert space), for example as $\mathrm{Ket}\left(C,\mathrm{α},\mathrm{β}\right)$, and $\mathrm{Dagger}\left(\mathrm{Ket}\left(C,\mathrm{α},\mathrm{β}\right)\right)$as $\mathrm{Bra}\left(C,\mathrm{α},\mathrm{β}\right)$, that is, preserving the order of the quantum numbers, the first index refers to the first Hilbert subspace and the second index to the other one, in both the Ket and the Bra (its Dagger). So, when these multi-index Kets can be expressed as tensor products, the ordering of the Hilbert subspaces is preserved.
 2. This preservation of the ordering of the Hilbert subspaces in a tensor product of Kets is also relevant in connection with the new Setup keyword hideketlabel, which requires the ordering of subspaces to be preserved in order to have non-ambiguous notation when the quantum numbers of Kets belonging to identical subspaces (e.g. qubits) are the same.

Example: we know that

$\mathrm{Ket}(A,0\mathrm{Ket}\left(B,1\right)\ne \mathrm{Ket}\left(B,0\right)\otimes \mathrm{Ket}\left(A,1\right)$

In the left-hand and right-hand sides of the expression above, the ordering of the Hilbert subspaces is not the same. If we now omit the labels ${A}$ and ${B}$, we would have

$\mathrm{Ket}\left(0\right)\otimes \mathrm{Ket}\left(1\right)\ne \mathrm{et}\left(0\right)\otimes \mathrm{Ket}\left(1\right)$

which would be misleading. Likewise,

$\mathrm{Ket}\left(A,0\right)\otimes \mathrm{Ket}\left(B,1\right)=\mathrm{Ket}\left(B,1\right)\otimes \mathrm{Ket}\left(A,0\right)$

and removing the labels we would get the misleading

$\mathrm{Ket}\left(0\right)\otimes \mathrm{Ket}\left(1\right)=\mathrm{Ket}\left(0\right)\otimes \mathrm{Ket}\left(1\right)$

From all this we see that, in order to make sense of the notation without labels, it is necessary to preserve the ordering of the Hilbert subspaces present in a tensor product, and also when taking the Dagger of a Ket. Accordingly, within tensor products, for instance in these examples, the system will always write Kets of the subspace A before Kets of the subspace B.

Tensor product notation and the hideketlabel option

According to the design section, set now two disjointed Hilbert spaces with operators ${A},{C}$ acting on one of them and ${B},{C}$ on the other one (you can think of  ${C}={A}\otimes {B}$)

 > $\mathrm{Setup}\left(\mathrm{hilbertspaces}=\left\{\left\{A,C\right\},\left\{B,C\right\}\right\}\right)$
 $\left[{\mathrm{disjointedspaces}}{=}\left\{\left\{{A}{,}{C}\right\}{,}\left\{{B}{,}{C}\right\}\right\}\right]$ (4)

Consider a tensor product of Kets, each of which belongs to one of these different spaces, note the new notation using$\otimes$

 >
 ${\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right)$ (5)
 • As explained in the Details of the design section, the ordering of the Hilbert spaces in tensor products is now preserved: Bras (Kets) of the first space always appear before Bras (Kets) of the second space. For example, construct a projector into the state (5)
 >
 ${\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){\otimes }{\mathrm{Bra}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Bra}}{}\left({B}{,}{0}\right)$ (6)

You see that in the product of Bras, and also in the product of Kets, A comes first, then B.

Remark: some textbooks prefer a dyadic style for sorting the operands in products of Bras and Kets that belong to different spaces, for example, $(\mathrm{Ket}\left(A,1\right)\mathrm{Bra}\left(A,1\right))\otimes (\mathrm{Ket}\left(B,0\right)\mathrm{Bra}\left(B,0\right))$ instead of the projector sorting style of (6). Both reorderings of Kets and Bras are mathematically equal.

 • Because that ordering is preserved, one can now hide the label of Bras and Kets without ambiguity, as it is usual in textbooks (e.g. in Quantum Information). For that purpose use the new keyword option hideketlabel
 > $\mathrm{Setup}\left(\mathrm{hide}=\mathrm{true}\right)$
 $\mathrm{* Partial match of \text{'}}\mathrm{hide}\mathrm{\text{'} against keyword \text{'}}\mathrm{hideketlabel}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{hideketlabel}}{=}{\mathrm{true}}\right]$ (7)

The display for (6) is now

 > 
 ${\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){\otimes }{\mathrm{Bra}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Bra}}{}\left({B}{,}{0}\right)$ (8)

Important: this new option only hides the label while displaying the Bra or Ket. The label, however, is still there, both in the input and in the output. One can "see" what is behind this new display using show, that works the same way as it does in the context of CompactDisplay. The actual contents being displayed in (8) is thus (6)

 > $\mathrm{show}$
 ${\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){\otimes }{\mathrm{Bra}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Bra}}{}\left({B}{,}{0}\right)$ (9)

Operators of each of these spaces act on their eigenkets as usual. Here we distribute over both sides of an equation, using * on the left-hand side, to see the product uncomputed, and . on the right-hand side to see it computed:

 >
 ${A}{}{\mathrm{Ket}}{}\left({A}{,}{1}\right){=}{\mathrm{Ket}}{}\left({A}{,}{1}\right)$ (10)
 >
 ${A}{}{\mathrm{Ket}}{}\left({A}{,}{0}\right){=}{0}$ (11)
 • The tensor product of operators belonging to different Hilbert spaces is also displayed using ⊗
 >
 ${A}{\otimes }{B}$ (12)
 • As mentioned in the preceding design section, using the commutativity between operators, Bras and Kets that belong to different Hilbert spaces, within a product, operators are placed contiguous to the Kets and Bras belonging to the space where the operator acts. For example, consider the delayed product represented using the start * operator
 >
 $\left({A}{\otimes }{B}\right){}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){\otimes }{\mathrm{Bra}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Bra}}{}\left({B}{,}{0}\right)$ (13)

Release the product

 > $%$
 ${A}{}{\mathrm{Ket}}{}\left({A}{,}{1}\right){}{B}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right){\otimes }{\mathrm{Bra}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Bra}}{}\left({B}{,}{0}\right)$ (14)

The same operation but now using the dot product . operator. Start by delaying the operation

 >
 $\left({A}{\otimes }{B}\right){·}\left({\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){\otimes }{\mathrm{Bra}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Bra}}{}\left({B}{,}{0}\right)\right)$ (15)

Recalling that this product is mathematically the same as (14), and that

 > ${B}·\mathrm{Ket}\left(B,0\right)$
 ${0}$ (16)

by releasing the delayed product (15) we have

 > 
 ${0}$ (17)

Reset hideketlabel

 >
 $\left[{\mathrm{hideketlabel}}{=}{\mathrm{false}}\right]$ (18)

Implementation details

 • When defining a disjointed Hilbert space that contains operators belonging to one of the previously defined disjointed spaces, if the previously defined space is a subset of the one being defined, the former definition is removed and only the latter is kept.
 • There are three new routines related to operators acting on disjointed spaces
 > $\mathrm{Library}:-\mathrm{BelongToDifferentDisjointedSpaces}\left(A,B\right)$
 ${\mathrm{true}}$ (19)
 and, in connection with the possibility of indicating that two operators act on the same disjointed space, there is a new routine to tell when the operators belong to (act on) the same space
 > $\mathrm{Library}:-\mathrm{BelongToTheSameDisjointedSpace}\left(A,B\right)$
 ${\mathrm{false}}$ (20)
 > $\mathrm{Library}:-\mathrm{BelongToTheSameDisjointedSpace}\left(A,C\right)$
 ${\mathrm{true}}$ (21)
 Finally, there is a routine to tell whether a sequence of objects belong (all of them) to (the same or different) disjointed spaces, i.e. were set as such using Setup and the hilbertpaces keyword
 > $\mathrm{Library}:-\mathrm{BelongToDisjointedSpaces}\left(A,B,C\right)$
 ${\mathrm{true}}$ (22)
 >
 $\mathrm{* Partial match of \text{'}}\mathrm{op}\mathrm{\text{'} against keyword \text{'}}\mathrm{quantumoperators}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{quantumoperators}}{=}\left\{{A}{,}{B}{,}{C}{,}{E}\right\}\right]$ (23)
 > $\mathrm{Library}:-\mathrm{BelongToDisjointedSpaces}\left(E\right)$
 ${\mathrm{false}}$ (24)
 > $\mathrm{Library}:-\mathrm{BelongToDisjointedSpaces}\left(A,B,E\right)$
 ${\mathrm{false}}$ (25)

These three Physics:-Library routines, are the ones used internally by the Physics package to make decisions.

 • Coordinates of a coordinate system defined using the Coordinates, or equivalently the Setup, command, when they are also set to as quantum operators, are automatically assumed to act on disjointed spaces. For example,
 >
 $\left[{\mathrm{coordinatesystems}}{=}\left\{{X}\right\}{,}{\mathrm{dimension}}{=}{3}{,}{\mathrm{quantumoperators}}{=}\left\{{A}{,}{B}{,}{C}{,}{E}{,}{x}{,}{y}{,}{z}\right\}{,}{\mathrm{signature}}{=}{\mathrm{+ + +}}\right]$ (26)
 > $\mathrm{Library}:-\mathrm{BelongToDifferentDisjointedSpaces}\left(x,y\right)$
 ${\mathrm{true}}$ (27)
 Remove the coordinates from the quantum operators set
 >
 $\mathrm{* Partial match of \text{'}}\mathrm{op}\mathrm{\text{'} against keyword \text{'}}\mathrm{quantumoperators}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{quantumoperators}}{=}\left\{{A}{,}{B}{,}{C}{,}{E}\right\}\right]$ (28)
 • The following swapped products on the left-hand and right-hand sides (with their evaluation delayed due to enclosing the equation between ' ' ) are automatically reordered in one and the same way when we remove the delay, as explained in the details of the design section.

Example

 >
 $\mathrm{* Partial match of \text{'}}\mathrm{hide}\mathrm{\text{'} against keyword \text{'}}\mathrm{hideketlabel}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{hideketlabel}}{=}{\mathrm{false}}\right]$ (29)
 >
 ${\mathrm{Ket}}{}\left({A}{,}{n}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{m}\right){=}{\mathrm{Ket}}{}\left({B}{,}{m}\right){\otimes }{\mathrm{Ket}}{}\left({A}{,}{n}\right)$ (30)

Remove now the evaluation delay and the ordering on the right-hand side is automatically rearranged as in the left-hand side.

 > $%$
 ${\mathrm{Ket}}{}\left({A}{,}{n}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{m}\right){=}{\mathrm{Ket}}{}\left({A}{,}{n}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{m}\right)$ (31)

The same using the dot operator .

 >
 ${\mathrm{Ket}}{}\left({A}{,}{n}\right){·}{\mathrm{Ket}}{}\left({B}{,}{m}\right){=}{\mathrm{Ket}}{}\left({B}{,}{m}\right){·}{\mathrm{Ket}}{}\left({A}{,}{n}\right)$ (32)
 > 
 ${\mathrm{Ket}}{}\left({A}{,}{n}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{m}\right){=}{\mathrm{Ket}}{}\left({A}{,}{n}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{m}\right)$ (33)

NOTE: the dot product operator, ., is used to perform contractions or attachments in the space of quantum states. Therefore, in the case of tensor products, it returns using the star product operator *, in that there is no meaning for the contraction of tensors of different (disjointed) Hilbert spaces.

Regarding the product of a Bra and a Ket belonging to disjointed spaces, we also have, automatically,

 >
 ${\mathrm{Bra}}{}\left({A}{,}{n}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{n}\right){=}{\mathrm{Ket}}{}\left({B}{,}{n}\right){\otimes }{\mathrm{Bra}}{}\left({A}{,}{n}\right)$ (34)
 > $%$
 ${\mathrm{Ket}}{}\left({B}{,}{n}\right){\otimes }{\mathrm{Bra}}{}\left({A}{,}{n}\right){=}{\mathrm{Ket}}{}\left({B}{,}{n}\right){\otimes }{\mathrm{Bra}}{}\left({A}{,}{n}\right)$ (35)

So the left-hand side is rewritten as the right-hand side, and $\mathrm{Bra}\left(A,n\right)\otimes \mathrm{Ket}\left(B,n\right)$is not a "scalar product", but an operator in the tensor product of spaces, since ${A}$ and ${B}$ belong to different disjointed spaces.

Enclose again the input with ' ' to delay its evaluation

 >
 ${A}{}{\mathrm{Ket}}{}\left({B}{,}{n}\right){=}{\mathrm{Ket}}{}\left({B}{,}{n}\right){}{A}$ (36)

Release the evaluation

 > $%$
 ${\mathrm{Ket}}{}\left({B}{,}{n}\right){}{A}{=}{\mathrm{Ket}}{}\left({B}{,}{n}\right){}{A}$ (37)

In the output above we see that ${A}·\mathrm{Ket}\left(B,n\right)$ is not interpreted as contraction between an operator and Ket, but as the product of ${A}={A}{\mathrm{𝕀}}_{{B}}$ acting on $\mathrm{Ket}\left(B,n\right)$ where ${\mathrm{𝕀}}_{{B}}$ is the identity (projector) onto the ${B}$ space. That is, an operator of one disjointed space acts transparently over a Bra or a Ket of a different disjointed space. The same happens with $\mathrm{Dagger}\left(A\right)$ just that, while ${A}$ moves to the right, jumping over a Bra or Ket (see (37)), $\mathrm{Dagger}\left(A\right)$ moves to the left:

 >
 ${\mathrm{*}}{}\left({\mathrm{Dagger}}{}\left({A}\right){,}{\mathrm{Bra}}{}\left({B}{,}{n}\right)\right){=}{\mathrm{*}}{}\left({\mathrm{Bra}}{}\left({B}{,}{n}\right){,}{\mathrm{Dagger}}{}\left({A}\right)\right)$ (38)
 > $%$
 ${\mathrm{*}}{}\left({\mathrm{Dagger}}{}\left({A}\right){,}{\mathrm{Bra}}{}\left({B}{,}{n}\right)\right){=}{\mathrm{*}}{}\left({\mathrm{Dagger}}{}\left({A}\right){,}{\mathrm{Bra}}{}\left({B}{,}{n}\right)\right)$ (39)

NOTE: Although determining "who is the Dagger of who" is arbitrary, this implementation follows what we do with paper and pencil: operators act to their right while those having an explicit Dagger act to their left.

Finally, the notation used for tensor products of operators is the same one used for tensor products of Bras and Kets:

 >
 ${A}{\otimes }{B}$ (40)

As explained in the Details of the design section, the ordering of the Hilbert spaces in tensor products is now preserved, so taking the Dagger does not swap the operands in this product:

 > $\mathrm{Dagger}\left(\right)$
 ${\mathrm{*}}{}\left({\mathrm{Dagger}}{}\left({A}\right){,}{\mathrm{Dagger}}{}\left({B}\right)\right)$ (41)

Entangled States and the Bell basis

With the introduction of disjointed Hilbert spaces in Maple 2019 it is possible to represent entangled quantum states in a simple way, basically as done with paper and pencil.

Recalling the Hilbert spaces set at this point are,

 >
 $\mathrm{* Partial match of \text{'}}\mathrm{hilbert}\mathrm{\text{'} against keyword \text{'}}\mathrm{hilbertspaces}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{disjointedspaces}}{=}\left\{\left\{{A}{,}{C}\right\}{,}\left\{{B}{,}{C}\right\}\right\}\right]$ (42)

where ${C}$ acts on the tensor product of the spaces where ${A}$ and ${B}$ act. An eigenstate of ${C}$ can then always be written as

 >
 ${\mathrm{Ket}}{}\left({C}{,}{m}{,}{n}\right){=}{\sum }_{{p}}{}{\sum }_{{j}}{}{{M}}_{{j}{,}{p}}{}{\mathrm{Ket}}{}\left({A}{,}{j}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{p}\right)$ (43)

where ${M}_{j,p}$ is a matrix of complex coefficients. Bra states of ${C}$ are formed as usual taking the Dagger

 > $\mathrm{Dagger}\left(\right)$
 ${\mathrm{Bra}}{}\left({C}{,}{m}{,}{n}\right){=}{\sum }_{{p}}{}{\sum }_{{j}}{}\stackrel{{&conjugate0;}}{{{M}}_{{j}{,}{p}}}{}{\mathrm{Bra}}{}\left({A}{,}{j}\right){\otimes }{\mathrm{Bra}}{}\left({B}{,}{p}\right)$ (44)

 • By definition, all states $\mathrm{Ket}\left(C,\mathrm{α},\mathrm{β}\right)$ that can be written exactly as $\mathrm{Ket}\left(A,\mathrm{α}\right)\otimes \mathrm{Ket}\left(B,\mathrm{β}\right)$, that is, the product of an arbitrary state of the subspace A and another of the subspace B, are product states, and all the other ones are entangled states. Entanglement is a property that is independent of the basis $\mathrm{Ket}\left(A,j\right)\otimes \mathrm{Ket}\left(B,p\right)$used in (43). The physical interpretation is the standard one: when the state of a system constituted by two subsystems A and B is represented by a product state, the properties of the subsystem A are well defined and all given by $\mathrm{Ket}\left(A,\mathrm{α}\right),$while those for the subsystem B by . When the system is in an entangled state one typically cannot assign definite properties to the individual subsystems A or B, each subsystem has no independent reality. To determine whether a state $\mathrm{Ket}\left(C,\mathrm{α},\mathrm{β}\right)$ is entangled it then suffices to check the rank R of the matrix ${M}_{j,p}$ (see LinearAlgebra:-Rank): when $R=1$ the state is a product state, otherwise it is an entangled state. When the state being analyzed belongs to the tensor product of two subspaces, $R=1$ is equivalent to having the determinant of ${M}_{j,p}$ equal to 0. The condition $R=1$, however, is more general, and suffices to determine whether a state is a product state also on a Hilbert space that is the tensor product of three or more subspaces: , in which case the matrix M will have more rows and columns and a determinant equal to 0 would only warrant the possibility of factorizing one Ket.

Example: the Bell basis for a system of two qubits

Consider a 2-dimensional space of states acted upon by the operator ${A}$, and let ${B}$ act upon another, disjointed, Hilbert space that is a replica of the Hilbert space on which ${A}$ acts. Set the dimensions of ${A}$, ${B}$ and ${C}$ respectively equal to 2, 2 and 2x2 (see Setup)

 >
 $\left[{\mathrm{quantumbasisdimension}}{=}\left\{{A}{=}{2}{,}{B}{=}{2}{,}{{C}}_{{1}}{=}{2}{,}{{C}}_{{2}}{=}{2}\right\}\right]$ (45)

The system C with the two subsystems A and B represents a two qubits system. The standard basis for C can be constructed in a natural way from the basis of Kets of A and B, $\left\{\mathrm{Ket}\left(A,0\right),\mathrm{Ket}\left(A,1\right),\mathrm{Ket}\left(B,0\right),\mathrm{Ket}\left(B,1\right)\right\}$, by taking their tensor products:

 > $\mathrm{seq}\left(\mathrm{seq}\left(\mathrm{Ket}\left(A,j\right)\cdot \mathrm{Ket}\left(B,k\right),k=0..1\right),j=0..1\right)$
 ${\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){,}{\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right){,}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){,}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right)$ (46)

Set a more mathematical display for the imaginary unit

 >

The four entangled Bell states also form a basis of C and are given by

 >
 $\mathrm{* Partial match of \text{'}}\mathrm{op}\mathrm{\text{'} against keyword \text{'}}\mathrm{quantumoperators}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{quantumoperators}}{=}\left\{{ℬ}{,}{A}{,}{B}{,}{C}{,}{E}\right\}\right]$ (47)
 >
 ${\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){=}\frac{{\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){+}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right)}{\sqrt{{2}}}$ (48)
 >
 ${\mathrm{Ket}}{}\left({ℬ}{,}{1}\right){=}\frac{{\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right){+}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right)}{\sqrt{{2}}}$ (49)
 >
 ${\mathrm{Ket}}{}\left({ℬ}{,}{2}\right){=}\frac{{i}{}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right){-}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right)}{\sqrt{{2}}}$ (50)
 >
 ${\mathrm{Ket}}{}\left({ℬ}{,}{3}\right){=}\frac{{\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){-}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right)}{\sqrt{{2}}}$ (51)

There is no standard convention for the four linear combinations of the right-hand sides above defining the Bell states. The convention used here relates to the definition of these states using the Pauli matrices as shown further below. Regardless of the convention used, the Bell basis is orthonormal. That can be verified by taking dot products, for example:

 >
 ${1}{=}{1}$ (52)

In steps, perform the same operation but using the star (*) operator, so that the contraction is represented but not performed

 >
 ${\mathrm{Bra}}{}\left({ℬ}{,}{0}\right){}{\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){=}\frac{\left({\mathrm{Bra}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Bra}}{}\left({B}{,}{0}\right){+}{\mathrm{Bra}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Bra}}{}\left({B}{,}{1}\right)\right){}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){+}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right)}{{2}}$ (53)

Evaluate now the result at * = ., that is transforming the star product into a dot product

 >
 ${1}{=}{1}$ (54)
 >
 ${\mathrm{Bra}}{}\left({ℬ}{,}{0}\right){}{\mathrm{Ket}}{}\left({ℬ}{,}{1}\right){=}\frac{\left({\mathrm{Bra}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Bra}}{}\left({B}{,}{0}\right){+}{\mathrm{Bra}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Bra}}{}\left({B}{,}{1}\right)\right){}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right){+}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right)}{{2}}$ (55)
 >
 ${0}{=}{0}$ (56)

The Bell basis and its relation with the Pauli matrices

The Bell basis can be constructed departing from $\mathrm{Ket}\left(ℬ,0\right)$ using the Pauli matrices ${{\mathrm{\sigma }}}_{j}$. For that purpose, using a Vector representation for $\mathrm{Ket}\left(A,j\right)$,

 >
 ${\mathrm{Ket}}{}\left({B}{,}{0}\right){=}\left[\begin{array}{c}{1}\\ {0}\end{array}\right]{,}{\mathrm{Ket}}{}\left({B}{,}{1}\right){=}\left[\begin{array}{c}{0}\\ {1}\end{array}\right]$ (57)

Multiplying $\mathrm{Ket}\left(B,0\right)$by each of the ${{\mathrm{\sigma }}}_{j}$ Pauli matrices and performing the matrix operations we have

 >
 $\left[{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{1}}{,}{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right){=}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{1}}{,}\left[\begin{array}{r}1\\ 0\end{array}\right]\right){,}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{2}}{,}{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right){=}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{2}}{,}\left[\begin{array}{r}1\\ 0\end{array}\right]\right){,}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{3}}{,}{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right){=}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{3}}{,}\left[\begin{array}{r}1\\ 0\end{array}\right]\right)\right]$ (58)
 > $\mathrm{Library}:-\mathrm{PerformMatrixOperations}\left(,\mathrm{only}=\mathrm{righthandsides}\right)$
 $\left[{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{1}}{,}{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right){=}\left(\left[\begin{array}{r}0\\ 1\end{array}\right]\right){,}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{2}}{,}{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right){=}\left(\left[\begin{array}{c}0\\ I\end{array}\right]\right){,}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{3}}{,}{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right){=}\left(\left[\begin{array}{r}1\\ 0\end{array}\right]\right)\right]$ (59)

In this result we see that ${{\mathrm{\sigma }}}_{1}$ and ${{\mathrm{\sigma }}}_{2}$ flip the state, transforming $\mathrm{Ket}\left(B,0\right)$ into $\mathrm{Ket}\left(B,1\right)$, ${{\mathrm{\sigma }}}_{2}$ also multiplies by the imaginary unit $i$, while ${{\mathrm{\sigma }}}_{3}$ leaves the state $\mathrm{Ket}\left(B,0\right)$unchanged.

We can express all that by removing from (59) the Vector representations shown in (57). For that purpose, create a list of substitution equations

 >
 $\left[\left(\left[\begin{array}{r}1\\ 0\end{array}\right]\right){=}{\mathrm{Ket}}{}\left({B}{,}{0}\right){,}\left(\left[\begin{array}{r}0\\ 1\end{array}\right]\right){=}{\mathrm{Ket}}{}\left({B}{,}{1}\right){,}\left(\left[\begin{array}{c}I\\ 0\end{array}\right]\right){=}{i}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right){,}\left(\left[\begin{array}{c}0\\ I\end{array}\right]\right){=}{i}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right]$ (60)

The action of ${{\mathrm{\sigma }}}_{j}$ in $\mathrm{Ket}\left(B,0\right)$is then given by

 > $\mathrm{Library}:-\mathrm{SubstituteMatrix}\left(,\right)$
 $\left[{{\mathrm{\sigma }}}_{{1}}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right){=}{\mathrm{Ket}}{}\left({B}{,}{1}\right){,}{{\mathrm{\sigma }}}_{{2}}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right){=}{i}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right){,}{{\mathrm{\sigma }}}_{{3}}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right){=}{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right]$ (61)

For , performing the same steps, the action of the Pauli matrices on it is

 >
 $\left[{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{1}}{,}{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right){=}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{1}}{,}\left[\begin{array}{r}0\\ 1\end{array}\right]\right){,}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{2}}{,}{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right){=}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{2}}{,}\left[\begin{array}{r}0\\ 1\end{array}\right]\right){,}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{3}}{,}{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right){=}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{3}}{,}\left[\begin{array}{r}0\\ 1\end{array}\right]\right)\right]$ (62)
 > $\mathrm{Library}:-\mathrm{PerformMatrixOperations}\left(,\mathrm{only}=\mathrm{righthandsides}\right)$
 $\left[{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{1}}{,}{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right){=}\left(\left[\begin{array}{r}1\\ 0\end{array}\right]\right){,}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{2}}{,}{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right){=}\left(\left[\begin{array}{c}-I\\ 0\end{array}\right]\right){,}{\mathrm{*}}{}\left({{\mathrm{Psigma}}}_{{3}}{,}{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right){=}\left(\left[\begin{array}{r}0\\ -1\end{array}\right]\right)\right]$ (63)
 > $\mathrm{Library}:-\mathrm{SubstituteMatrix}\left(,\right)$
 $\left[{{\mathrm{\sigma }}}_{{1}}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right){=}{\mathrm{Ket}}{}\left({B}{,}{0}\right){,}{{\mathrm{\sigma }}}_{{2}}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right){=}{-i}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right){,}{{\mathrm{\sigma }}}_{{3}}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right){=}{-}{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right]$ (64)

To obtain the other three Bell states using the results (61) and (64), indicate to the system that the Pauli matrices operate in the subspace where ${B}$ operates

 >
 $\mathrm{* Partial match of \text{'}}\mathrm{hilbert}\mathrm{\text{'} against keyword \text{'}}\mathrm{hilbertspaces}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{disjointedspaces}}{=}\left\{\left\{{A}{,}{C}\right\}{,}\left\{{B}{,}{C}{,}{\mathrm{\sigma }}\right\}\right\}\right]$ (65)

Multiplying $\mathrm{Ket}\left(ℬ,0\right)$ given in (48) by each of the three ${{\mathrm{\sigma }}}_{j}$ we get the other three Bell states

 > 
 ${\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){=}\frac{\sqrt{{2}}{}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){+}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right)}{{2}}$ (66)
 >
 ${{\mathrm{\sigma }}}_{{1}}{}{\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){=}\frac{\sqrt{{2}}{}{{\mathrm{\sigma }}}_{{1}}{}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){+}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right)}{{2}}$ (67)

Substitute in this result the first equations of (61) and (64)

 >
 ${{\mathrm{\sigma }}}_{{1}}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right){=}{\mathrm{Ket}}{}\left({B}{,}{1}\right){,}{{\mathrm{\sigma }}}_{{1}}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right){=}{\mathrm{Ket}}{}\left({B}{,}{0}\right)$ (68)
 > $\mathrm{map}\left(\mathrm{rhs}=\mathrm{lhs},\left[\right]\right)$
 $\left[{\mathrm{Ket}}{}\left({B}{,}{1}\right){=}{{\mathrm{\sigma }}}_{{1}}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right){,}{\mathrm{Ket}}{}\left({B}{,}{0}\right){=}{{\mathrm{\sigma }}}_{{1}}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right]$ (69)
 > $\mathrm{subs}\left(,\right)$
 ${{\mathrm{\sigma }}}_{{1}}{}{\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){=}\frac{\sqrt{{2}}{}{{\mathrm{\sigma }}}_{{1}}{}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){}{{\mathrm{\sigma }}}_{{1}}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right){+}{\mathrm{Ket}}{}\left({A}{,}{1}\right){}{{\mathrm{\sigma }}}_{{1}}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right)}{{2}}$ (70)
 > $\mathrm{factor}\left(\mathrm{Simplify}\left(\right)\right)$
 ${{\mathrm{\sigma }}}_{{1}}{}{\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){=}\frac{\sqrt{{2}}{}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right){+}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right)}{{2}}$ (71)

This is $\mathrm{Ket}\left(ℬ,1\right)$ defined in (49)

 > 
 ${\mathrm{Ket}}{}\left({ℬ}{,}{1}\right){=}\frac{\sqrt{{2}}{}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right){+}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right)}{{2}}$ (72)
 > $-$
 ${{\mathrm{\sigma }}}_{{1}}{}{\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){-}{\mathrm{Ket}}{}\left({ℬ}{,}{1}\right){=}{0}$ (73)

Multiplying now by ${{\mathrm{\sigma }}}_{2}$ and substituting $\mathrm{Ket}\left(B,j\right)$ using the ${2}^{\mathrm{nd}}$ equations of (61) and (64) we get $\mathrm{Ket}\left(ℬ,1\right)$

 >
 ${{\mathrm{\sigma }}}_{{2}}{}{\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){=}\frac{\sqrt{{2}}{}{{\mathrm{\sigma }}}_{{2}}{}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){+}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right)}{{2}}$ (74)
 >
 ${{\mathrm{\sigma }}}_{{2}}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right){=}{i}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right){,}{{\mathrm{\sigma }}}_{{2}}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right){=}{-i}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right)$ (75)
 > $\mathrm{zip}\left(\mathrm{isolate},\left[\right],\left[\mathrm{Ket}\left(B,1\right),\mathrm{Ket}\left(B,0\right)\right]\right)$
 $\left[{\mathrm{Ket}}{}\left({B}{,}{1}\right){=}{-i}{}{{\mathrm{\sigma }}}_{{2}}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right){,}{\mathrm{Ket}}{}\left({B}{,}{0}\right){=}{i}{}{{\mathrm{\sigma }}}_{{2}}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right]$ (76)
 > $\mathrm{factor}\left(\mathrm{Simplify}\left(\mathrm{subs}\left(,\right)\right)\right)$
 ${{\mathrm{\sigma }}}_{{2}}{}{\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){=}\frac{{i}}{{2}}{}\sqrt{{2}}{}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right){-}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right)$ (77)

The above is $\mathrm{Ket}\left(ℬ,2\right)$ defined in (50)

 > 
 ${\mathrm{Ket}}{}\left({ℬ}{,}{2}\right){=}\frac{{i}}{{2}}{}\sqrt{{2}}{}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right){-}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right)\right)$ (78)
 > $\mathrm{Expand}\left(-\right)$
 ${{\mathrm{\sigma }}}_{{2}}{}{\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){-}{\mathrm{Ket}}{}\left({ℬ}{,}{2}\right){=}{0}$ (79)

Finally, multiplying $\mathrm{Ket}\left(ℬ,2\right)$ by ${{\mathrm{\sigma }}}_{3}$

 >
 ${{\mathrm{\sigma }}}_{{3}}{}{\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){=}\frac{\sqrt{{2}}{}{{\mathrm{\sigma }}}_{{3}}{}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){+}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right)}{{2}}$ (80)

Substituting

 >
 ${{\mathrm{\sigma }}}_{{3}}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right){=}{\mathrm{Ket}}{}\left({B}{,}{0}\right){,}{{\mathrm{\sigma }}}_{{3}}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right){=}{-}{\mathrm{Ket}}{}\left({B}{,}{1}\right)$ (81)
 >
 ${\mathrm{Ket}}{}\left({B}{,}{0}\right){=}{{\mathrm{\sigma }}}_{{3}}{}{\mathrm{Ket}}{}\left({B}{,}{0}\right){,}{\mathrm{Ket}}{}\left({B}{,}{1}\right){=}{-}{{\mathrm{\sigma }}}_{{3}}{}{\mathrm{Ket}}{}\left({B}{,}{1}\right)$ (82)

We get 

 > $\mathrm{factor}\left(\mathrm{Simplify}\left(\mathrm{subs}\left(,\right)\right)\right)$
 ${{\mathrm{\sigma }}}_{{3}}{}{\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){=}\frac{\sqrt{{2}}{}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){-}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right)}{{2}}$ (83)

which is $\mathrm{Ket}\left(ℬ,3\right)$

 > 
 ${\mathrm{Ket}}{}\left({ℬ}{,}{3}\right){=}\frac{\sqrt{{2}}{}\left({\mathrm{Ket}}{}\left({A}{,}{0}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{0}\right){-}{\mathrm{Ket}}{}\left({A}{,}{1}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{1}\right)\right)}{{2}}$ (84)
 > $\mathrm{Expand}\left(-\right)$
 ${{\mathrm{\sigma }}}_{{3}}{}{\mathrm{Ket}}{}\left({ℬ}{,}{0}\right){-}{\mathrm{Ket}}{}\left({ℬ}{,}{3}\right){=}{0}$ (85)

Reset the symbol representing imaginary unit to use i as an index in the next section

 >

Entangled States, Operators and Projectors

Consider a fourth operator, ${H}$, that is Hermitian and acts on the same space of ${C}$, has the same dimension, and $\mathrm{ℋ},\mathrm{ℍ}$ are its mean values in an entangled and product states respectively.

 >
 $\mathrm{* Partial match of \text{'}}\mathrm{hermitian}\mathrm{\text{'} against keyword \text{'}}\mathrm{hermitianoperators}\text{'}$
 $\mathrm{* Partial match of \text{'}}\mathrm{basisdimension}\mathrm{\text{'} against keyword \text{'}}\mathrm{quantumbasisdimension}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{disjointedspaces}}{=}\left\{\left\{{A}{,}{C}{,}{H}\right\}{,}\left\{{B}{,}{C}{,}{H}\right\}{,}\left\{{B}{,}{C}{,}{\mathrm{\sigma }}\right\}\right\}{,}{\mathrm{hermitianoperators}}{=}\left\{{H}\right\}{,}{\mathrm{quantumbasisdimension}}{=}\left\{{A}{=}{2}{,}{B}{=}{2}{,}{{C}}_{{1}}{=}{2}{,}{{C}}_{{2}}{=}{2}{,}{{H}}_{{1}}{=}{2}{,}{{H}}_{{2}}{=}{2}\right\}{,}{\mathrm{realobjects}}{=}\left\{{ℍ}{,}{ℋ}{,}{x}{,}{y}{,}{z}\right\}\right]$ (86)

To operate in a practical way with these operators, Bras and Kets, bracket rules reflecting their relationship are necessary. From the definition of ${C}$ as acting on the tensor product of spaces where ${A}$ and ${B}$ act (see (43)) and taking into account the dimensions specified for ${A}$, ${B}$ and ${C}$ we have

 >
 ${\mathrm{Ket}}{}\left({C}{,}{a}{,}{b}\right){=}{\sum }_{{p}{=}{0}}^{{1}}{}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\sum }_{{j}{=}{0}}^{{1}}{}{{M}}_{{a}{,}{j}{,}{b}{,}{p}}{}{\mathrm{Ket}}{}\left({A}{,}{j}\right){\otimes }{\mathrm{Ket}}{}\left({B}{,}{p}\right)$ (87)
 > $\mathrm{Bra}\left(A,k\right)·$
 ${\mathrm{Bracket}}{}\left({\mathrm{Bra}}{}\left({A}{,}{k}\right){,}{\mathrm{Ket}}{}\left({C}{,}{a}{,}{b}\right)\right){=}{\sum }_{{p}{=}{0}}^{{1}}{}{{M}}_{{a}{,}{k}{,}{b}{,}{p}}{}{\mathrm{Ket}}{}\left({B}{,}{p}\right)$ (88)
 > $\mathrm{Bra}\left(B,k\right)·$
 ${\mathrm{Bracket}}{}\left({\mathrm{Bra}}{}\left({B}{,}{k}\right){,}{\mathrm{Ket}}{}\left({C}{,}{a}{,}{b}\right)\right){=}{\sum }_{{j}{=}{0}}^{{1}}{}{{M}}_{{a}{,}{j}{,}{b}{,}{k}}{}{\mathrm{Ket}}{}\left({A}{,}{j}\right)$ (89)
 >
 ${\mathrm{Bra}}{}\left({A}{,}{k}\right){}{\mathrm{Bracket}}{}\left({\mathrm{Bra}}{}\left({B}{,}{l}\right){,}{\mathrm{Ket}}{}\left({C}{,}{a}{,}{b}\right)\right){=}{{M}}_{{a}{,}{k}{,}{b}{,}{l}}$ (90)

The bracket rules for ${A}$, ${B}$ and ${C}$ are the first two of these; Set these rules, so that the system can take them into account

 >
 $\left[{\mathrm{bracketrules}}{=}\left\{{\mathrm{%Bracket}}{}\left({\mathrm{%Bra}}{}\left({A}{,}{k}\right){,}{\mathrm{%Ket}}{}\left({C}{,}{a}{,}{b}\right)\right){=}{\mathrm{Sum}}{}\left({{M}}_{{a}{,}{k}{,}{b}{,}{p}}{}{\mathrm{Ket}}{}\left({B}{,}{p}\right){,}{p}{=}{0}{..}{1}\right){,}{\mathrm{%Bracket}}{}\left({\mathrm{%Bra}}{}\left({B}{,}{k}\right){,}{\mathrm{%Ket}}{}\left({C}{,}{a}{,}{b}\right)\right){=}{\mathrm{Sum}}{}\left({{M}}_{{a}{,}{j}{,}{b}{,}{k}}{}{\mathrm{Ket}}{}\left({A}{,}{j}\right){,}{j}{=}{0}{..}{1}\right)\right\}\right]$ (91)

If we now recompute (90), the left-hand side is also computed

 >
 ${{M}}_{{a}{,}{k}{,}{b}{,}{l}}{=}{{M}}_{{a}{,}{k}{,}{b}{,}{l}}$ (92)

Suppose now that you want to compute with the Hermitian operator ${H}$, that operates on the same space as ${C}$, both using C and the operators ${A}$ and ${B}$, as in

$\mathrm{Bracket}\left(\mathrm{Bra}\left(C,I,j\right),H,\mathrm{Ket}\left(C,k,l\right)\right)={\mathrm{ℋ}}_{i,j,k,l}$

$\mathrm{Bra}\left(A,I\right)\otimes \mathrm{Bra}\left(B,j\right){H}\mathrm{Ket}\left(A,k\right)\otimes \mathrm{Ket}\left(B,l\right)={\mathrm{ℍ}}_{\mathit{i}\mathit{,}j,k,l}$

where ${\mathrm{ℋ}}_{i,j,k,l}$ = ${\mathrm{ℍ}}_{\mathit{i}\mathit{,}j,k,l}$ when $\mathrm{Ket}\left(C,a,b\right)$ is a product (not entangled) state.

To compute taking into account $\mathrm{Bracket}\left(\mathrm{Bra}\left(C,I,j\right),H,\mathrm{Ket}\left(C,k,l\right)\right)={\mathrm{ℋ}}_{\mathit{i}\mathit{,}j,k,l}$ it suffices to set a bracket rule

 >
 $\mathrm{* Partial match of \text{'}}\mathrm{real}\mathrm{\text{'} against keyword \text{'}}\mathrm{realobjects}\text{'}$
 $\mathrm{_______________________________________________________}$
 $\left[{\mathrm{bracketrules}}{=}\left\{{\mathrm{%Bracket}}{}\left({\mathrm{%Bra}}{}\left({A}{,}{k}\right){,}{\mathrm{%Ket}}{}\left({C}{,}{a}{,}{b}\right)\right){=}{\mathrm{Sum}}{}\left({{M}}_{{a}{,}{k}{,}{b}{,}{p}}{}{\mathrm{Ket}}{}\left({B}{,}{p}\right){,}{p}{=}{0}{..}{1}\right){,}{\mathrm{%Bracket}}{}\left({\mathrm{%Bra}}{}\left({B}{,}{k}\right){,}{\mathrm{%Ket}}{}\left({C}{,}{a}{,}{b}\right)\right){=}{\mathrm{Sum}}{}\left({{M}}_{{a}{,}{j}{,}{b}{,}{k}}{}{\mathrm{Ket}}{}\left({A}{,}{j}\right){,}{j}{=}{0}{..}{1}\right){,}{\mathrm{%Bracket}}{}\left({\mathrm{%Bra}}{}\left({C}{,}{a}{,}{b}\right){,}{H}{,}{\mathrm{%Ket}}{}\left({C}{,}{c}{,}{d}\right)\right){=}{{ℋ}}_{{a}{,}{b}{,}{c}{,}{d}}\right\}{,}{\mathrm{realobjects}}{=}\left\{{ℍ}{,}{ℋ}{,}{x}{,}{y}{,}{z}\right\}\right]$ (93)

After that,

 > $\mathrm{Bra}\left(C,j,k\right)·{H}·\mathrm{Ket}\left(C,m,n\right)$
 ${{ℋ}}_{{j}{,}{k}{,}{m}{,}{n}}$ (94)

Regarding $\mathrm{Bra}\left(A,I\right)\otimes \mathrm{Bra}\left(B,j\right){H}\mathrm{Ket}\left(A,k\right)\otimes \mathrm{Ket}\left(B,l\right)=\mathrm{ℍ}{}_{\mathit{i}\mathit{,}j,k,l}$, since ${H}$ belongs to the tensor product of spaces A and B, it can be an entangled operator, one that you cannot represent just as a product of one operator acting on A times another one acting on B. A computational representation for the operator $\mathrm{Bra}\left(B,j\right){H}\mathrm{Ket}\left(A,k\right)$ (that is not just itself or as abstract) is not possible in the general case. For that you can use a different feature: define the action of the operator ${H}$ on Kets of ${A}$ and ${B}$.

Basically, we want:

A program sketch for that would be:

if H is applied to a Ket of A or B and it still has not 4 indices then

if H itself is indexed then
return H with its indices followed by the index of the Ket
else

return H indexed by the index of the Ket;
otherwise
return the dot product operation uncomputed, unevaluated

In the Maple language (see sec. 1.4) that program-sketch becomes

 >

Let's see it in action. Start by erasing the Physics performance remember tables, which remember results computed before the definition of ${H}$

 > $\mathrm{Library}:-\mathrm{Forget}\left(\right)$
 > ${H}·\mathrm{Ket}\left(A,k\right)$
 ${{H}}_{{k}}$ (95)

Recalling that ${H}$ is Hermitian,

 > $\mathrm{Bra}\left(B,j\right)·{H}$
 ${{H}}_{{j}}$ (96)
 > $\mathrm{Bra}\left(B,j\right)·{H}·\mathrm{Ket}\left(A,k\right)$
 ${{H}}_{{j}{,}{k}}$ (97)
 > $\mathrm{Bra}\left(B,j\right)·{H}·\mathrm{Ket}\left(A,k\right)·\mathrm{Ket}\left(B,l\right)$
 ${{H}}_{{j}{,}{k}{,}{l}}$ (98)
 > $\mathrm{Bra}\left(A,i\right)·\mathrm{Bra}\left(B,j\right)·{H}·\mathrm{Ket}\left(A,k\right)·\mathrm{Ket}\left(B,l\right)$
 ${{ℍ}}_{{i}{,}{j}{,}{k}{,}{l}}$ (99)

Note that the definition of ${H}$ as a procedure does not interfere with the setting of a bracket rule for it with $\mathrm{Ket}\left(C,a,b\right)$, that is still working

 > $\mathrm{Bra}\left(C,i,j\right)·{H}·\mathrm{Ket}\left(C,k,l\right)$
 ${{ℋ}}_{{i}{,}{j}{,}{k}{,}{l}}$ (100)

where H = H when $\mathrm{Ket}\left(C,k,l\right)$ is a product state. The definition of H takes precedence, so if in that definition you indicate what to do with a ${C}$ Ket, that will be taken into account before the bracket rule.

 • You can set the projectors for all these operators / spaces. For example,
 >
 $\mathrm{𝕀__A}{≔}{\sum }_{{i}{=}{0}}^{{1}}{}{\mathrm{Ket}}{}\left({A}{,}{i}\right){}{\mathrm{Bra}}{}\left({A}{,}{i}\right)$
 $\mathrm{𝕀__B}{≔}{\sum }_{{i}{=}{0}}^{{1}}{}{\mathrm{Ket}}{}\left({B}{,}{i}\right){}{\mathrm{Bra}}{}\left({B}{,}{i}\right)$
 $\mathrm{𝕀__C}{≔}{\sum }_{{b}{=}{0}}^{{1}}{}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\sum }_{{a}{=}{0}}^{{1}}{}{\mathrm{Ket}}{}\left({C}{,}{a}{,}{b}\right){}{\mathrm{Bra}}{}\left({C}{,}{a}{,}{b}\right)$ (101)

Since the algebra rules for computing with eigenkets of ${A}$, ${B}$ and ${C}$ were already set in (91), from the projectors above you can construct any subspace projector, for example

 >
 ${\sum }_{{b}{=}{0}}^{{1}}{}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\sum }_{{a}{=}{0}}^{{1}}{}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\sum }_{{p}{=}{0}}^{{1}}{}{{M}}_{{a}{,}{m}{,}{b}{,}{p}}{}{\mathrm{Ket}}{}\left({B}{,}{p}\right){}{\mathrm{Bra}}{}\left({C}{,}{a}{,}{b}\right)$ (102)
 >
 ${\sum }_{{b}{=}{0}}^{{1}}{}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\sum }_{{a}{=}{0}}^{{1}}{}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\sum }_{{p}{=}{0}}^{{1}}{}\stackrel{{&conjugate0;}}{{{M}}_{{a}{,}{m}{,}{b}{,}{p}}}{}{\mathrm{Ket}}{}\left({C}{,}{a}{,}{b}\right){}{\mathrm{Bra}}{}\left({B}{,}{p}\right)$ (103)

The conjugate of ${M}_{a,m,b,p}$ is due to the contraction or attachment from the right of (102), that is with

 > $\mathrm{Dagger}\left(\right)$
 ${\mathrm{Bra}}{}\left({C}{,}{a}{,}{b}\right){=}{\sum }_{{p}{=}{0}}^{{1}}{}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\sum }_{{j}{=}{0}}^{{1}}{}\stackrel{{&conjugate0;}}{{{M}}_{{a}{,}{j}{,}{b}{,}{p}}}{}{\mathrm{Bra}}{}\left({A}{,}{j}\right){\otimes }{\mathrm{Bra}}{}\left({B}{,}{p}\right)$ (104)

The coefficients ${M}_{a,m,b,p}$ satisfy constraints due to the normalization of Kets of ${A}$ and ${B}$. One can derive these constraints by inserting the unit operator $\mathrm{𝕀__C}$ in the identity

 > $\mathrm{Bra}\left(A,m\right)·\mathrm{Bra}\left(B,n\right)·\mathrm{𝕀__C}·\mathrm{Ket}\left(A,r\right)·\mathrm{Ket}\left(B,s\right)=\mathrm{Bra}\left(A,m\right)·\mathrm{Bra}\left(B,n\right)·\mathrm{Ket}\left(A,r\right)·\mathrm{Ket}\left(B,s\right)$
 ${\sum }_{{b}{=}{0}}^{{1}}{}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\sum }_{{a}{=}{0}}^{{1}}{}\stackrel{{&conjugate0;}}{{{M}}_{{a}{,}{r}{,}{b}{,}{s}}}{}{{M}}_{{a}{,}{m}{,}{b}{,}{n}}{=}{{\mathrm{\delta }}}_{{m}{,}{r}}{}{{\mathrm{\delta }}}_{{n}{,}{s}}$ (105)

Transform this result into a function P  to explore the identity further

 >
 ${P}{≔}\left({m}{,}{n}{,}{r}{,}{s}\right){↦}{\sum }_{{b}{=}{0}}^{{1}}{}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\sum }_{{a}{=}{0}}^{{1}}{}\stackrel{{&conjugate0;}}{{{M}}_{{a}{,}{r}{,}{b}{,}{s}}}{}{{M}}_{{a}{,}{m}{,}{b}{,}{n}}{=}{{\mathrm{\delta }}}_{{m}{,}{r}}{}{{\mathrm{\delta }}}_{{n}{,}{s}}$ (106)

The first and third indices refer to the quantum numbers of ${A}$, the second and fourth to ${B}$, so the right-hand sides in the following are respectively 1 and 0

 > $P\left(1,0,1,0\right)$
 $\stackrel{{&conjugate0;}}{{{M}}_{{0}{,}{1}{,}{0}{,}{0}}}{}{{M}}_{{0}{,}{1}{,}{0}{,}{0}}{+}\stackrel{{&conjugate0;}}{{{M}}_{{1}{,}{1}{,}{0}{,}{0}}}{}{{M}}_{{1}{,}{1}{,}{0}{,}{0}}{+}\stackrel{{&conjugate0;}}{{{M}}_{{0}{,}{1}{,}{1}{,}{0}}}{}{{M}}_{{0}{,}{1}{,}{1}{,}{0}}{+}\stackrel{{&conjugate0;}}{{{M}}_{{1}{,}{1}{,}{1}{,}{0}}}{}{{M}}_{{1}{,}}$