SlideShare a Scribd company logo
1 of 60
Download to read offline
Spinor Quantum Simulator User Guide
Copyright Notice
Spinor Quantum Simulator and User Guide © 2021 Dr Russell John Childs, PhD.
All rights reserved.
This user guide and associated quantum simulator, tradename “Spinor Quantum Simulator”, were
wholly developed and are wholly owned by Dr Russell John Childs, PhD.
Table of Contents
Copyright Notice..................................................................................................................................1
Spinor Quantum Simulator and User Guide © 2021 Dr Russell John Childs, PhD........................1
Section 1: Introduction.........................................................................................................................4
1.1 Goal............................................................................................................................................4
1.2 Spinors and Direct support for Dirac notation...........................................................................4
1.2.1 Example.............................................................................................................................4
1.3 Column and row vectors............................................................................................................4
1.4 Inner products............................................................................................................................4
1.5 Matrices.....................................................................................................................................4
1.6 States..........................................................................................................................................5
1.7 Generalisation............................................................................................................................5
1.8 Illustrating Dirac notation for a matrix and vectors...................................................................5
1.9 Real-world example of using the simulator to solve a mathematical problem..........................5
1.10 Multiplying dissimilar matrices and vectors............................................................................6
1.11 Spinors as elements of geometry..............................................................................................7
1.12 Entanglement...........................................................................................................................7
1.13 Factorisation of state vectors and operators.............................................................................7
1.14 Support for un-normalised spinors. ........................................................................................8
1.15 Support for Geometric Algebra, metric tensors and matrix decomposition............................8
1.16 Solutions to eigenvalue problems............................................................................................9
1.17 Equations developed for this simulator....................................................................................9
1.18 Teaching quantum mechanics in high schools.........................................................................9
Section 2: Definitions and syntax.......................................................................................................10
2.1 Amplitudes...............................................................................................................................10
2.2 States........................................................................................................................................10
2.3 Bras..........................................................................................................................................10
2.4 Kets..........................................................................................................................................10
2.5 Outer Products.........................................................................................................................10
2.6 State Vectors.............................................................................................................................10
2.7 Operators..................................................................................................................................10
2.8 Tensor Products and sums of tensor products..........................................................................10
2.9 Inner products..........................................................................................................................11
2.10 Conjugate transpose...............................................................................................................11
2.11 Measurement and collapse.....................................................................................................11
2.11.1 Entangling a measuring device.......................................................................................11
2.12 Geometric Algebra and matrix decomposition......................................................................12
2.12.1 Creating basis vectors....................................................................................................12
2.12.1 Creating a multivector....................................................................................................12
2.12.2 Selecting grades.............................................................................................................12
1/60
2.12.3 Decomposing matrices...................................................................................................13
2.13 General Geometric Algebra commands.................................................................................13
Section 3: Functions...........................................................................................................................15
3.1 Norm: _|(...)|_...........................................................................................................................15
3.2 Tensor power (“^_X” and “P”)...............................................................................................15
3.3 Trace.........................................................................................................................................15
3.4 Commutators and anticommutators.........................................................................................15
3.5 Eigendecomposition.................................................................................................................15
3.6 Matrix exponential and other functions...................................................................................15
3.7 Relational operations...............................................................................................................16
3.8 Combining additions................................................................................................................16
3.9 Printing state vector and operators...........................................................................................16
3.9.1 Converting to vectors, matrices and Octave....................................................................16
3.10 Running Octave.....................................................................................................................16
3.11 Random numbers...................................................................................................................16
Section 4: Gates..................................................................................................................................17
4.1 Standard gates (X, Y, Z, H, T, S, R()) and the truth_table command......................................17
4.2 SWAP.......................................................................................................................................17
4.3 Controlled-U............................................................................................................................17
Section 5: Creating and debugging quantum algorithms...................................................................19
5.1 Adding measurements..............................................................................................................19
5.2 Debugging................................................................................................................................19
5.3 Coding example – 3 qubit Quantum Fourier Transform..........................................................20
Section 6: Header files and namespaces.............................................................................................23
Section 7: Miscellaneous....................................................................................................................24
7.1 Testing......................................................................................................................................24
7.2 Conventions.............................................................................................................................24
7.2.1 Qubit left-to-right numbering...........................................................................................24
7.2.2 Inner product convention for kets and bras......................................................................24
7.3 Ongoing and future development............................................................................................24
7.4 Rounding errors.......................................................................................................................25
7.4.1 Display precision..............................................................................................................25
7.4.2 Exploiting rounding errors...............................................................................................25
Section 8: Tutorial - Introduction to Quantum Mechanics.................................................................26
8.1 Qubits, spinors and higher dimensional Hilbert spaces...........................................................26
8.2 Pauli matrices and SU(2).........................................................................................................27
8.2.1 Coding Example: Spinors................................................................................................27
8.3 Rotations..................................................................................................................................29
8.3.1 Euler rotations..................................................................................................................29
8.3.2 Coding example: SU(2) rotations using spinors..............................................................29
8.4 Hyperbolic rotations and Special Relativity............................................................................31
8.4.1 Hyperbolic rotations.........................................................................................................32
8.5 Dirac matrices, Dirac equation and Special Relativity............................................................33
8.5.1 Coding Example: Time-dilation, Lorentz contraction and E=mc-squared using spinors34
8.5.2 Spatial rotations of Dirac spinors.....................................................................................35
8.5.3 The Pauli-Lubanski “vector”, helicity, the Higgs and mass.............................................36
8.6 Rotations on non-entangled and entangled systems................................................................37
8.6.1 Disentangling qubits........................................................................................................37
8.7 Energy and momentum............................................................................................................37
8.8 Measurements and observables...............................................................................................38
8.9 Heisenberg versus Schrödinger picture...................................................................................39
2/60
8.10 Classical mechanics versus quantum mechanics...................................................................39
8.10.1 The issue of superpositions and the “measurement problem”.......................................39
8.10.2 Coding Example: Bell's inequality using Monte-Carlo simulation...............................40
8.10.3 Coding Example: The double-slit using Monte-Carlo simulation.................................44
8.11 Addition of angular momentum and Clebsch-Gordan coefficients.......................................47
8.11.1 Coding Example: Adding two spin-1/2..........................................................................47
Section 9: Introduction to Geometric Algebra, Real and Complex Clifford Algebra........................49
9.1 Inner product............................................................................................................................49
9.2 Outer product...........................................................................................................................49
9.3 Geometric product...................................................................................................................49
9.4 Blades, k-vectors, grades and multivectors.............................................................................49
9.5 Multivector operations.............................................................................................................50
9.6 Even and odd dimensions........................................................................................................51
9.6.1 Coding Example 2D versus 3D........................................................................................52
9.7 Grade involution......................................................................................................................52
9.8 Matrix decomposition and grade operations............................................................................53
9.9 Blade and multvector inverses.................................................................................................53
9.10 General multivector functions and eigendecomposition.......................................................53
9.11 Rotations................................................................................................................................54
9.11.1 Coding Example: Rotation in X-Y plane and transcendental functions of a multivector.
...................................................................................................................................................54
9.12 Reflections.............................................................................................................................55
9.12.1 Reflection of a matrix without decomposition into a multivector..................................55
9.12.2 Coding Example: Reflection of a matrix without decomposition into a multivector....56
9.13 Contractions and projections.................................................................................................58
9.13.1 Coding Example: Left contraction.................................................................................58
9.13.2 Coding Example: Right contraction...............................................................................58
9.13.3 Coding Example: Projection and rejection....................................................................59
9.14 Clifford algebras....................................................................................................................60
3/60
Section 1: Introduction
1.1 Goal.
The goal in developing this simulator is to minimise the amount of coding required to run
quantum mechanical equations that have been reduced to bras, kets, and unitary and Hermitian
operators in Dirac notation, allowing physicists to concentrate on physics rather than the code.
1.2 Spinors and Direct support for Dirac notation.
This simulator uses C++ operator-overloading to compile Dirac notation directly, without the
need to convert equations to computer code that serves only to obfuscate. Equations are
simplified and executed using Group Theory to provide higher efficiency. Gate primitives are
provided, along with functions such as trace, eigen-decomposition and Geometric (Clifford)
Algebra representations. C++, C++11, C++17 and C++20 were used to develop this simulator.
1.2.1 Example.
A small example suffices to illustrate how to write Dirac notation that is directly compilable:
auto matrix=((1.0il)|0_3>_<0_1|_+_|1_3>_<1_1|_)*(_|0_1>_<0_2|_+(2.0il)|0_1>_<3_2|_);
This “creates” a non-square 2
4
×2
3
matrix, ∑i=0, j=0
i=15, j=7
cij∣i〉〈 j∣ , from the tensor product,
denoted by * , of 2
3
×2
1
and 2
1
×2
2
matrices, where cij is a complex number
residing in the i
th
row and j
th
column. The underscores only serve to satisfy the C++
compiler, which requires two operands for ∣, < and > and to signify the number, N , of
qubits, denoted _ N in the binary number, e.g. “2_3”->“010” and “5_3”->“101”. This
compact notation eliminates zero-elements and the simulator can further simplify large
matrices by factorising them into the tensor product of far smaller matrices, leading to faster
matrix multiplication. This also applies to vectors, in a similar fashion,
∑i=0
2
n−1
∣i 〉→(∣0〉+∣1〉)
⊗n
≡(∣0〉+∣1〉)0⊗⋯⊗(∣0〉+∣1〉)n−1 . Spinors correspond to linear
combinations of the qubits ∣0〉 and ∣1〉 and their conjugates 〈0∣ and 〈1∣ , from which
the Pauli matrices of quantum mechanics are created, which have a direct relationship to
quaternions and geometric algebra. The ∣i〉 are called “kets” and their conjugates 〈i∣ are
called “bras”. They correspond to column and row vectors, where 0≤i≤2
n−1
is a binary
number giving the row or column in a 2
n
-dimensional complex “vector”. We shall use the
word “spinor” to denote both qubits and their linear combinations.
1.3 Column and row vectors.
Dirac notation simplifies quantum mechanics and simulations. Vectors are denoted by
A=
(
α0
:
αn−1
)→∣ψ〉=∑i=0
n−1
αi∣i〉 and B=(β0 ... βn−1)→〈ψ'∣=∑i=0
n−1
〈i∣βi≡(∑i=0
n−1
βi
*
∣i 〉)
†
.
1.4 Inner products.
An inner product is denoted by
B⋅A=∑i=0
n−1
βiαi=〈ψ'∣ψ 〉=∑i=0, j=0
i=n−1, j=n−1
βi αj 〈i∣ j〉⇒〈i∣ j〉=δij : δij≡0iff i≠ j ,1iff i= j .
1.5 Matrices.
Matrix elements are denoted M ij=mij∣i〉〈 j∣⇒
{M⋅A=(∑ij
mij∣i〉〈 j∣)(∑k
αk∣k 〉)=∑ij
mij α j∣j 〉
B⋅M =(∑i
〈k∣βk)(∑ji
m ji∣j〉〈i∣)=∑ji
〈 j∣βj mji
.
4/60
1.6 States.
Each state ∣i〉 can be simplified as a tensor product of the simplest possible states ∣0〉 and
∣1〉 , for example: a∣2〉+b∣3〉=a
∣ 10
⏟
2in binary 〉+b
∣ 11
⏟
3in binary〉=a ∣1〉⊗∣0〉
⏟
tensor product of∣1〉and∣0〉
+b∣1〉⊗∣1〉 and
similarly for row vectors and matrices, s.t.
〈i0 ...in−1
⏟
i
∣j0... jn−1
⏟
j
〉=δi0 j0
...δin−1 jn−1
where
iμ∈{0,1}, jν∈{0,1} are μ
th
, ν
th
bits of i , j in the binary representation.
1.7 Generalisation.
Splitting matrices and operators into spinors brings many advantages, in allowing quantum
mechanics to be built from spinors: ∣0〉 , ∣1〉 , 〈0∣ , 〈1∣ and complex numbers,
mij ,α ,β , although “digitising” spacetime, ∣x ,t 〉→∣x0 ... xn−1 ,t0...tn−1〉 , breaks Lorentz
Invariance, requiring a modified approach. The tutorial section “Introduction to quantum
mechanics” will show the reader how Pauli matrices and spinors can perform rotations, Dirac
matrices and spinors can be used to do Special Relativity and how the De Broglie relations can
be justified by considering how the Fourier transformation of a probability distribution extending
over spacetime behaves under Special Relativity. It also includes examples of how to use the
simulator to demonstrate Bell's inequality and the double-slit experiment.
Finally, spinors are quite general and can be used to create any vector or matrix, including those
outside of quantum mechanics, and this simulator supports non-Unitary/Hermitian/square
matrices and operations such as:
(M =∑i=0, j=0, k=0
i=I −1, j=J −1, k=K−1
mijk∣i〉〈 j∣⊗〈k∣
⏟
I× N
⏟
J×K
≠I non-square matrix≡I ×N OR I ×J ×K )(∑j=0
J −1
αj∣j〉)
⏟
J ×1vector
=∑i=0, j=0, k=0
i=I −1, j=J −1,k=K −1
mijk αj∣i 〉〈k∣
⏟
I×K matrix
.
1.8 Illustrating Dirac notation for a matrix and vectors.
A simple illustration shows how to interpret Dirac notion in terms of a row vector, matrix and
column vector:
(〈0∣1,〈1∣2,〈2∣0)
⏟
〈00∣1+〈01∣2
⏞
row vector
(
0∣00〉〈00∣ 1∣00〉〈01∣ 0∣00〉〈10∣
0∣01〉〈00∣ 4∣01〉〈01∣ 0∣01〉〈10∣
6∣10〉〈00∣ 0∣10〉〈01∣ 8∣10〉〈10∣)
⏟
1∣00〉 〈01∣+4∣01〉〈01∣+6∣10〉〈00∣+8∣10〉 〈10∣
⏞
matrix
(
0∣0〉
3∣1〉
5∣2〉)}3∣1〉+5∣2〉
⏞
column vector
We see the operators ignore zero-elements. They can represent jagged matrices and allow
operations that would be disallowed using matrices. Operators free us from matrices and vectors
when we can work with individual elements. The astute reader may have noticed that the
3×3 matrix above can be interpreted as a 4×4 matrix with the last row and column zeroed
out. This type of flexibility allows us to decompose a matrix into other matrices of a different
dimension, in ways that would normally be disallowed were we restricted to working with
matrices and vectors.
1.9 Real-world example of using the simulator to solve a mathematical
problem.
The Pauli matrices are 2×2 matrices given by σ1=∣0〉〈1∣+∣1〉〈0∣ , σ2=−i∣0〉〈1∣+i∣1〉〈0∣
σ3=∣0〉〈0∣−∣1〉〈1∣ . We are given a 4×4 matrix: M =∑i=1, j =i+1
i=3, j =3
aij σi⊗σ j , with aij
5/60
and σi ,σj unknown and we want the coefficients aij . We can solve this problem by noting
that the anti-commutator {σi ,σ j}:=σi σ j+σ j σi=2δij , so that:
aij=
∣∣1
2 {1
2
{M ,σi⊗I }, I⊗σ j}∣∣HS
∣
∣σ∣
∣HS
2
=
∣∣aij δij⊗δij∣∣HS
∣
∣σ∣
∣HS
2
. Here we are double-matching, on σi to
the left and σ j to the right, and getting rid of the ∣∣σi⊗σ j∣
∣HS
norm, to give us aij . We
could also have done it using traces, since tr (σ)=0 tr (δij )=2 , so
tr(σi σ j)=
{0 iff i≠ j
2 iff i= j
We now write this into the simulator:
//The solution
auto solution=[](auto sig_i, auto sig_j, auto M)
{
return (_|_({_({M,sig_i*I}),I*sig_j})/4|_)/(_|sig_i|_^2);
};
The test code then creates a matrix and verifies that the coefficients are extracted:
//(1) Use simulator's geometric algebra package to create Pauli matrices
// _3D_ defines 3D space, Euclidean metric is just the 3X3 identity
auto e= _3D_[_|00_2>_<00_2|_+_|01_2>_<01_2|_+_|10_2>_<10_2|_];
//(2) Loop over all combinations sig_i sig_j and sum
Oper<2,2> op;
for(auto [i,j]:std::vector<std::pair<size_t,size_t>>{{1,2},{1,3},{2,3}})
{
//(3) Create tensor of form 12*sig_1*sig2 + 23*sig_2*sig_3 ...
op+=(10*i+j)*e[i].oper()*e[j].oper();
}
//(4) Loop over sig_i sig_j
for(auto [i,j]:std::vector<std::pair<size_t,size_t>>{{1,2},{1,3},{2,3}})
{
//(5) Print out components
auto result=solution(e[i].oper(),e[j].oper(),op);
std::cout << "(e[" << i << "]*e[" << j << "]).(op)=" << result
<< std::endl;
}
This is the output:
(e[1]*e[2]).(op)=(12+0i)
(e[1]*e[3]).(op)=(13+0i)
(e[2]*e[3]).(op)=(23+0i)
1.10 Multiplying dissimilar matrices and vectors
The main advantage to using spinors over vectors and matrices is that spinors do not care about
the vector or matrix to which they belong, allowing us to do operations that would be forbidden
if we stuck with matrices. As an example, Pauli matrices are 2×2 and Dirac matrices are
4×4 . Ordinarily, we would need both to be of the same dimensions in order to multiply
them. With operators, however, we need only recognise that (〈i∣) (∣ j k 〉)=δij∣k 〉 , for example:
(〈0∣)
⏟
2-vector
(∣01〉)
⏟
4−vector
= ∣1〉
⏟
2−vector
. Multiplying a 2×2 into a 4×4 , element-by-element, then
becomes possible, for example, (∣1〉〈0∣)
⏟
2×2
(∣01〉〈11∣)
⏟
4×4
=(∣11〉〈11∣)
⏟
4×4
.
This can be made clearer using tensor products: σx (σx⊗σy )=I⊗σy≡(σx σx)⊗σy . More
generally, we can also pad matrices so that they look to be of the same dimension:
6/60
a0,0∣00〉〈00∣+⋯+a2,2∣01〉〈01∣
⏟
3×3
≡a0,0∣00〉〈00∣+⋯+a3,3∣11〉〈11∣
⏟
4×4
,ai, 3=a3,i=0∀i , which
operators do naturally by omitting zero-elements, since this is the only way spinors can express
an N ×N matrix when N ≠2
n
.
1.11 Spinors as elements of geometry.
We may choose 〈i∈{0,1}∣,∣j∈{0,1}〉 to satisfy 〈i∣
⋅∣j 〉≡〈i∣ j〉=δij≡
{1 iff i= j
0 iff i≠ j
, which
correspond to orthonormal vectors that describe a particle with two possible spins, up and down.
Of necessity, a general spinor and its conjugate may be written
e
iα
(cos θ
2
∣0〉+e
iϕ
sinθ
2
∣1〉), e
−iα
(〈0∣cosθ
2
+〈1∣e
−iϕ
sinθ
2 ) , for which the simulator
syntax is: (e^(i*alpha))*(cos(theta/2)|0_1>_ + (e^(i*phi))*sin(theta/2)|0_1>_);.
This encodes three Euler angles and a conceptual picture is a unit vector, pointed along (θ ,ϕ)
and rotated by α about its own axis. Half-angles are used, for the same reason they are used in
quaternions and this will be explained later in the Introduction to Quantum Mechanics, where it
is shown that spinors are entities that perform rotations and how quantum mechanics can be used
to do translations, rotations and Lorentz boosts for computer graphics.
The angles appearing in the spinor determine the probability of getting 0 or 1, when it is
measured: p(0)=cos
2
θ/2 , p(1)=sin
2
θ/ 2 . The angle α is a global phase and treated as
“unobservable”, but does have consequences for interactions with photons. The angle ϕ is
called a relative phase and can generate the interference for which quantum mechanics is
renowned. We must, therefore, regard probabilities to form a “vector” whose components will be
different in different coordinate systems, S , related by some “rotation” operator ̂
O :
∣01⋯0n〉S1
≡ ∣ψ〉S2
=∑i
αi∣i 〉= ̂
O∣01⋯0n〉 ≡ ∣ψ' 〉S3
=∑i
αi '∣i〉= ̂
O'∣01⋯0n〉 . This is forced
on quantum mechanics by Special Relativity, which demands that probability distributions be
invariant under spacetime translations, 3D rotations, and Lorentz boosts.
1.12 Entanglement.
Two spinors can generate 4 outcomes: (∣0〉+∣1〉)⊗(∣0〉+∣1〉)→∣00〉
⏟
∣0〉⊗∣0〉
+∣01〉+∣10〉+∣11〉 . If the
possible outcomes are restricted to ∣00〉+∣11〉 then the two qubits are said to be “entangled”,
such that measuring one of them determines the other. In simulations, this is done through a
unitary operator ̂
O that can be viewed as a matrix that rotates a complex, higher dimensional
unit vector to a new direction, so that its components change.
1.13 Factorisation of state vectors and operators.
This simulator effects speed-ups by factorising expressions, for example:
∑i=0
2
n−1
∣i 〉→(∣0〉+∣1〉)
⊗n
, effects an exponential reduction in computational complexity from
2
n
summands to a tensor product of n subspaces. More often than not, state vectors and
operators are not fully factorisable and, instead, a large reduction in the number of summands
leads to a nested partitioning into subspaces, consisting of sums of tensor products of subspaces,
where the subspaces contain sums of tensor products and so forth. Operators can also be
factorised. As an example, the operator, cu_0_1_2_0_swp_4_1_3, that swaps qubits 1 and 3 iff
qubit 0 is 1 and qubit 2 is 0, after it is factorised it may be printed with the command
table_table(cu_0_1_2_0_swp_4_1_3), which produces:
7/60
Truth table for cu_0_1_2_0_swp_4_1_3=(2.8284271247+0i)|0><0| * [(0.7071067812+0i)|0><0| * {(0.7071067812+0i)|
0><0| * ((0.7071067812+0i)|0><0|+(0.7071067812+0i)|1><1|) + (0.7071067812+0i)|1><1| * ((0.7071067812+0i)|0><0|
+(0.7071067812+0i)|1><1|)} + (0.7071067812+0i)|1><1| * {(0.7071067812+0i)|0><0| * ((0.7071067812+0i)|0><0|
+(0.7071067812+0i)|1><1|) + (0.7071067812+0i)|1><1| * ((0.7071067812+0i)|0><0|+(0.7071067812+0i)|1><1|)}] +
(2.8284271247+0i)|1><1| * [(0.7071067812+0i)|0> * {(0.7071067812+0i)|0> * ((0.7071067812+0i)|0><000|
+(0.7071067812+0i)|1><100|) + (1+0i)|1><0| * ((0.5+0i)|0><10|+(0.5+0i)|1><11|)} + (0.7071067812+0i)|1> *
{(0.7071067812+0i)|0> * ((0.7071067812+0i)|0><001|+(0.7071067812+0i)|1><101|) + (1+0i)|1><1| * ((0.5+0i)|0><10|
+(0.5+0i)|1><11|)}]
---------------------------------------
| Input | Output |
---------------------------------------
| (1+0i)|0000> | (1+0i)|0000> |
| (1+0i)|0001> | (1+0i)|0001> |
| (1+0i)|0010> | (1+0i)|0010> |
| (1+0i)|0011> | (1+0i)|0011> |
| (1+0i)|0100> | (1+0i)|0100> |
| (1+0i)|0101> | (1+0i)|0101> |
| (1+0i)|0110> | (1+0i)|0110> |
| (1+0i)|0111> | (1+0i)|0111> |
| (1+0i)|1000> | (1+0i)|1000> |
| (1+0i)|1001> | (1+0i)|1100> |
| (1+0i)|1010> | (1+0i)|1010> |
| (1+0i)|1011> | (1+0i)|1011> |
| (1+0i)|1100> | (1+0i)|1001> |
| (1+0i)|1101> | (1+0i)|1101> |
| (1+0i)|1110> | (1+0i)|1110> |
| (1+0i)|1111> | (1+0i)|1111> |
---------------------------------------
Factorisation can produce reordering, for example: ∣00〉〈0∣+∣10〉〈1∣→(∣0〉〈0∣+∣1〉〈1∣)⊗(∣0〉) . A
factorised expression is only produced if it results in a reduction in computational complexity,
which is not the case in this example because factorised and unfactorised expressions both
contain the same number of summands, so there is no difference in their computational
complexity.
Since quantum algorithms are a sequence of unitary operators applied to an initial state-vector,
we can factorise the state vector after each unitary operation.
1.14 Support for un-normalised spinors.
This simulator supports un-normalised spinors, r e
iα
(cos θ
2
∣0〉+e
iϕ
sin θ
2
∣1〉) , to emphasise the
geometry. Normalised spinors can only rotate a unit-vector to a new direction, whilst un-
normalised spinors can also change the length, with r
2
as the scaling factor.
1.15 Support for Geometric Algebra, metric tensors and matrix
decomposition.
Geometric algebra is one of the more interesting branches of mathematics. It is based on the
work of Grassmann and Clifford in the 19th
Century. One can think of basis vectors as being
“variables” satisfying ei e j=−e j ei ,i≠ j and ei
2
=±1 . From these simple rules, one can
describe spaces of any dimension, the two most common being 3D Euclidean space, with
ei
2
=1,1≤i≤3 , and 4D spacetime, with e1
2
=±1,ei
2
=∓1,2≤i≤4 . In these two spaces, the
basis vectors can be represented by the Pauli and Dirac matrices from quantum mechanics. Any
complex matrix can be decomposed as
a0 e0
⏟
identity
+(a1e1+⋯+an en )+(a12 e1e2+⋯+an−1, n en−1 en )+⋯+a12 ⋯n e1⋯en .
Given a user-defined diagonalisable metric tensor, this simulator will generate anti-commuting
basis vectors, e. For example, a Minkowski metric will generate Dirac gamma-matrices as bases.
Multivectors are then built, eg, multi=(1.0l+0.0il)+2*e[2]+((0.0l+12.0il)*e[1]^e[2]).
The grade operator is given by _<multi>_(grade) and standard operations in GA are
supported. The simulator can use factorised operators as a compact and efficient representation,
and can decompose matrix-operators with respect to the generated basis vectors, using
8/60
combinatorial pruning to skip terms making zero contribution.
1.16 Solutions to eigenvalue problems.
This simulator provides an efficient method for obtaining the eigenvalues and eigenvectors of
any square matrix, including matrices with degenerate eigenvalues. This simplifies one of the
more difficult topics in quantum mechanics, namely, addition of angular momentum and
Clebsch-Gordan coefficients.
1.17 Equations developed for this simulator.
This simulator is based on the following equations, developed by the author:
(1) An equation for diagonalising any square matrix, requiring a small number of matrix
multiplications to achieve convergence.
(2) An equation for separating a matrix into two matrices containing even and odd grade
multivector blades, without the need to decompose the matrix into a full multivector.
(3) An equation for decomposing a matrix into a multivector using combinatorial pruning, to
reduce the search-space from 2
N
possible blades to n , where n is the number of blades
present in the matrix. This is equivalent to decomposing the matrix as a Clifford Algebra.
(4) An equation for extracting multivector blades of a given grade from a matrix, without
decomposing the matrix. This should not be used to construct the full multivector, since it
contains redundant computation, insofar as different blades have common elements.
(5) An equation for factorising matrices and vectors into tensor products. In the ideal case,
2
N
summands become a tensor product of N subspaces. In a non-ideal case, the number of
summands is reduced, but each summand is a tensor product of spaces, which contain summands
and so on recursively. This recursive partitioning into subsapces can vary from summand to
summand and between the operands to the inner product.
These equations depend heavily on the inner product function used by this simulator. Due to the
complexity of factorised, tensored expressions, this inner product function is far slower than
matrix operations performed using libraries, such as BLAS, that do not require the additional
logic needed and subspace copying to process complicated, tensored expressions. Finding a
faster alternative is an ongoing concern and the simulator offers a feature to convert Dirac
notation to the matrix notation of MATLAB and Mathematica, which can avail of fast, vectorised
matrix operations.
1.18 Teaching quantum mechanics in high schools.
The author has developed a technique for distilling derivations down to a few lines, enabling
advanced quantum mechanics to be taught in high schools. School teachers familiar with
quaternions will grasp the technique quite quickly. Quantum mechanics is largely geometry, in a
form discovered much earlier by the classical geometers Grassmann, Clifford, Hamilton and Lie.
It is a special case of geometric algebra and Dirac notation. It only appears odd, because we are
taught geometry a different way in high schools that leaves us unprepared for Special Relativity
and quantum mechanics, which are taught in an overly complicated way that obscures the
geometrical simplicity one would expect of the fundamental building blocks of the Universe.
In order to address this, Sections 8 and 9 contain two tutorials on quantum mechanics and
geometric algebra. The former includes advanced topics and the latter is especially useful in
showing that quantum mechanics is, largely, geometry. These tutorials contain coding examples
that illustrate, for example, how to do Special Relativity with the simulator by using the quantum
mechanics developed in the tutorial. The author believes that this can be taught in high schools.
9/60
Section 2: Definitions and syntax
Required header file and namespace: dirac.hpp, Quantum..
2.1 Amplitudes
An amplitude is defined through the following format:
Amplitude := AmpOrPhase(long double +/- long double il)
:= “_” → AmpOrPhase(1.0l+0.0il);
:= (long double)*e^( long double il)
:= (long double or int)_f OR _C
Examples: _, 1.0l+1.0il, 2.0l*e^(2*pi/3), 1_f. Un-normalised spinors are supported.
2.2 States
A state is defined according to the following formats:
State := integer _ number of qubits
State := binary string _ number of qubits
State := State<N>(integer)
Example: 3_4, “0011”_4, State<4> state(3), State<4>(3)
2.3 Bras
A bra is defined according to the following format:
Bra := _<State|AmpOrPhase
Example: _<3_4|(1.0il), _<“0011”_4|_
2.4 Kets
A ket is defined according to the following format:
Ket := AmpOrPhase|State>_
Example: (1.0il)|3_4>_, _|“0011”_4>_
2.5 Outer Products
An outer product is defined according to the following format:
Outer := AmpOrPhase|State>_<State|_
Example: (1.0il)|3_4>_<2_2|_, _|“0011”_4>_<2_2|_
2.6 State Vectors
A state vector is defined according to the following formats:
[bra] State Vector := Bra +/- Bra …
[ket] State Vector := Ket +/- Ket …
where Fock spaces are disallowed and each bra or ket must have the same number of qubits.
Example: _<3_2|(1.0il)+_<“10”_2|_, (1.0il)|3_2>_ + _|“10”_2>_
2.7 Operators
An operator is defined according to the following format:
Operator := Outer +/- Outer …
where the outer products must have the same number of qubits
Example: (1.0il)|3_4>_<2_2|_ + _|“1000”_4>_<1_2|_
2.8 Tensor Products and sums of tensor products
A tensor product is defined according to the following formats:
Tensor Product := (State Vector)*(State Vector)...
Tensor Product := (Operator)*(Operator)...
where the terms do not have to have the same number of qubits and state vectors are wholly bra or
ket. Tensor products may be summed and further tensored:
Tensor Sum := Tensor Product +/- Tensor Product ...
Tensor Product := (Tensor Sum)*(Tensor Sum)...
⋮
Terms in a tensor sum must have the same number of qubits, terms in a tensor product do not.
10/60
2.9 Inner products
An inner product is defined according to the following formats:
Inner Product := ([bra] State Vector) | ([ket] State Vector)
Inner Product := (Operator) | ([ket] State Vector)
Inner Product := ([bra] State Vector) | (Operator)
Inner Product := (Operator)(Operator)
where state vectors and operators may be tensor products and sums of tensor products.
2.10 Conjugate transpose
The conjugate transpose of a state vector or operator is defined according to the following formats:
Conjugate Transpose := (State Vector)^dag
Conjugate Transpose := (Operator)^dag
where state vectors and operators may be tensor products and sums of tensor products.
2.11 Measurement and collapse
Required header file and namespace: measurement.hpp, Quantum::Measurement.
A partial or full collapse of a state vector is specified through the syntax M(_|0_1>_<0_1|_)
and M(I), with I=_|0_1>_<0_1|_+_|1_1>_<1_1|_, where the former collapses a
qubit and the latter leaves it in a superposition. These are tensored to match the dimensionailty of
the state vector. The operator “^_XN” and “^_X(N)” will exponentiate these to the power N.
Examples:
H=(M(I)^_X2)*M(_|0_1>_<0_1|_)*(M(I)^_X(3))*(_|0_1>_<0_1|_)
collapses only qubits 2 and 6 out of qubits 0 to 7, H=M(_|0_1>_<0_1|_)^_X8 collapses all
8 qubits out of qubits 0 to 7 and H=M(I)^_X8 collapses no qubits.
To effect collapse, apply the operator H to the state vector: H|S>, <S|H. Qubits to be
measured will collapse either to 0 or 1, whilst qubits not being measured will remain in their
superposition state.
This is a slow operation and if all qubits need to be collapsed then the user may define the
operator: auto samp=sample(state vector). Once defined, this operator will
generate a state at random, state=samp(), weighted by the modulus-squared of its
probability amplitude.
2.11.1 Entangling a measuring device
When a state vector collapses it may trigger some reaction or “hit” in a measuring device. This
simulator models a device as a callback function:
Device device(const AmpOrPhase a, const state& s, const std::string& str)
{
// “a” holds amplitude of collapsed state.
// “s” holds the collapsed state, e.g. |001>
// “str” holds the binary string, e.g. “001” for use in std::bitset
};
The type of the state may be declared explicitly, e.g. KET<3> , or deduced, e.g
decltype(_<”001”_3|_). The device is then entangled:
auto H=M(...)*...*M(...)*M(device);
auto samp=sample(state vector, device);
Examples of the use of measurement are contained in the Introduction to quantum mechanics
section, in which the double-slit is simulated.
11/60
2.12 Geometric Algebra and matrix decomposition
Required header file and namespace: ga.hpp, Quantum::GA.
Users not familiar with geometric algebra may wish to consult the chapter on this subject, before
commencing with the simulator commands that implement the algebra.
2.12.1 Creating basis vectors
The first step in using the simulator for GA is defining the Clifford Group CLp ,q through a
diagonal metric tensor, M, eg:
auto Euclidean=_|0_2>_<0_2|_ + _|1_2>_<1_2|_ + _|2_2>_<2_2|_;
auto Minkowski= -1|0_2>_<0_2|_ + _|1_2>_<1_2|_ + _|2_2>_<2_2|_ + _|3_2>_<3_2|_;
The user may then create basis vectors through the commands:
auto e=_3D_[Euclidean]; and auto e=_4D_[Minkowski];
The basis vector, ei , is created dynamically and cached by the command e[i]. The basis
vectors are the Pauli matrices for 3D Euclidean space, the Dirac matrices for 4D Minkowski
space and the simulator will generate other bases for a specific metric and dimension:
_{N}D_[Metric].
2.12.1 Creating a multivector
The user may now use the basis vectors to create a multivector from blades, using “^”:
auto multivector=a + a_i*e[i] + a_j*e[j] + … + a_ij*e[i]^e[j] + ...;
with the a's complex numbers. The simulator will generate a representation as an operator,
which can be factorised into an equivalent operator with reduced computational complexity.
Geometric products cannot be written as A B, in C++, and the syntax for this is: (A)(B).
An N-dimensional multivector has up to 2
N
coefficients
∑i=0
N
ai ei+∑i , j≠i
aij ei∧e j+⋯+a1⋯n e1∧⋯∧eN , corresponding to a 2
⌊N /2⌋
×2
⌊N /2⌋
matrix.
If a 2
⌊N /2⌋
×2
⌊N /2⌋
matrix has complex elements, then the multivector is either N-dimensional
and complex or (N+1)-dimensional and real, for example:
N Basis vectors/Multivector
2 σ1 ,σ3 - the Pauli X and Z matrices / a0+a1 σ1+a3 σ3+a31σ3∧σ1
⏟
4 real or 4 complex
3 σ1 ,σ3 , i σ3σ1
⏟
σ2- Pauli-Y
/ a0+a1 σ1+a3σ3+a2 σ2+a12σ1σ2+a23 σ2σ3+a31 σ31+a123 σ1 σ2σ2
⏟
8 real numbers can hold2×2complex numbers
4/5 γ0 ,γ1, γ2 ,γ3 and γ5=i γ0 γ1 γ2 γ3 Dirac matrices
This property of dimensions is well-known to group theoreticians familiar with the Clifford
Group. This simulator is based on equations developed by the author allowing fast matrix
operations using GA and fast GA operations using matrix operations.
2.12.2 Selecting grades
A particular grade, g, is obtained via: _<multivector>_(g);
or they may be listed via:
for(auto g:_<multivector>_all) std::cout << _<multivector>_(g) << std::endl;
12/60
2.12.3 Decomposing matrices
A matrix operator, OP, can be decomposed with respect to basis vectors through the commands:
auto mv=_<(OP,BASIS)>_; eg _<(2|0_1>_<0_1|_+ …,_3D_[Euclidean])>_;
auto grade=_<(OP,BASIS)>_(g); eg _<(2|0_1>_<0_1|_+ …,_3D_[Euclidean])>_(2);
A square matrix not in the form 2
⌊N /2⌋
×2
⌊N /2⌋
can still be decomposed, with rows and columns
being zeroed out. Operators allow this because, for example,
M (3×3)
=∣00〉〈00∣+∣00〉〈01∣+∣00〉〈10∣+∣01〉〈00∣+∣01〉 〈01∣+∣01〉〈10∣+∣10〉〈00∣+∣10〉〈01∣+∣10〉〈10∣ is a
3×3 matrix formed by setting the last row and column of a 4×4 matrix to zero. This is
valid, because it may be applied to a 3-vector, such as, V(3×1)
=∣00〉+∣01〉+∣10〉 , which is
equivalent to the 4-vector V(4×1)
=∣00〉+∣01〉+∣10〉+(0)∣11〉 , with the last component set to 0.
2.13 General Geometric Algebra commands
A plethora of notational variations has arisen amongst proponents of GA, so this simulator shall
employ a more uniform syntax. The following operations of geometric algebra are supported:
GA Operation Grade operator Example/meaning Simulator
command
Decompose
matrix
NA Decompose a matrix, written as an
operator, wrt a basis, e.g.
_3D_[Euclidean]
_<(OP,Basis)>_
Grade extraction NA Do not decompose matrix, just obtain a
grade, k.
_<(OP,Basis)>_(k)
Even and odd
grades
NA Do not decompose matrix, just seperate
into two matrices with even and odd grades
m=
_<OP,Basis>_even_an
d_odd
m[0] – even
m[1] - odd
Involution NA
B=ei e j⋯ek
⏟
k-blade
→(−1)
k
ei ej ⋯ek
B^_ or
_<(m[0]-m[1],Basis)>_
Reversion
̃
A
NA Reversion:
ei e j ⋯ek →ek ⋯e j ei
~A or (for
Hermitian bases)
_<(A^dag,Basis)>_
AB=
∑k , k '
Ak Bk '
NA Geometric product:
(x1 ex+y1 ey+⋯)
(x2 ex+y2 ey+⋯)=
x1 y1+x2 y2+x1 y2ex ey+⋯
(A)(B)
Scalar product
A∗B
〈 AB〉0 a
⏟
number
⋅ v
⏟
vector
=〈a v〉0=0
〈(x1 ex+y1 ey )(x2ex+y2 ey )〉0
=
x1 y1+x2 y2
A*B or
_<A,B>_0
Outer product
Ak∧Bk '
Ak∧Bk '=〈 AB〉k+k '
A∧B=∑
k , k '
〈〈 A〉k 〈 B〉k ' 〉k+k '
a
⏟
number
∧ v
⏟
vector
=〈a v〉1=av
〈(x1 ex+y1ey )(x2 ex+y2e y)〉2
=
(x1 y2−x2 y1)ex ey
A^B
Right contraction
Ak ⌊ Bk '≤k
〈Ak Bk ' 〉k−k ' (B⋅A∥B) A⊥B Example: A|_(B)
13/60
A ⌊ B= ∑
k , k '≤k
〈〈A〉k 〈B〉k ' 〉k−k '
≡I ((I
−1
A)∧B)
a(e1e2)⌊ be2=abe1
Left contraction
Ak ⌋ Bk '≥k
〈Ak Bk ' 〉k '−k
A ⌋ B= ∑
k , k '≥k
〈〈A〉k 〈B〉k ' 〉k−k '
≡( A∧(B I
−1
)) I
(A⋅B∥A)B⊥A Example:
a e1 ⌋b(e1 e2)=ab e2
~((~B)|_(~A))
or
_(A)|B;
Inverse
Ak
−1
A
−1
̃
Ak
〈Ak Ak 〉0
≡
Ak
〈Ak Ak 〉0
The inverse:
Ak
−1
Ak =Ak Ak
−1
=1
A^(-1)
Projection
P{Bk } Ak '
(Ak ⌋ Bk ' )Bk '
−1
≡(Ak ⌋ Bk '
−1
)Bk '
Component of Bk parallel to Ak '
: B∥A
P_[B](A)
Rejection
R{Bk } Ak '
(Ak∧Bk ' )Bk '
−1
Component of Bk perpendicular to
Ak ' : B⊥ A
R_[B](A)
e
multivector NA Exponentiation, e.g
Rx=e
e2∧e3 θ/2
e^multivector
or
_e_^multivector
log NA Logarithm of multivector log(multivec)
Square root NA Square root of multivector Mvec^0.5
or
std::sqrt|mvec
mvec
p NA Multivector to the power p mvec^p
Eigen
decompos
NA Eigenvalues and eigenvectors of
multivector
auto m=eig(mv);
m[0] –
eigenvectors as
columns
m[1] eigenvalues
as diagonal
matrix
m[2]=m[0]^-1
Pseudoscalar
I N
NA I N =e1∧⋯∧eN
I N
2
=−1
[I N =odd ,ei ]=0 commutes.
{I N =even ,ei }=0 anticommutes.
auto e=
_{N}D_[Metric];
auto I_{N}=e[-1];
with {N} an integer
dimension, e.g. 4.
These form the basic elements from which the user can implement equations from standard texts.
The simulator provides for the basis qualifiers _0D_ to _59D_, so that _3D_[Euclidean]
will compile. Additional qualifiers can be created by the user in blocks of 10, through the
command: GEN10(N1,N2,N3,N3,N5,N6,N7,N8,N9), or just one with GEN1(N1), where
each N is an integer not previously used. For example, should the user need _100D_[Metric],
they can call GEN1(100), either in a header file or locally scoped to some function.
14/60
Section 3: Functions
Required header file and namespace: functions.hpp, Quantum.
3.1 Norm: _|(...)|_
The norm of a state vector or Hilbert-Schmidt norm of an operator are defined according to the
following formats:
Norm := _|(State Vector)|_
Norm := _|(Operator)|_
where state vectors and operators may be tensor products and sums of tensor products, and the
norm is a long double. The norm to a power is also supported: _|(...)|_^power.
3.2 Tensor power (“^_X” and “P”)
A state vector or operator may be tensored N times, at compile-time, through the format:
Tensor := (State Vector)^_XN or _X(N)
Tensor := (Operator)^XN or _X(N)
Example: (_|0_1>_<0_1|_ + _|1_1>_<1_1|_)^_X5 creates a 5-qubit identity
operator. The related operator _X(CONSTANT EXPRESSION) may be used with arithmetic
expressions, example: (_|0_1>_<0_1|_ + _|1_1>_<1_1|_)^_X(2+3).
For the run-time exponent, i, we use
Tensor := (State Vector)^P{i}
Tensor := (Operator)^P{i}
3.3 Trace
The trace of a square operator is defined according to the following format:
Trace := tr(Operator)
where operators may be tensor products and sums of tensor products.
3.4 Commutators and anticommutators
The commutator of two operators is defined through the following format:
Commutator := _[Operator,Operator]
The anticommutator of two operators is defined through the following format:
Anticommutator := _({Operator,Operator})
with the latter having a slightly different syntax due to the restrictions of the C++ compiler.
3.5 Eigendecomposition
The eigenvalues and eigenvectors of a square operator are obtained in the following way:
auto decomp = eig(Operator) or eig(Operator, Simultaneous)
where Simultaneous is a second operator, such as J z that commutes with Operator
and the result contains the right eigenvectors, as columns, the diagonal matrix of eigenvalues
and the left eigenvectors as columns, so that Operator=(decomp[0])(decomp[1])
(decomp[2]).
This simulator uses a proprietary method for obtaining eigenstates that applies generally and
does not require raising and lowering operators to be defined. It may be used to obtain
∣J , J z 〉 eigenstates from ∣J
1
, J z
1
〉⊗∣J
2
, J z
2
〉 , bypassing the standard method for addition of
angular momentum. An example of this is given in Introduction to quantum mechanics.
3.6 Matrix exponential and other functions
This simulator allows the exponential and powers of a matrix to be obtained, via
e^(operator), operator^(power). Any C++ STL function that accepts a complex
value can be applied to a matrix, via func|operator, where std::func represents an STL
function, e.g. std::log. User-defined functions are also supported, where func takes the
form: auto func=[](const AmpOrPhase& c){ return some_func(c); }.
15/60
3.7 Relational operations
State vectors and operators may be checked for equality, up to a global phase:
[State Vector or Operator] == [State Vector or Operator]
[State Vector or Operator] != [State Vector or Operator]
In the case of equality, the global phase difference may be extracted:
phase=[State Vector or Operator]/[State Vector or Operator]
These operations are slow and involve checking whether the state vectors or operators are
parallel. Amplitudes can also be checked for equality:
eq(AmpOrPhase,AmpOrPhase) or
eq(AmpOrPhase,AmpOrPhase,tolerance(real,imag))
3.8 Combining additions
Required header and namespace: vec.hpp, Quantum.
Very often, additions lead to duplicated terms, e.g. S+=_|0>_ → (2.0l+1.0il)|0>_+_|0>_ .
This can be avoided by using auto merge=merge_additions(S) and merge+=variable;
This will combine terms, e.g. S->(3.0l+1.0il)|0>_. This applies to state vectors and
operators and also to merge-=variable.
3.9 Printing state vector and operators
State vectors and operators are displayed through the following constructs:
std::cout << State Vector << std::endl;
std::cout << Operator << std::endl;
They are displayed in Dirac notation, with tensor products denoted by “*”.
3.9.1 Converting to vectors, matrices and Octave
Required header file and namespace: common.hpp, Quantum.
The function to_matrix(State Vector or Operator) will convert a bra-vector to a
row vector, a ket-vector to a column vector and an operator to a matrix. The functions
to_octave(to_matrix(State Vector or Operator)) and
to_wa(to_matrix(State Vector or Operator))convert the vector or matrix to the
Matlab and Wolfram Alpha format, respectively, for copying and pasting into these applications.
3.10 Running Octave
Required header file and namespace: common.hpp, Quantum.
If Octave is installed as some_dir/octave-cli.exe the simulator can send commands to
Octave, via:
auto octave_object=Octave(“some_dir/octave-cli.exe”);
octave_object << “command1” << “command2” … << “commandN” << run;
This is useful for such operations as plotting results. An Octave window remains open and the
execution of the simulator blocks, until the user exits Octave. Each of the commands will be sent
to Octave, each is terminated by a semi-colon “;” and after “run” Octave will open and
execute each of these commands, as if they had been entered manually.
3.11 Random numbers
Required header file and namespace: common.hpp, Quantum.
A random, complex number in the ranges (lower_real,upper_real),(lower_imag,upper_imag)
may be generated from the commands:
random({lower_real,lower_imag},{upper_real,upper_imag})
random({upper_real,upper_imag})
where the second function uses default values of zero for the lower bounds.
16/60
Section 4: Gates
Required header file and namespace: gates.hpp, Quantum::Gates.
4.1 Standard gates (X, Y, Z, H, T, S, R( θ )) and the truth_table command
The single-qubit gates X, Y, Z, H, T, S and R are supported and their truth table may be generated
through the command truth_table(gate); Example truth_table(Gates::H) :
Truth table for H=(0.70710678118655+0i)|0><0|+(0.70710678118655+0i)|0><1|+(0.70710678118655+0i)|1><0|+(-0.70710678118655+0i)|1><1|
--------------------------------------------------------------------------
| Input | Output |
--------------------------------------------------------------------------
| (1+0i)|0> | (0.70710678118655+0i)|0>+(0.70710678118655+0i)|1> |
| (1+0i)|1> | (0.70710678118655+0i)|0>+(-0.70710678118655+0i)|1> |
--------------------------------------------------------------------------
This command applies to any operator or quantum algorithm on N qubits, but caution is warranted
when the number of input states, 2
N
, is large, since it will enumerate all of them. Outputs are not
given as vectors or matrices, because these are often large, sparse and obscure the simplicity of their
representation as spinors. It is the exponentially large size of the state-space that prevents all
quantum algorithms being reduced to lookups on their truth tables, during inner products and
measurements: For example, an operator or algorithm may yield
(∣0〉+∣1〉)
⊗N
2
N
, whose modulus
would require (2N
)
2
=22N
inner products on the summands if expanded out, but only N inner
products on the (〈0∣+〈1∣) and (∣0〉+∣1〉) subspaces in the operands that are then multiplied.
4.2 SWAP
An N-qubit swap-operator that swaps qubits qi and q j is specified through the following
format:
auto swp_4_1_3=SWAP(N,q_i,q_j);
where N is the number of qubits and qubits q_i and q_j are to be swapped.
4.3 Controlled-U
An N-qubit unitary operator to be applied iff the control-qubits {qi ,q j ,...} satisfy the bit-pattern
{bi ,bj ,...} is specified through the following format:
auto cu = CU([U] Operator, C( qi ,bi ),C( q j ,b j ),...)
Example - Controlled-SWAP
auto swp_4_1_3=SWAP(4,1,3);
CU(swp_4_1_3, C(0,1),C(2,0));
swaps qubits 1 and 3 iff qubit 0 is 1 and qubit 2 is 0.
CU(swp_4_1_3, C(1,1),C(3,0));
swaps qubits 1 and 3 iff qubit 1 is 1 and qubit 3 is 0.
The truth table for the factorised CU(swp_4_1_3, C(1,1),C(3,0)) is given below:
17/60
Truth table for cu_0_1_2_0_swp_4_1_3=(2.8284271247+0i)|0><0| * [(0.7071067812+0i)|0><0| * {(0.7071067812+0i)|
0><0| * ((0.7071067812+0i)|0><0|+(0.7071067812+0i)|1><1|) + (0.7071067812+0i)|1><1| * ((0.7071067812+0i)|0><0|
+(0.7071067812+0i)|1><1|)} + (0.7071067812+0i)|1><1| * {(0.7071067812+0i)|0><0| * ((0.7071067812+0i)|0><0|
+(0.7071067812+0i)|1><1|) + (0.7071067812+0i)|1><1| * ((0.7071067812+0i)|0><0|+(0.7071067812+0i)|1><1|)}] +
(2.8284271247+0i)|1><1| * [(0.7071067812+0i)|0> * {(0.7071067812+0i)|0> * ((0.7071067812+0i)|0><000|
+(0.7071067812+0i)|1><100|) + (1+0i)|1><0| * ((0.5+0i)|0><10|+(0.5+0i)|1><11|)} + (0.7071067812+0i)|1> *
{(0.7071067812+0i)|0> * ((0.7071067812+0i)|0><001|+(0.7071067812+0i)|1><101|) + (1+0i)|1><1| * ((0.5+0i)|0><10|
+(0.5+0i)|1><11|)}]
---------------------------------------
| Input | Output |
---------------------------------------
| (1+0i)|0000> | (1+0i)|0000> |
| (1+0i)|0001> | (1+0i)|0001> |
| (1+0i)|0010> | (1+0i)|0010> |
| (1+0i)|0011> | (1+0i)|0011> |
| (1+0i)|0100> | (1+0i)|0100> |
| (1+0i)|0101> | (1+0i)|0101> |
| (1+0i)|0110> | (1+0i)|0110> |
| (1+0i)|0111> | (1+0i)|0111> |
| (1+0i)|1000> | (1+0i)|1000> |
| (1+0i)|1001> | (1+0i)|1100> |
| (1+0i)|1010> | (1+0i)|1010> |
| (1+0i)|1011> | (1+0i)|1011> |
| (1+0i)|1100> | (1+0i)|1001> |
| (1+0i)|1101> | (1+0i)|1101> |
| (1+0i)|1110> | (1+0i)|1110> |
| (1+0i)|1111> | (1+0i)|1111> |
---------------------------------------
18/60
Section 5: Creating and debugging
quantum algorithms.
Required header file and namespace: algorithm.hpp, Quantum::Algo.
An N-qubit quantum circuit is a unitary operator that itself comprises M unitary operators, “stages”,
applied sequentially, the quintessential example being the quantum Fourier transform. To create a
quantum algorithm, A, one simply derives from the class Algo::Algorithm and then adds the
M unitary operators using (*this)+=operator. The following functions are then available to
A:
A|State Vector>_ and _<State Vector|A – runs the algorithm on the state vector.
A^dag – returns the inverse algorithm, such that (A^dag)(A)=(A)(A^dag)=I.
A.size() – returns the number of stages.
std::cout << A; – Prints, sequentially, each of the M unitary operators.
5.1 Adding measurements
The user may add a measurement, described in the section “Measurement and collapse”, after
each of the M unitary operators has been applied. The Algorithm class allows for the
attachment of a callback function: A >> measure; This must be done before execution of the
algorithm begins and the callback must have the form:
Algo::Measure measure=[&](size_t i, const State Vector& after)
{
//i – contains the sequence number of the operator, 0 to M-1
//after - contains the state vector after the i-th operator.
//Perform measurement on after
return after; // Must return to quantum algorithm.
};
To avoid recursive calls to the callback when the algorithm is used in the callback, a copy must
be made and the callback switched off: algo_copy >> Measure();
5.2 Debugging
In order to simplify debugging, the Algorithm class allows for the attachment of a callback
function: A >> debug; This must be done before execution of the algorithm begins and the callback
must have the form:
Algo::Debug debug=[&](size_t i, const Operator& op,
const State Vector& before, const State Vector& after)
{
//i – contains the sequence number of the operator, 0 to M-1
//op – contains the i-th operator.
//before - contains the state vector before the i-th operator
//after - contains the state vector after the i-th operator.
};
To avoid recursive calls to the callback when the algorithm is used in the callback, a copy must
be made and the callback switched off: algo_copy >> Debug();
19/60
5.3 Coding example – 3 qubit Quantum Fourier Transform.
An n-qubit quantum Fourier transform satisfies: QFT∣x〉 =
1
√2
n
⊗j=1
j=n
(∣0〉+[e
i 2π x2n− j
/N
]∣1〉) . It
can be implemented as unitary operator with Hadamard, H, and phase, R, gates (Credit:
Wikipedia):
followed by reversing the order of the output qubits, using swap gates. It is very easy to
implement this, using the simulator:
//N-qubit quantum Fourier transform circuit
template<size_t N>
struct QFT : public Algorithm<N>
{
QFT(void)
{
create();
}
void create(void)
{
using namespace Gates;
auto& t=*this;
//Loop over stages
for(size_t i=0; i<N; ++i)
{
//Add the Hadamard gate
t+=(I^P{i})*H*(I^P{N-(i+1)});
//Add the phase gates
for(size_t j=1; j<(N-i); ++j)
{
AmpOrPhase phase=2.0l*pi/((2.0l+0il)^(j+1));
auto gate=(I^P{i})*R(phase)*(I^P{N-(i+1)});
t+=CU(OP<N>(gate),C(i+j,1));
}
}
//Add the final swap gates
for(size_t i=0; i<(N/2); ++i)
{
t+=swp(N,i,N-1-i);
}
}
};
We then wish to test it. To do this, we use the truth_table function on the 3-qubit algorithm
QFT<3> , which will invoke the algorithm against |000> to |111> . We attach a callback
function, which will be called for each invocation, after each stage of the algorithm, and verifies
that the final stage output is correct and also that (QFT^1 QFT)|input>=|input> . Finally, we
also attach a mock measurement callback, which only prints out the output of each stage, but that
could do a measurement after each stage.
20/60
//Create 3-qubit QFT
static constexpr size_t N=3;
QFT<N> qft;
//Debugging callback to perform sanity checks on algorithm
//Will be called every time the truth_table function calls qft|input_state>
size_t input_state=0; //to be incremented with each truth_table call
Algo::Debug debug=
[&](size_t stg, const OP<N,N>& op, const KET<N>& before,const KET<N>& after)
{
//Wait until end of algorithm
bool run_sanity_checks=(stg==qft.size()-1);
if(run_sanity_checks)
{
std::bitset<N> input(input_state);
std::cout << "Sanity checks on |"<< input << ">" << std::endl;
typedef AmpOrPhase A;
KET<0> tmp;
//Manually calculate expected result of qft|input_state>
for(size_t j=1; j<=N; ++j)
{
AmpOrPhase normalisation=(1.0l/(AmpOrPhase(2.0l)))^(0.5l);
AmpOrPhase a=(e^(2_f*pi*i/(2_f^N)))^(A(input_state)*(2_f^(N-j)));
if(j==1) tmp=normalisation*(_|0_1>_ +a|1_1>_);
else tmp*=(normalisation*(_|0_1>_ +a|1_1>_));
}
auto ket=KET<N>(tmp);
//Check expected results equals actual result
expected(ket)==actual(after);
expected(true)==actual(eq(1,ket/after,tolerance(1e-15,1e-15)));
//Check that (qft^1 qft)|input_state> == |input_state>
auto tmp_qft=qft;
tmp_qft >> Debug() >> Measure(); //switch off callback recursion
auto in=_|State<3>(input_state)>_;
expected((tmp_qft^dag)|after>_)==actual(in);
expected(true)==actual(eq(1,((tmp_qft^dag)|after>_)/in,
tolerance(1e-15,1e-15)));
++input_state;
}
};
//Callback to to a mock measurement
Algo::Measure measure=[&](size_t i, const KET<N>& aft)
{
std::cout << "measure: " << i << " " << aft << std::endl;
return aft;
};
//Attach callbacks to quantum algorithm
qft >> debug >> measure;
//Run quantum algorithm by calling the truth table
truth_table(qft);
The output for the first input state, |000>, is shown, below, along with the truth table:
21/60
measure: 0 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * (1+0i)|00>
measure: 1 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * (1+0i)|00>
measure: 2 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * (1+0i)|00>
measure: 3 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * (1+0i)|0>
measure: 4 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * (1+0i)|0>
measure: 5 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>]
Sanity checks on |000>
Test 1): [File: undefined, function: operator(), line: 144]: ket[aka [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>]] == after[aka [(0.7071067812+0i)|
0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>]] is true
Test 2): [File: undefined, function: operator(), line: 145]: true[aka true] == eq(1,ket/after,tolerance(1e-15,1e-15))[aka true] is true
Test 3): [File: undefined, function: operator(), line: 150]: (tmp_qft^dag)|after>_[aka (1+0i)|000>] == in[aka (1+0i)|000>] is true
Test 4): [File: undefined, function: operator(), line: 151]: true[aka true] == eq(1,((tmp_qft^dag)|after>_)/in, tolerance(1e-15,1e-15))[aka true] is true
measure: 6 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>]
⋮
Truth table for qft=
Stage 0: [(0.7071067812+0i)|0><0|+(0.7071067812+0i)|0><1|+(0.7071067812+0i)|1><0|+(-0.7071067812+0i)|1><1|] * [(1+0i)|0><0|+(1+0i)|1><1|] * [(1+0i)|0><0|+(1+0i)|1><1|]
Stage 1: [(1+0i)|0><0|+(0+1i)|1><1|] * (1+0i)|1><1| * [(1+0i)|0><0|+(1+0i)|1><1|] + [{(1+0i)|0><0|+(1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} + {(-1+0i)|0><0|+(-1+0i)|1><1|} * (1+0i)|1><1| * {(1+0i)|0><0|
+(1+0i)|1><1|}]
Stage 2: [(1+0i)|0><0|+(0.7071067812+0.7071067812i)|1><1|] * [(1+0i)|0><0|+(1+0i)|1><1|] * (1+0i)|1><1| + [{(1+0i)|0><0|+(1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} + {(-1+0i)|0><0|+(-1+0i)|1><1|} * {(1+0i)|
0><0|+(1+0i)|1><1|} * (1+0i)|1><1|]
Stage 3: [(1+0i)|0><0|+(1+0i)|1><1|] * [(0.7071067812+0i)|0><0|+(0.7071067812+0i)|0><1|+(0.7071067812+0i)|1><0|+(-0.7071067812+0i)|1><1|] * [(1+0i)|0><0|+(1+0i)|1><1|]
Stage 4: [(1+0i)|0><0|+(1+0i)|1><1|] * [(1+0i)|0><0|+(0+1i)|1><1|] * (1+0i)|1><1| + [{(1+0i)|0><0|+(1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} + {(-1+0i)|0><0|+(-1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} *
(1+0i)|1><1|]
Stage 5: [(1+0i)|0><0|+(1+0i)|1><1|] * [(1+0i)|0><0|+(1+0i)|1><1|] * [(0.7071067812+0i)|0><0|+(0.7071067812+0i)|0><1|+(0.7071067812+0i)|1><0|+(-0.7071067812+0i)|1><1|]
Stage 6: (1+0i)|0><0| * [(1+0i)|0><0|+(1+0i)|1><1|] * (1+0i)|0><0|+(1+0i)|1><0| * [(1+0i)|0><0|+(1+0i)|1><1|] * (1+0i)|0><1|+(1+0i)|0><1| * [(1+0i)|0><0|+(1+0i)|1><1|] * (1+0i)|1><0|+(1+0i)|1><1| * [(1+0i)|0><0|+(1+0i)|1><1|] * (1+0i)|1><1|
------------------------------------------------------------------------------------------------------------------------------------------------------------------
| Input | Output |
------------------------------------------------------------------------------------------------------------------------------------------------------------------
| (1+0i)|000> | [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] |
| (1+0i)|001> | [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0+0.7071067812i)|1>] * [(0.7071067812+0i)|0>+(0.5+0.5i)|1>] |
| (1+0i)|010> | [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0+0.7071067812i)|1>] |
| (1+0i)|011> | [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0-0.7071067812i)|1>] * [(0.7071067812+0i)|0>+(-0.5+0.5i)|1>] |
| (1+0i)|100> | [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] |
| (1+0i)|101> | [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0+0.7071067812i)|1>] * [(0.7071067812+0i)|0>+(-0.5-0.5i)|1>] |
| (1+0i)|110> | [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0-0.7071067812i)|1>] |
| (1+0i)|111> | [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0-0.7071067812i)|1>] * [(0.7071067812+0i)|0>+(0.5-0.5i)|1>] |
------------------------------------------------------------------------------------------------------------------------------------------------------------------
22/60
Section 6: Header files and namespaces
The following header files and namespaces are required to compile the various packages offered by
the simulator:
Header file Namespace Description
dirac.hpp Quantum Required in all code and allows Dirac notation to be
complied and run, using C++ operator-overloading.
measurement.hpp Quantum::Measurement Provides measurement operations.
gates.hpp Quantum::Gates Provides quantum gates.
algorithm.hpp Quantum::Algo Provides template for quantum algorithms and
circuits.
functions.hpp Quantum Provides matrix functions and eigendecomposition.
ga.hpp Quantum::GA Allows geometrical algebra notation to be compiled
and run, provides GA package of functions.
truth_table.hpp Quantum Provides truth table display.
common.hpp Quantum Provides helper functions to_matrix,
to_octave, to_wa, Octave - command pipe and
the random number generator function random.
verify.hpp Test Provides the expected(val)==actual(result)
command, terminates on first failure, prints out
function name and line number of the test and the
the number of tests and passes. See section
“Miscellaneous - Testing”
vec.hpp Quantum Provides merge_additions.
dirac.hpp Quantum::Fixed_Point_Arithmetic Provides fixed point arithmetic functions.
23/60
Section 7: Miscellaneous
7.1 Testing
Required header file and namespace: verify.hpp, Test.
The simulator offers a very simple testing interface. The syntax expected(A)==actual(B)
compares the expected value, A, against the actual value, B. It prints the name of the function
and line number, together with true if the comparison is true or false otherwise. Execution will
terminate on the first failed test. At the end, it will print the total number of tests and number
that passed.
7.2 Conventions
7.2.1 Qubit left-to-right numbering
The simulator uses ∣q0 q1 ...qn−1〉 .
7.2.2 Inner product convention for kets and bras
The inner product between two kets is, by convention, taken to be the tensor product:
∣kl 〉|∣kr 〉→∣kl kr 〉 . For bras, we have
(∣00〉〈1∣)(∣11〉)=∣001〉⇒(〈11∣)(∣1〉〈00∣)=(∣001〉)
†
=〈001∣ ⇒
〈1∣ ∣ 〈00∣=〈001∣⇒〈i∣ ∣ 〈 j∣=〈 j∣⊗〈i∣
(∣00〉〈1∣)(∣11〉〈11∣)=∣001〉〈11∣ ⇒
(∣11〉〈11∣)(∣1〉〈00∣)=(∣001〉〈11∣)
†
=∣11〉〈001∣ ⇒
(∣11〉〈1∣)(〈00∣)=∣11〉〈001∣⇒(∣i 〉〈 j∣)(〈k∣)=∣i 〉〈k∣⊗〈 j∣
Example:
L| R (L| R)
†
=R
†
| L
†
L =(2+0i)|000><10|+(3+0i)|001><11|
012 01 012 01
LLL LL LLL LL
R =(0+2i)|100><000|+(0+3i)|110><001|
012 012 012 012
RRR RRR RRR RR
L|R=(0+4i)|0000><000|+(0+9i)|0010><001|
0123 012 0123 012
LR
=(0-2i)|000><100|+(0-3i)|001><110|
012 012 012 012
LLL LLL LLL LLL
L
†
=(2+0i)|10><000|+(3+0i)|11><001|
01 012 01 012
RR RRR RR RRR
R
†
| L
†
=(0-4i)|000><0000|+(0-9i)|001><0010|
012 0123 012 0123
RL
7.3 Ongoing and future development
This includes:
1. Replacing the inner product function, which is slow, because it contains logic needed to
handle complicated factorised experessions. It can fail.
2. Numerical solutions to the Dirac equation.
3. Lorentz-invariant spacetime discretisation and simulation of General Relativity as a point-
wise similarity transformation of the Minkowski metric.
24/60
7.4 Rounding errors
Rounding errors have proven to be a significant problem. A result that is only zero to within some
tolerance, δ , has a precision of √δ in the modulus of null-vectors:
∣∣NULL 〉=(∣ψ〉−∣ψ〉)∣= √〈 NULL∣NULL〉≈√δ . This causes checks for zero, to within some
tolerance, to fail, which can lead to a crash. It can also lead to tests for equality between two results
to fail when they are the same, which is a problem when checking that a factorised expression is the
same as an unfactorised expression. It also leads to very much reduced precision for eigenvectors
and eigenvalues.
This problem is under investigation and checks for equality between state vectors or operators use
ψ1 is parallel to ψ2 , which gives higher accuracy than the test ∣ψ1−ψ2∣≈0
The simulator defaults to the precision of a long double (18 significant figures) in calculations,
and 15 to 18 significant figures for comparisons ad 14 significant figures in printed values.
7.4.1 Display precision
Required header file and namespace: dirac.hpp, Quantum.
The commands:
SetPrecision precision(integer N_significant_figures);
SetPrecision precision(integer N_significant_figures, integer N_decimal_places);
set the number of significant figures to N_significant_figures in printed values, with rounding, and,
optionally, also round to N_decimal_places.
Upon going out of scope, the local variable, “precision”, restores the previous values.
This can be used, case-by-case, to round to the nearest integer, to improve readability, for
example: -0.99999999999999 → -1, 1.009999999999999 → 1.01.
The outputs in this user-guide generally use SetPrecision precision(14,10).
7.4.2 Exploiting rounding errors
It is often the case that rounding errors can be exploited in tests. Suppose, for example, one has
the state-vector ψ=(α∣0〉+β∣1〉)⊗∣q∈{0,1}〉 and wishes to test whether q is 0. This may be
done through ∣[(〈0∣+〈1∣)⊗〈0∣]∣ψ〉∣≠0 , even when β=−α , provided 〈q=i∣q= j〉=δij
with exactitude. This is because of rounding errors on the first qubit, which will result in a small,
but non-zero value. This, however, would fail for exact or very precise arithmetic and the
alternatives ∣[(〈0∣(1+δ)+〈1∣(1−δ))⊗〈0∣]∣ψ〉∣≠0 or ∣[〈0∣⊗〈0∣]∣ψ〉∣+∣[〈1∣⊗〈0∣]∣ψ〉∣≠0 would
be necessary.
This can, of course, give rise to unintended consequences, in which results are correct until
precision is improved, at which point they become incorrect.
25/60
Section 8: Tutorial - Introduction to
Quantum Mechanics
8.1 Qubits, spinors and higher dimensional Hilbert spaces
We denote a qubit as ∣0〉 or ∣1〉 , which correspond to the column vectors
(1
0) and
(0
1) , respectively. We denote their duals as 〈0∣ or 〈1∣ , corresponding to the row vectors
(1,0) and (0,1) , respectively. We denote the inner product as 〈i∈{0,1}∣j∈{0,1}〉= δij .
We denote a spinor as α0∣0〉+α1∣1〉 , corresponding to the column vector
(α0
α1) , where
α∈ℂ and ∣α0∣
2
+∣α1∣
2
=r2
, with r a real “length”, which is 1 in quantum mechanics. We
denote the dual as ̄
α0〈0∣+ ̄
α1 〈1∣=(α0∣0〉+α1∣1〉)
†
, corresponding to the row vector
( ̄
α0 , ̄
α1) , where ̄
α denotes the complex conjugate and † denotes the conjugate
transpose, aka Hermitian transpose.
We denote a 2×2 complex matrix-operator as M =∑i=0, j=0
i= j , j=1
mij∣i 〉〈 j∣ , which corresponds
to the matrix
(m00 m01
m10 m11
) , m∈ℂ . Each term in the matrix operator can be applied, on the
left, to a spinor and, on the right, to some dual:
(mij∣i〉〈 j∣)(αk∣k 〉)≡mij αk∣i 〉〈 j∣k 〉= mij αk δ jk∣i 〉 and
(〈k∣βk )(mij∣i〉〈 j∣)≡mij βk 〈k∣i〉〈 j∣= 〈 j∣mij βk δki .
This spinor belongs to a complex, 2D Hilbert space, which simply means a 2D vector with
complex components. We can enlarge our space to any dimension, by increasing the number of
qubits, so that N qubits produce a 2
N
dimensional column vector,
∑i=1
2
N
−1
αi∣i 〉=∑i=1
2
N
−1
∣bit0(i)〉⊗⋯⊗∣bit2
N
−1
(i)〉 or row vector, which belongs to a complex
2
N
- dimensional Hilbert space, and a 2
N
×2
N
matrix-operator: M =∑i , j
mij∣i 〉〈 j∣
One may well ask how we represent matrices and vectors whose dimensionality, D , is not a
power of 2. The most straightforward way to do this is to create vectors of size 2⌈log2( D)⌉
,
matrices of size 2⌈log2( D)⌉
×2⌈log2 (D)⌉
and then remove rows and columns by setting them to zero.
For example, a 3-vector would become a 4-vector with the last element set to 0,
a0∣00〉+a1∣01〉+a2∣10〉 , and a 5×3 matrix would be an 8×8 matrix with the last 3 rows and
the last 5 columns set to zero, ∑i=0, j=0
i=4, j=2
mij∣i〉〈 j∣ , where i and j contain ⌈log2(5)⌉=3
qubits, giving a 2
3
×2
3
matrix that has been pared down to a 5×3 matrix. This will not produce
zeros for determinants and eigenvalues, since, for example, a 4×4 matrix with the last row and
column zeroed, will behave exactly the same as a 3×3 matrix.
Finally, quantum mechanics also contains continuous variables, such as position and momentum,
for which the best we can do is “digitise” them, using a sufficient number of qubits to achieve a
26/60
desired accuracy, whilst being aware that this is not terribly rigorous, in terms of continuously
differentiable manifolds. It is well-known that this breaks Special Relativity, because it
“pixelates” spacetime, with each “pixel” being unable to undergo Lorentz contraction and time
dilation.
8.2 Pauli matrices and SU(2)
Paul matrices comprise the 2×2 identity matrix-operator, σ0=∣0〉〈0∣+∣1〉〈1∣ and the three
matrix-operators σx=σ1=∣0〉〈1∣+∣1〉〈0∣, σy=σ2=−i∣0〉〈1∣+i∣1〉〈0∣, σz=σ3∣0〉〈0∣−∣1〉〈1∣ .
They satisfy the following:
(1) σi=σi
†
(2) σi
2
=1
(3) {σi ,σj }=σi σ j+σ j σi =2δij I ⇒σi>0σ j>i=−σ j σi
From these we find the further identities: (σ1 σ2σ3)
2
=−1 and σi σ j=δij+i ϵijk σk .These
properties make them suitable to be treated as “orthonormal basis vectors” and in quantum
mechanics the Pauli-vector is defined to be vPauli=x1σ1+x2 σ2+x3 σ3 , corresponding to the
matrix
( x3 x1−i x2
x1+i x2 −x3
) . The qubits ∣0〉 and ∣1〉 are the eigenvectors of σ3 ,
whilst (x1=r sinθcosϕ)σ1+( x2=r sinθsin ϕ)σ2+( x3=r cosθ)σ3 has corresponding
eigenvectors
{∣S0〉=cos(θ/2)e
−i ϕ/2
∣0〉+sin(θ/2)e
iϕ/2
∣1〉
〈S1∣S0 〉=0⇒∣S1〉=sin(−θ/2)e
−iϕ/2
∣0〉+cos(θ/2)e
+i ϕ/2
∣1〉
,
with eigenvalues ±r , and eigenspinors √r∣S0〉 , √r∣S1〉 the proof of which will be given in
the section on SU(2) rotations. Denoting ∣si〉 to be the eigenvector of σi , we can easily see
that xi=〈si∣v∣si〉
Eigenvectors may look different, when they are just the same eigenvector multiplied by some
global “phase” r e
iα
. Since the simulator returns eigenvectors as a column matrix P , where
each column is an eigenvector, we can apply a complex constant to all the eigenvectors through
P
(
r1 e
iα1
0 ⋯ 0
0 r2e
iα2
⋯ 0
⋱
0 0 ⋯ rn e
iαn
), with some convention, such as making the top entry 1 for all
eigenvectors. We can also check for equality and extract the global phase difference for two
eigenvectors with:
bool equal=(eigenvector_1==eigenvector_2);
auto phase=(eigenvector_1/eigenvector_2);
8.2.1 Coding Example: Spinors
We use the simulator to obtain eigenvectors and eigenvalues for each of the Pauli matrices and
then for a Pauli vector. Finally, we compare the eigenvectors for the Pauli-vector with the spinors
corresponding to this Paul-vector, to show that the spinors are just the eigenvectors:
27/60
//Pauli matrices
std::cout << "sigma_z=" << Z << std::endl;
//Get eigendecomposition. Apply global phases (top entry of eigenvecs-->1)
auto eig_decomp=eig(Z);
auto global_phase_1=(_<0_1|eig_decomp[0]|0_1>_)^(-1);
auto global_phase_2=(_<1_1|eig_decomp[0]|1_1>_)^(-1);
auto mat=global_phase_1|0_1>_<0_1|_+global_phase_2|1_1>_<1_1|_;
std::cout << "eigen vectors with global phase="
<< to_matrix((eig_decomp[0])(mat));
std::cout << "eigenvalues=" << to_matrix(eig_decomp[1]);
std::cout << "sigma_x=" << X << std::endl;
//Get eigendecomposition. Apply global phases (top entry of eigenvecs-->1)
eig_decomp=eig(X);
global_phase_1=(_<0_1|eig_decomp[0]|0_1>_)^(-1);
global_phase_2=(_<0_1|eig_decomp[0]|1_1>_)^(-1);
mat=global_phase_1|0_1>_<0_1|_+global_phase_2|1_1>_<1_1|_;
std::cout << "eigen vectors with global phase="
<< to_matrix((eig_decomp[0])(mat));
std::cout << "eigenvalues=" << to_matrix(eig_decomp[1]);
std::cout << "sigma_y=" << Y << std::endl;
//Get eigendecomposition. Apply global phases (top entry of eigenvecs-->1)
eig_decomp=eig(Y);
global_phase_1=(_<0_1|eig_decomp[0]|0_1>_)^(-1);
global_phase_2=(_<0_1|eig_decomp[0]|1_1>_)^(-1);
mat=global_phase_1|0_1>_<0_1|_+global_phase_2|1_1>_<1_1|_;
std::cout << "eigen vectors with global phase="
<< to_matrix((eig_decomp[0])(mat));
std::cout << "eigenvalues=" << to_matrix(eig_decomp[1]);
//Pauli vector v=r(sin theta cos phi,sin theta sin phi, cos theta)
AmpOrPhase theta=pi/3_f, phi=pi/5_f;
auto pauli_vector=
100*(sin(theta)*cos(phi)*X+sin(theta)*sin(phi)*Y+cos(theta)*Z);
std::cout << "Pauli vector=" << to_matrix(pauli_vector);
//Get eigendecomposition. Apply global phases (top entry of eigenvecs-->1)
eig_decomp=eig(pauli_vector);
global_phase_1=(_<0_1|eig_decomp[0]|0_1>_)^(-1);
global_phase_2=(_<0_1|eig_decomp[0]|1_1>_)^(-1);
mat=global_phase_1|0_1>_<0_1|_+global_phase_2|1_1>_<1_1|_;
std::cout << "eigen vectors with global phase="
<< to_matrix((eig_decomp[0])(mat));
std::cout << "eigenvalues=" << to_matrix(eig_decomp[1]);
//eigenspinor
auto spinors=cos(theta/2_f)*(e^(-i*phi/2_f))|0_1>_<0_1|_+
(e^(i*phi/2_f))*sin(theta/2_f)|1_1>_<0_1|_+
sin(-theta/2_f)*(e^(-i*phi/2_f))|0_1>_<1_1|_+
(e^(i*phi/2_f))*cos(theta/2_f)|1_1>_<1_1|_;
global_phase_1=(_<0_1|spinors|0_1>_)^(-1);
global_phase_2=(_<0_1|spinors|1_1>_)^(-1);
mat=global_phase_1|0_1>_<0_1|_+global_phase_2|1_1>_<1_1|_;
std::cout << "spinors with global phase=" << to_matrix((spinors)(mat));
The output for this is:
sigma_z=(1+0i)|0><0|+(-1+0i)|1><1|
eigen vectors with global phase=
(1+0i) (0+0i)
(0+0i) (1+0i)
eigenvalues=
(1+0i) (0+0i)
(0+0i) (-1+0i)
sigma_x=(1+0i)|0><1|+(1+0i)|1><0|
eigen vectors with global phase=
(1+0i) (1+0i)
(0.9999999996-4e-10i) (-1.0000000003-1.2e-09i)
eigenvalues=
(1+0i) (0+0i)
(0+0i) (-1+0i)
sigma_y=(0-1i)|0><1|+(0+1i)|1><0|
eigen vectors with global phase=
(1+0i) (1+0i)
(0+1i) (0-1i)
eigenvalues=
(1+0i) (0+0i)
(0+0i) (-1+0i)
Pauli vector=
(50+0i) (70.0629269222-50.9036960455i)
(70.0629269222+50.9036960455i) (-50+0i)
eigen vectors with global phase=
(1+0i) (1+0i)
(0.4670861796+0.3393579723i) (-1.401258537-1.0180739284i)
eigenvalues=
(100+0i) (0+0i)
(0+0i) (-100+0i)
spinors with global phase=
(1+0i) (1+0i)
(0.4670861795+0.3393579736i) (-1.4012585384-1.0180739209i)
28/60
8.3 Rotations
We can guess, from the previous section, that if σ3 ⇒∣0〉 and
̂
v=cosθcos ϕσ1+cosθsin ϕσ2+sinθσ3 ⇒cos(θ/2)e
−iϕ/2
∣0〉+sin(θ/2)e
iϕ/2
∣1〉 , then the
general spinor can be obtained by a rotation on ∣0〉 . This is indeed the case and we can use
e
iσk α
=cos α+i sinα σk , σμ σν=−σν σμ , i σk=σiσ j to show an interesting property of SU(2):
e
−iσk α/2
(aiσi+aj σ j+ak σk)e
iσk α/2
=e
−iσk α/2
e
−i σk α/2
(ai σi+a j σj)+ak σk
=(cosα−σiσ j sinα)(ai σi+a j σj)+ak ek
=(ai cosα−a j sinα)σi+(a j cosα+ai sinα)σ j+ak σk
This can be seen to be a rotation that leaves the σk component invariant and rotates vectors in
the perpendicular plane through angle α . We now seek to generalise this, through an Euler
rotation.
8.3.1 Euler rotations
We saw that e
−i σk α/2
̂
v e
iσk α/2
rotates the σi and σ j components of ̂
v , whilst leaving the
σk component unchanged. Thus, we may write
sinθcos ϕσ1+sin θsin ϕσ2+cosθσ3 = e
−i σz ϕ/2
e
−iσy θ/2
σ3 e
i σyθ/2
e
iσz ϕ/2
and
I cos α/2+i(sinθ cosϕσ1+sinθsin ϕσ2+cosθ σ3)sin α/2 =e
−iσz ϕ/ 2
e
−iσy θ/2
e
iσ3 α/2
e
iσy θ/2
e
i σz ϕ/2
This is an Euler rotation expressed through the exponential R=e
−iσ⋅̂
n α/2
, where ̂
n
2
=1 . The
exponential R=e
−iσ⋅̂
n α/2
is a 2×2 matrix belonging to the SU(2) group.
We can now ask how rotations affect spinors. Let ∣s〉 be the “spin-up” eigenvector of the Pauli
vector ̂
v , then 〈0∣σ3∣0〉= 〈s∣v∣s〉=1= 〈0∣R
−1
Rσ3 R
−1
⏟
v
R∣0〉
⏟
∣s〉
. Thus, some spinor ∣u〉
transforms under the rotation R=e
−iσ⋅̂
n α/2
as R∣u〉 . NB: This is different to defining the
rotation as 〈0∣Rσ3 R
−1
⏟
v
∣0〉 =〈0∣R
⏟
〈 s∣
σ3 R
−1
∣0〉
⏟
∣s〉
and chosen so that ∣ψ〉〈 ψ∣→ R(∣ψ〉 〈 ψ∣) R
−1
.
Example, using σy=−i σz σx , σx∣0〉=∣1〉, σz∣i∈{0,1}〉=(−1)
i
∣i 〉 :
Let R=e
−iσz ϕ/2
e
−iσy θ/2
R∣0〉 = e
−iσz ϕ/2
(I cos θ
2
−i σy sinθ
2 )∣0〉
= e
−iσz
ϕ/2
(I cos θ
2
∣0〉−σzsin θ
2
∣1〉
)
= cos(θ/2)e
−iϕ/2
∣0〉+sin(θ/2)e
iϕ/2
∣1〉
.
These will be the same for the Paul-vector v=r ̂
v , but the eigenvalues become ±1→±r .
Suppose we have the spinor ∣s〉=R∣0〉 , but do not know the rotation that produced it. We can
still recover v=Rσ3 R
−1
. We denote ∣s j〉 to be the “spin-up” eigenvector of σ j and note
that 〈s j∣σi∣s j 〉=δij ⇒vi=〈s∣σi∣s〉 . The following code illustrates these mathematical results:
8.3.2 Coding example: SU(2) rotations using spinors
In the following code we demonstrate how to rotate σ3 →v and then how to reverse this using
the inverse rotation:
29/60
using namespace Quantum;
using namespace Gates;
using std::sin, std::cos;
//x,y and z spinors (eigenvectors of Pauli matrices Gates::X, Y Z)
auto s_x=(1/sqrt(2))*(_|0_1>_+_|1_1>_);
auto s_y=(1/sqrt(2))*(_|0_1>_+i|1_1>_);
auto s_z=_|0_1>_;
//Pauli vector (x=sin theta cos phi, y=sin theta sin phi, z=cos theta)
AmpOrPhase theta=pi/3_f, phi=pi/5_f, norm=100;
auto pauli_vector=sin(theta)*cos(phi)*X+sin(theta)*sin(phi)*Y+cos(theta)*Z;
pauli_vector*=norm;
std::cout <<"pauli vector: "
<< "100*(sin(pi/3)cos(pi/5),sin(pi/3)cos(pi/5),cos(pi/3))="
<< "(" << norm*sin(theta)*cos(phi) << ", "
<< norm*sin(theta)*sin(phi) << ", " << norm*cos(theta) << ")"
<< std::endl << to_matrix(pauli_vector) << std::endl;
auto eigs=eig(pauli_vector);
std::cout << "eig(pauli_vector)=" << to_matrix(eigs[0])
<< to_matrix(eigs[1]) << to_matrix(eigs[2]);
std::cout << "Pauli vector from eigen decomposition="
<< to_matrix((eigs[0])(eigs[1])(eigs[2]))
<< std::endl;
//Rotation: theta about Y, then phi about Z
auto R=(e^(-i*Z*phi/2))(e^(-i*Y*theta/2));
//Check that 100*Z --> Pauli vector
std::cout << "R (100*Z) R^-1=" << to_matrix((R)(100*Z)(R^dag));
//Rotation via spinor
auto s=cos(theta/2_f)*(e^(-i*phi/2_f))|0_1>_+
sin(theta/2_f)*(e^(i*phi/2_f))|1_1>_;
s*=norm^(0.5);
std::cout << "spinor with global phase=" << to_matrix(s*((_<0_1|s)^(-1)));
std::cout << "<s|sigma_x|s>=" << (_<s|X|s>_) << std::endl;
std::cout << "<s|sigma_y|s>=" << (_<s|Y|s>_) << std::endl;
std::cout << "<s|sigma_z|s>=" << (_<s|Z|s>_) << std::endl;
s/=norm^(0.5);
std::cout << "<s|pauli_vector|s>=" << (_<s|pauli_vector|s>_) << std::endl;
std::cout << "R|0>=" << to_matrix((R)|0_1>_);
//Rotate eigen-spinors to Pauli vector frame, Z', and check we get 100*Z'
s_x=R|s_x>_;
s_y=R|s_y>_;
s_z=R|s_z>_;
//Check Pauli vector --> (x=0,y=0,z=1)
std::cout << "Inverse rotation using spinors" << std::endl;
std::cout << "(_<s_x|pauli_vector|s_x>_)=" << (_<s_x|pauli_vector|s_x>_)
<< std::endl;
std::cout << "(_<s_y|pauli_vector|s_y>_)=" << (_<s_y|pauli_vector|s_y>_)
<< std::endl;
std::cout << "(_<s_z|pauli_vector|s_z>_)=" << (_<s_z|pauli_vector|s_z>_)
<< std::endl;
The output is as follows:
30/60
pauli vector: 100*(sin(pi/3)cos(pi/5),sin(pi/3)cos(pi/5),cos(pi/3))=((70.0629269222+0i), (50.9036960455+0i), (50+0i))
(50+0i) (70.0629269222-50.9036960455i)
(70.0629269222+50.9036960455i) (-50+0i)
eig(pauli_vector)=
(-0.6510155548+0.5711206067i) (-0.1069063702-0.4884373327i)
(-0.4978947001+0.0458352227i) (-0.3474618464+0.7932655705i)
(100+0i) (0+0i)
(0+0i) (-100+0i)
(-0.6510155548-0.5711206067i) (-0.4978947001-0.0458352227i)
(-0.1069063702+0.4884373327i) (-0.3474618464-0.7932655705i)
Pauli vector from eigen decomposition=
(50+0i) (70.0629269222-50.9036960455i)
(70.0629269222+50.9036960455i) (-50+0i)
R (100*Z) R^-1=
(50+0i) (70.0629269222-50.9036960455i)
(70.0629269222+50.9036960455i) (-50+0i)
spinor with global phase=
(1+0i)
(0.4670861795+0.3393579736i)
<s|sigma_x|s>=(70.0629269222+0i)
<s|sigma_y|s>=(50.9036960455+0i)
<s|sigma_z|s>=(50+0i)
<s|pauli_vector|s>=(100+0i)
R|0>=
(0.8236391035-0.2676165673i)
(0.4755282581+0.1545084972i)
Inverse rotation using spinors
(_<s_x|pauli_vector|s_x>_)=(0+0i)
(_<s_y|pauli_vector|s_y>_)=(0+0i)
(_<s_z|pauli_vector|s_z>_)=(100+0i)
8.4 Hyperbolic rotations and Special Relativity
Pauli matrices have the property {σiσ j}= σi σj+σ j σi = 2δij . This means they satisfy a
Euclidean metric, which is the 3X3 identity matrix, from which we obtain Pythagoras'
Theorem: (x , y , z)
(
1 0 0
0 1 0
0 0 1)(
x
y
z)= x
2
+y
2
+z
2
. This relationship also means that
σi>0σ j>i=−σiσ j , which is a defining property of perpendicular vectors:
(U +V )(U+V )=U 2
+V 2
+U V +V U ⇒U V+V U =2U⋅V U⋅V :=
1
2
{U ,V }
U⋅V ⊥U=
1
2
{U ,V ⊥U }=0⇒U V ⊥U =−V ⊥U U U∧V :=
1
2
[U ,V ]
U V =
1
2
{U ,V }+
1
2
[U ,V ] U V=U⋅V +U ∧V
The metric also endows Pauli matrices with another nice property: (I 3:=σ1 σ2σ3)
2
=−1 , so
we can write a rotation as e
−iσi θ/2
=e
−I 3σiθ/2
.
We now want to move to four dimensions, so we need four matrices that satisfy
γi≥0 γj>i=−γi γj and (I 4:=γ0 γ1 γ2 γ3)
2
=−1 . This is equivalent to {γi γ j}=2 ηij , where
η is a 4X4 metric: (x0, x1, x2, x3)
(
1 0 0 0
0 −1 0 0
0 0 −1 0
0 0 0 −1
)(
x0
x1
x2
x3
)= x0
2
−(x1
2
+x2
2
+x3
2
) . The four
matrices are Dirac gamma matrices and the metric is the Minkowski metric of Special Relativity,
where (ct )
2
−(x
2
+y
2
+z
2
)=(ct )
2
−(vt )
2
is a 4D version of Pythagoras' Theorem that satisfies
the rule that it is the same “length squared” when you rotate to some new coordinate-system
31/60
(ct )
2
−(x
2
+y
2
+z
2
)=(ct ')
2
−(x'
2
+ y'
2
+z'
2
) . These gamma matrices will be explored later
and be shown to generate Special Relativity, quantum mechanically.
8.4.1 Hyperbolic rotations
In the absence of gamma matrices we are restricted to the four Pauli matrices and the Pauli
vector v=(ct )σ0+∑i=1
i=3
xi σi =
(ct+x3 x1−i x2
x1+i x2 ct−x3
) .
The 3D rotation (x , y , z)→(x '=x cosθ−ysinθ , y' =xsin θ+y cosθ , z '=z) satisfies
x '
2
+y'
2
+z '
2
=x
2
+y
2
+z
2
. Similarly, we can define a hyperbolic rotation
(ct , x , y ,z)→(ct '=ct cosh ζ−x sinhζ , x '=−ct sinh ζ+x cosh ζ , y '=y , z' =z) , which
satisfies (ct ')2
−x'2
−y'2
−z '2
=(ct)2
−x2
−y2
−z2
. The hyperbolic angle ζ is given by
tanh ζ=
sinhζ
cosh ζ
=
x
ct
=β:=
vx
c
⇒ζ=tanh
−1
β and viewed as a rotation in the t−x plane, since
we can no longer define a perpendicular axis of rotation. Since lim
v →c
(tanh
−1
(v /c))=∞ , we
cannot attain v=c and the Universe has the regions v<c
⏟
massive/timelike
, v=c
⏟
massless/lightlike
, v>c
⏟
tachyonic/spacelike
.
Let γ=(1−β2
)−1/2
=cosh(ζ) . A Lorentz transformation, Λ , performs a hyperbolic rotation:
(
ct '
x'
y '
z '
)=
[Λ=cosh(ζ)
(
1 −tanh(ζ) 0 0
−tanh(ζ) 1 0 0
0 0 1 0
0 0 0 1
)](
ct
x
y
z
)=γ
(
1 −β 0 0
−β 1 0 0
0 0 1 0
0 0 0 1
)(
ct
x
y
z
) .
The hyperbolic functions can be written cosh ζ=cosi ζ, sinh ζ=−i sin i ζ , tanh ζ=−tan i ζ .
We note that e
±iσk (iζ)
=I cosi ζ±i σk sinh i ζ = I cosh ζ∓σk sinhζ and
e
−σk ζ/2
(ct σ0+xi σi+x j σj+xk σk )e
−σk ζ/2
=e
−σk ζ
(ct σ0+xk σk)+xi σi+x j σj
=(I cosh ζ−σk sinh ζ)(ct σ0+xk σk )+xi σi+x j σ j
=(ct cosh ζ−xk sinhζ)σ0+(−ct sinhζ+xk cosh ζ)σk+xi σi+x j σ j
,
which is the Lorentz transformation in the t−xk plane. A Lorentz transformation in a general
direction σk=sin θ cosϕσ1+sin θsin ϕσ2+cosθσ3 is then e
−(sin θcosϕσ1+sinθsin ϕσ2+cosθσ3)ζ/2
.
It should be obvious that the eigenspinors for u=(ct )σ0+∑i=1
i=3
xi σi are the same as before for
v=∑i=1
i=3
xiσi ⇔√r∣s〉 , but the eigenvalues acquire the additive term ct , because we have
only added a scaled identity. We now have a four-component vector: (〈s∣σ0∣s〉, 〈s∣σi∣s〉) .
Since the zeroth component is 〈s∣σ0∣s〉=r , we conclude that ct=r , corresponding to a
massless particle travelling at v=c , where r=vt . This limitation is the result of σ0 not
satisfying σ0σi=−σi σ0 , which is a requirement for σ0 to be treated as a “basis vector”.
This limitation is overcome with Dirac gamma matrices that do satisfy γ
0
γ
i
=−γ
i
γ
0
. It is
worth noting, however, that the eigenspinors of u correspond with Weyl spinors and neutrinos
were thought to be Weyl spinors until it was discovered they are not massless.
32/60
8.5 Dirac matrices, Dirac equation and Special Relativity
Pauli matrices limit us to (ct )
2
−( x
2
+y
2
+z
2
)=0 , so we need four “basis vectors” satisfying
γi
γj
=−γ j
γi
, (γ0
γ1
γ2
γ3
)2
=−1 . Dirac matrices achieve this, with the properties:
(1) (γ
0
)
†
=γ
0
, (γ
μ>0
)
†
=−γ
μ>0
, (2) (γ
0
)
2
=1, (γ
μ>0
)
2
=−1 ,
(3) {γ
μ
, γ
ν
}=2ημ ν ⇒γ
μ
γ
ν>μ
=−γ
ν
γ
μ
, where ημ ν is the Minkowski metric discussed earlier.
Two common representations are (γchiral(or standard)
μ=0
=σ
1(or3)
⊗I 2 , γ
i∈{1,2,3}
=i σ
2
⊗σ
i
) and we will
use the Chiral basis. With this extended basis we can now write a “Dirac-vector”:
V=c τ ̂
V =c τ
[cosh ζ γ
0
−sinh ζ(sin θcos ϕγ
1
+sin θsinϕγ
2
+cos θ γ
3
)
⏟
̂
x⋅γ c.f. Pauli vector ]≡γμ x
μ
.
Having four basis vectors removes the restriction (c τ)
2
=(ct)
2
−(x
2
+y
2
+z
2
)=0 present with
Pauli matrices and allows c τ≥0 . The Dirac-vector may be obtained from γ
0
by a boost
̂
V=e
− ̂
x⋅γ γ
0
ζ/2
γ
0
e
̂
x⋅γ γ
0
ζ/2
=e
− ̂
x⋅γ γ
0
ζ
γ
0
=cosh ζ γ
0
−sinh ζ ̂
x⋅γ .
The eigenvectors of the exponential, e
− ̂
x⋅γ γ
0
ζ/2
are the same as those of its exponent:
−̂
x⋅γ γ
0
ζ/ 2=−(sin θcos ϕγ
1
+sinθsin ϕ γ
2
+cosθ γ
3
)γ
0
ζ/2
=−ζ/2[i σ
2
⊗(sin θcosϕσ
1
+sinθsin ϕσ
2
+cosθ σ
3
)][σ
1
⊗I2]
=−ζ/2[σ
3
⊗(sin θcos ϕσ
1
+sin θsin ϕσ
2
+cosθσ
3
)]
We can see that eigenvectors comprise ∣S〉=∣s±
3
〉⊗∣sPauli
± ̂
xB
〉 , such as
∣S〉=
1
√2
(∣0〉⊗∣s
̂
xB
〉+∣1〉⊗∣s
− ̂
xB
〉) . The useful identity cosh ζ=2cosh
2 ζ
2
−1 gives
cosh
ζ
2
=(cosh ζ+1
2 )
1/2
=[γ+1
2 ]
1/2
=[t+τ
2 τ ]
1/2
, sinh ζ/2=[cosh
2
ζ/2−1]
1/2
=[t−τ
2 τ ]
1/2
,
where γ=t /τ , and, using √t
2
−τ
2
=sinh(ζ) , the boost is:
∣SB 〉=e
+̂
x⋅γ γ0
ζ/2 1
√2
(∣0〉+∣1〉)⊗∣s〉rest frame =(cosh ζ/2+sinh ζ/2σ3⊗ ̂
x⋅σ)
1
√2
(∣0〉+∣1〉)⊗∣s〉
=
1
√4 τ(t+τ)
[I2⊗([t+τ] I 2+sinh(ζ) ̂
x⋅σ)∣0〉⊗∣s〉+I 2⊗([t+τ] I2−sinh(ζ) ̂
x⋅σ)∣1〉⊗∣s〉]
From γ0
∣S=Srest 〉=∣S 〉 , (̂
x⋅γ γ
0
)
†
= ̂
x⋅γ γ
0
, we get ̂
V
μ
=〈S∣e
̂
x⋅γ γ
0
ζ/2
γ
0
γ
μ
e
̂
x⋅γ γ
0
ζ/2
∣S 〉 .
Finally, using A
μ
Bμ ≡∑μ
A
μ
Bμ and xμ=(t ,−x) so that xμ
xμ=t2
−∣x∣
2
, we can show:
(γ
μ
xμ )∣SB〉= τ[cosh ζ γ
0
−sinh ζ(−̂
x⋅γ)]= τ e
+ ̂
x⋅γ γ
0
ζ/2
γ
0
e
− ̂
x⋅γ γ
0
ζ/2
∣SB〉
= τ(e
+ ̂
x⋅γ γ
0
ζ/2
(γ
0
=σ
1
⊗I2)) 1
√2
(∣0〉+∣1〉)⊗∣s〉rest frame
= τ(e
+ ̂
x⋅γ γ
0
ζ/2
) 1
√2
(∣1〉+∣0〉)⊗∣s〉rest frame= τ∣SB 〉 }⇒(γ
μ
xμ−τ)∣SB〉=0 .
Under the quantum mechanical substitution (ct ,−x)→(E ,− p)→i ℏ(∂/∂t , ∇) this becomes
the Dirac equation: (i γ
μ
∂/∂ x
μ
−m0)∣SB〉=0 and the Klein-Gordon equation is
(i γ
μ
∂/∂ x
μ
+m0)(i γ
μ
∂/∂ x
μ
−m0)∣S ' 〉=0 , in the Planck system of units, discussed later.
33/60
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf
spinor_quantum_simulator_user_guide_.pdf

More Related Content

Similar to spinor_quantum_simulator_user_guide_.pdf

developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdfjcarrey
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdfjcarrey
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdfjcarrey
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdfjcarrey
 
Rand rr2647z1.appendixes
Rand rr2647z1.appendixesRand rr2647z1.appendixes
Rand rr2647z1.appendixesBookStoreLib
 
2008 biodiesel handling & use guidelines
2008 biodiesel handling & use guidelines2008 biodiesel handling & use guidelines
2008 biodiesel handling & use guidelinesBiodiesel Automotive
 
Fundamentals of quantum information theory
Fundamentals of quantum information theoryFundamentals of quantum information theory
Fundamentals of quantum information theoryAli J
 
Air Force Enhancing Performance Under Stress
Air Force Enhancing Performance Under StressAir Force Enhancing Performance Under Stress
Air Force Enhancing Performance Under StressJA Larson
 
Mysql tutorial-excerpt-5.1-en
Mysql tutorial-excerpt-5.1-enMysql tutorial-excerpt-5.1-en
Mysql tutorial-excerpt-5.1-enAnh Vuong
 
Clostridiumbotulism
ClostridiumbotulismClostridiumbotulism
Clostridiumbotulismthuytrang246
 
Translinked Regional Freight Study
Translinked Regional Freight StudyTranslinked Regional Freight Study
Translinked Regional Freight StudyTranslinked
 

Similar to spinor_quantum_simulator_user_guide_.pdf (20)

developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdf
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdf
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdf
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdf
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdf
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdf
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdf
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdf
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdf
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdf
 
developersguide.pdf
developersguide.pdfdevelopersguide.pdf
developersguide.pdf
 
Rand rr2647z1.appendixes
Rand rr2647z1.appendixesRand rr2647z1.appendixes
Rand rr2647z1.appendixes
 
2008 biodiesel handling & use guidelines
2008 biodiesel handling & use guidelines2008 biodiesel handling & use guidelines
2008 biodiesel handling & use guidelines
 
Fundamentals of quantum information theory
Fundamentals of quantum information theoryFundamentals of quantum information theory
Fundamentals of quantum information theory
 
Original
OriginalOriginal
Original
 
RAND_RR750.pdf
RAND_RR750.pdfRAND_RR750.pdf
RAND_RR750.pdf
 
Air Force Enhancing Performance Under Stress
Air Force Enhancing Performance Under StressAir Force Enhancing Performance Under Stress
Air Force Enhancing Performance Under Stress
 
Mysql tutorial-excerpt-5.1-en
Mysql tutorial-excerpt-5.1-enMysql tutorial-excerpt-5.1-en
Mysql tutorial-excerpt-5.1-en
 
Clostridiumbotulism
ClostridiumbotulismClostridiumbotulism
Clostridiumbotulism
 
Translinked Regional Freight Study
Translinked Regional Freight StudyTranslinked Regional Freight Study
Translinked Regional Freight Study
 

More from Russell Childs

Feature extraction using adiabatic theorem
Feature extraction using adiabatic theoremFeature extraction using adiabatic theorem
Feature extraction using adiabatic theoremRussell Childs
 
Feature extraction using adiabatic theorem
Feature extraction using adiabatic theoremFeature extraction using adiabatic theorem
Feature extraction using adiabatic theoremRussell Childs
 
Wavelets_and_multiresolution_in_two_pages
Wavelets_and_multiresolution_in_two_pagesWavelets_and_multiresolution_in_two_pages
Wavelets_and_multiresolution_in_two_pagesRussell Childs
 
Recursion to iteration automation.
Recursion to iteration automation.Recursion to iteration automation.
Recursion to iteration automation.Russell Childs
 
Dirac demo (quantum mechanics with C++). Please note: There is a problem with...
Dirac demo (quantum mechanics with C++). Please note: There is a problem with...Dirac demo (quantum mechanics with C++). Please note: There is a problem with...
Dirac demo (quantum mechanics with C++). Please note: There is a problem with...Russell Childs
 
Shared_memory_hash_table
Shared_memory_hash_tableShared_memory_hash_table
Shared_memory_hash_tableRussell Childs
 
Full resume dr_russell_john_childs_2016
Full resume dr_russell_john_childs_2016Full resume dr_russell_john_childs_2016
Full resume dr_russell_john_childs_2016Russell Childs
 
Simple shared mutex UML
Simple shared mutex UMLSimple shared mutex UML
Simple shared mutex UMLRussell Childs
 
Design pattern to avoid downcasting
Design pattern to avoid downcastingDesign pattern to avoid downcasting
Design pattern to avoid downcastingRussell Childs
 
Full_resume_Dr_Russell_John_Childs
Full_resume_Dr_Russell_John_ChildsFull_resume_Dr_Russell_John_Childs
Full_resume_Dr_Russell_John_ChildsRussell Childs
 
Dynamic programming burglar_problem
Dynamic programming burglar_problemDynamic programming burglar_problem
Dynamic programming burglar_problemRussell Childs
 

More from Russell Childs (20)

String searching o_n
String searching o_nString searching o_n
String searching o_n
 
String searching o_n
String searching o_nString searching o_n
String searching o_n
 
String searching o_n
String searching o_nString searching o_n
String searching o_n
 
String searching
String searchingString searching
String searching
 
Permute
PermutePermute
Permute
 
Permute
PermutePermute
Permute
 
Feature extraction using adiabatic theorem
Feature extraction using adiabatic theoremFeature extraction using adiabatic theorem
Feature extraction using adiabatic theorem
 
Feature extraction using adiabatic theorem
Feature extraction using adiabatic theoremFeature extraction using adiabatic theorem
Feature extraction using adiabatic theorem
 
Wavelets_and_multiresolution_in_two_pages
Wavelets_and_multiresolution_in_two_pagesWavelets_and_multiresolution_in_two_pages
Wavelets_and_multiresolution_in_two_pages
 
Relativity 2
Relativity 2Relativity 2
Relativity 2
 
Recursion to iteration automation.
Recursion to iteration automation.Recursion to iteration automation.
Recursion to iteration automation.
 
Dirac demo (quantum mechanics with C++). Please note: There is a problem with...
Dirac demo (quantum mechanics with C++). Please note: There is a problem with...Dirac demo (quantum mechanics with C++). Please note: There is a problem with...
Dirac demo (quantum mechanics with C++). Please note: There is a problem with...
 
Shared_memory_hash_table
Shared_memory_hash_tableShared_memory_hash_table
Shared_memory_hash_table
 
Full resume dr_russell_john_childs_2016
Full resume dr_russell_john_childs_2016Full resume dr_russell_john_childs_2016
Full resume dr_russell_john_childs_2016
 
Simple shared mutex UML
Simple shared mutex UMLSimple shared mutex UML
Simple shared mutex UML
 
Design pattern to avoid downcasting
Design pattern to avoid downcastingDesign pattern to avoid downcasting
Design pattern to avoid downcasting
 
Interview uml design
Interview uml designInterview uml design
Interview uml design
 
Interview C++11 code
Interview C++11 codeInterview C++11 code
Interview C++11 code
 
Full_resume_Dr_Russell_John_Childs
Full_resume_Dr_Russell_John_ChildsFull_resume_Dr_Russell_John_Childs
Full_resume_Dr_Russell_John_Childs
 
Dynamic programming burglar_problem
Dynamic programming burglar_problemDynamic programming burglar_problem
Dynamic programming burglar_problem
 

Recently uploaded

User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)Columbia Weather Systems
 
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptxTHE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptxNandakishor Bhaurao Deshmukh
 
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)Columbia Weather Systems
 
Citronella presentation SlideShare mani upadhyay
Citronella presentation SlideShare mani upadhyayCitronella presentation SlideShare mani upadhyay
Citronella presentation SlideShare mani upadhyayupadhyaymani499
 
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxSTOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxMurugaveni B
 
Base editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editingBase editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editingNetHelix
 
Pests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPirithiRaju
 
preservation, maintanence and improvement of industrial organism.pptx
preservation, maintanence and improvement of industrial organism.pptxpreservation, maintanence and improvement of industrial organism.pptx
preservation, maintanence and improvement of industrial organism.pptxnoordubaliya2003
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
Microteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringMicroteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringPrajakta Shinde
 
User Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather StationUser Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather StationColumbia Weather Systems
 
Speech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxSpeech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxpriyankatabhane
 
TOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsTOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsssuserddc89b
 
User Guide: Capricorn FLX™ Weather Station
User Guide: Capricorn FLX™ Weather StationUser Guide: Capricorn FLX™ Weather Station
User Guide: Capricorn FLX™ Weather StationColumbia Weather Systems
 
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPirithiRaju
 
Transposable elements in prokaryotes.ppt
Transposable elements in prokaryotes.pptTransposable elements in prokaryotes.ppt
Transposable elements in prokaryotes.pptArshadWarsi13
 
Solution chemistry, Moral and Normal solutions
Solution chemistry, Moral and Normal solutionsSolution chemistry, Moral and Normal solutions
Solution chemistry, Moral and Normal solutionsHajira Mahmood
 
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptxRESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptxFarihaAbdulRasheed
 

Recently uploaded (20)

User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)User Guide: Orion™ Weather Station (Columbia Weather Systems)
User Guide: Orion™ Weather Station (Columbia Weather Systems)
 
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptxTHE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
THE ROLE OF PHARMACOGNOSY IN TRADITIONAL AND MODERN SYSTEM OF MEDICINE.pptx
 
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
 
Citronella presentation SlideShare mani upadhyay
Citronella presentation SlideShare mani upadhyayCitronella presentation SlideShare mani upadhyay
Citronella presentation SlideShare mani upadhyay
 
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptxSTOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
STOPPED FLOW METHOD & APPLICATION MURUGAVENI B.pptx
 
Base editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editingBase editing, prime editing, Cas13 & RNA editing and organelle base editing
Base editing, prime editing, Cas13 & RNA editing and organelle base editing
 
Pests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdf
 
preservation, maintanence and improvement of industrial organism.pptx
preservation, maintanence and improvement of industrial organism.pptxpreservation, maintanence and improvement of industrial organism.pptx
preservation, maintanence and improvement of industrial organism.pptx
 
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
Microteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical EngineeringMicroteaching on terms used in filtration .Pharmaceutical Engineering
Microteaching on terms used in filtration .Pharmaceutical Engineering
 
Volatile Oils Pharmacognosy And Phytochemistry -I
Volatile Oils Pharmacognosy And Phytochemistry -IVolatile Oils Pharmacognosy And Phytochemistry -I
Volatile Oils Pharmacognosy And Phytochemistry -I
 
User Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather StationUser Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather Station
 
Speech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxSpeech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptx
 
TOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physicsTOPIC 8 Temperature and Heat.pdf physics
TOPIC 8 Temperature and Heat.pdf physics
 
User Guide: Capricorn FLX™ Weather Station
User Guide: Capricorn FLX™ Weather StationUser Guide: Capricorn FLX™ Weather Station
User Guide: Capricorn FLX™ Weather Station
 
Hot Sexy call girls in Moti Nagar,🔝 9953056974 🔝 escort Service
Hot Sexy call girls in  Moti Nagar,🔝 9953056974 🔝 escort ServiceHot Sexy call girls in  Moti Nagar,🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Moti Nagar,🔝 9953056974 🔝 escort Service
 
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdfPests of safflower_Binomics_Identification_Dr.UPR.pdf
Pests of safflower_Binomics_Identification_Dr.UPR.pdf
 
Transposable elements in prokaryotes.ppt
Transposable elements in prokaryotes.pptTransposable elements in prokaryotes.ppt
Transposable elements in prokaryotes.ppt
 
Solution chemistry, Moral and Normal solutions
Solution chemistry, Moral and Normal solutionsSolution chemistry, Moral and Normal solutions
Solution chemistry, Moral and Normal solutions
 
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptxRESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
 

spinor_quantum_simulator_user_guide_.pdf

  • 1. Spinor Quantum Simulator User Guide Copyright Notice Spinor Quantum Simulator and User Guide © 2021 Dr Russell John Childs, PhD. All rights reserved. This user guide and associated quantum simulator, tradename “Spinor Quantum Simulator”, were wholly developed and are wholly owned by Dr Russell John Childs, PhD. Table of Contents Copyright Notice..................................................................................................................................1 Spinor Quantum Simulator and User Guide © 2021 Dr Russell John Childs, PhD........................1 Section 1: Introduction.........................................................................................................................4 1.1 Goal............................................................................................................................................4 1.2 Spinors and Direct support for Dirac notation...........................................................................4 1.2.1 Example.............................................................................................................................4 1.3 Column and row vectors............................................................................................................4 1.4 Inner products............................................................................................................................4 1.5 Matrices.....................................................................................................................................4 1.6 States..........................................................................................................................................5 1.7 Generalisation............................................................................................................................5 1.8 Illustrating Dirac notation for a matrix and vectors...................................................................5 1.9 Real-world example of using the simulator to solve a mathematical problem..........................5 1.10 Multiplying dissimilar matrices and vectors............................................................................6 1.11 Spinors as elements of geometry..............................................................................................7 1.12 Entanglement...........................................................................................................................7 1.13 Factorisation of state vectors and operators.............................................................................7 1.14 Support for un-normalised spinors. ........................................................................................8 1.15 Support for Geometric Algebra, metric tensors and matrix decomposition............................8 1.16 Solutions to eigenvalue problems............................................................................................9 1.17 Equations developed for this simulator....................................................................................9 1.18 Teaching quantum mechanics in high schools.........................................................................9 Section 2: Definitions and syntax.......................................................................................................10 2.1 Amplitudes...............................................................................................................................10 2.2 States........................................................................................................................................10 2.3 Bras..........................................................................................................................................10 2.4 Kets..........................................................................................................................................10 2.5 Outer Products.........................................................................................................................10 2.6 State Vectors.............................................................................................................................10 2.7 Operators..................................................................................................................................10 2.8 Tensor Products and sums of tensor products..........................................................................10 2.9 Inner products..........................................................................................................................11 2.10 Conjugate transpose...............................................................................................................11 2.11 Measurement and collapse.....................................................................................................11 2.11.1 Entangling a measuring device.......................................................................................11 2.12 Geometric Algebra and matrix decomposition......................................................................12 2.12.1 Creating basis vectors....................................................................................................12 2.12.1 Creating a multivector....................................................................................................12 2.12.2 Selecting grades.............................................................................................................12 1/60
  • 2. 2.12.3 Decomposing matrices...................................................................................................13 2.13 General Geometric Algebra commands.................................................................................13 Section 3: Functions...........................................................................................................................15 3.1 Norm: _|(...)|_...........................................................................................................................15 3.2 Tensor power (“^_X” and “P”)...............................................................................................15 3.3 Trace.........................................................................................................................................15 3.4 Commutators and anticommutators.........................................................................................15 3.5 Eigendecomposition.................................................................................................................15 3.6 Matrix exponential and other functions...................................................................................15 3.7 Relational operations...............................................................................................................16 3.8 Combining additions................................................................................................................16 3.9 Printing state vector and operators...........................................................................................16 3.9.1 Converting to vectors, matrices and Octave....................................................................16 3.10 Running Octave.....................................................................................................................16 3.11 Random numbers...................................................................................................................16 Section 4: Gates..................................................................................................................................17 4.1 Standard gates (X, Y, Z, H, T, S, R()) and the truth_table command......................................17 4.2 SWAP.......................................................................................................................................17 4.3 Controlled-U............................................................................................................................17 Section 5: Creating and debugging quantum algorithms...................................................................19 5.1 Adding measurements..............................................................................................................19 5.2 Debugging................................................................................................................................19 5.3 Coding example – 3 qubit Quantum Fourier Transform..........................................................20 Section 6: Header files and namespaces.............................................................................................23 Section 7: Miscellaneous....................................................................................................................24 7.1 Testing......................................................................................................................................24 7.2 Conventions.............................................................................................................................24 7.2.1 Qubit left-to-right numbering...........................................................................................24 7.2.2 Inner product convention for kets and bras......................................................................24 7.3 Ongoing and future development............................................................................................24 7.4 Rounding errors.......................................................................................................................25 7.4.1 Display precision..............................................................................................................25 7.4.2 Exploiting rounding errors...............................................................................................25 Section 8: Tutorial - Introduction to Quantum Mechanics.................................................................26 8.1 Qubits, spinors and higher dimensional Hilbert spaces...........................................................26 8.2 Pauli matrices and SU(2).........................................................................................................27 8.2.1 Coding Example: Spinors................................................................................................27 8.3 Rotations..................................................................................................................................29 8.3.1 Euler rotations..................................................................................................................29 8.3.2 Coding example: SU(2) rotations using spinors..............................................................29 8.4 Hyperbolic rotations and Special Relativity............................................................................31 8.4.1 Hyperbolic rotations.........................................................................................................32 8.5 Dirac matrices, Dirac equation and Special Relativity............................................................33 8.5.1 Coding Example: Time-dilation, Lorentz contraction and E=mc-squared using spinors34 8.5.2 Spatial rotations of Dirac spinors.....................................................................................35 8.5.3 The Pauli-Lubanski “vector”, helicity, the Higgs and mass.............................................36 8.6 Rotations on non-entangled and entangled systems................................................................37 8.6.1 Disentangling qubits........................................................................................................37 8.7 Energy and momentum............................................................................................................37 8.8 Measurements and observables...............................................................................................38 8.9 Heisenberg versus Schrödinger picture...................................................................................39 2/60
  • 3. 8.10 Classical mechanics versus quantum mechanics...................................................................39 8.10.1 The issue of superpositions and the “measurement problem”.......................................39 8.10.2 Coding Example: Bell's inequality using Monte-Carlo simulation...............................40 8.10.3 Coding Example: The double-slit using Monte-Carlo simulation.................................44 8.11 Addition of angular momentum and Clebsch-Gordan coefficients.......................................47 8.11.1 Coding Example: Adding two spin-1/2..........................................................................47 Section 9: Introduction to Geometric Algebra, Real and Complex Clifford Algebra........................49 9.1 Inner product............................................................................................................................49 9.2 Outer product...........................................................................................................................49 9.3 Geometric product...................................................................................................................49 9.4 Blades, k-vectors, grades and multivectors.............................................................................49 9.5 Multivector operations.............................................................................................................50 9.6 Even and odd dimensions........................................................................................................51 9.6.1 Coding Example 2D versus 3D........................................................................................52 9.7 Grade involution......................................................................................................................52 9.8 Matrix decomposition and grade operations............................................................................53 9.9 Blade and multvector inverses.................................................................................................53 9.10 General multivector functions and eigendecomposition.......................................................53 9.11 Rotations................................................................................................................................54 9.11.1 Coding Example: Rotation in X-Y plane and transcendental functions of a multivector. ...................................................................................................................................................54 9.12 Reflections.............................................................................................................................55 9.12.1 Reflection of a matrix without decomposition into a multivector..................................55 9.12.2 Coding Example: Reflection of a matrix without decomposition into a multivector....56 9.13 Contractions and projections.................................................................................................58 9.13.1 Coding Example: Left contraction.................................................................................58 9.13.2 Coding Example: Right contraction...............................................................................58 9.13.3 Coding Example: Projection and rejection....................................................................59 9.14 Clifford algebras....................................................................................................................60 3/60
  • 4. Section 1: Introduction 1.1 Goal. The goal in developing this simulator is to minimise the amount of coding required to run quantum mechanical equations that have been reduced to bras, kets, and unitary and Hermitian operators in Dirac notation, allowing physicists to concentrate on physics rather than the code. 1.2 Spinors and Direct support for Dirac notation. This simulator uses C++ operator-overloading to compile Dirac notation directly, without the need to convert equations to computer code that serves only to obfuscate. Equations are simplified and executed using Group Theory to provide higher efficiency. Gate primitives are provided, along with functions such as trace, eigen-decomposition and Geometric (Clifford) Algebra representations. C++, C++11, C++17 and C++20 were used to develop this simulator. 1.2.1 Example. A small example suffices to illustrate how to write Dirac notation that is directly compilable: auto matrix=((1.0il)|0_3>_<0_1|_+_|1_3>_<1_1|_)*(_|0_1>_<0_2|_+(2.0il)|0_1>_<3_2|_); This “creates” a non-square 2 4 ×2 3 matrix, ∑i=0, j=0 i=15, j=7 cij∣i〉〈 j∣ , from the tensor product, denoted by * , of 2 3 ×2 1 and 2 1 ×2 2 matrices, where cij is a complex number residing in the i th row and j th column. The underscores only serve to satisfy the C++ compiler, which requires two operands for ∣, < and > and to signify the number, N , of qubits, denoted _ N in the binary number, e.g. “2_3”->“010” and “5_3”->“101”. This compact notation eliminates zero-elements and the simulator can further simplify large matrices by factorising them into the tensor product of far smaller matrices, leading to faster matrix multiplication. This also applies to vectors, in a similar fashion, ∑i=0 2 n−1 ∣i 〉→(∣0〉+∣1〉) ⊗n ≡(∣0〉+∣1〉)0⊗⋯⊗(∣0〉+∣1〉)n−1 . Spinors correspond to linear combinations of the qubits ∣0〉 and ∣1〉 and their conjugates 〈0∣ and 〈1∣ , from which the Pauli matrices of quantum mechanics are created, which have a direct relationship to quaternions and geometric algebra. The ∣i〉 are called “kets” and their conjugates 〈i∣ are called “bras”. They correspond to column and row vectors, where 0≤i≤2 n−1 is a binary number giving the row or column in a 2 n -dimensional complex “vector”. We shall use the word “spinor” to denote both qubits and their linear combinations. 1.3 Column and row vectors. Dirac notation simplifies quantum mechanics and simulations. Vectors are denoted by A= ( α0 : αn−1 )→∣ψ〉=∑i=0 n−1 αi∣i〉 and B=(β0 ... βn−1)→〈ψ'∣=∑i=0 n−1 〈i∣βi≡(∑i=0 n−1 βi * ∣i 〉) † . 1.4 Inner products. An inner product is denoted by B⋅A=∑i=0 n−1 βiαi=〈ψ'∣ψ 〉=∑i=0, j=0 i=n−1, j=n−1 βi αj 〈i∣ j〉⇒〈i∣ j〉=δij : δij≡0iff i≠ j ,1iff i= j . 1.5 Matrices. Matrix elements are denoted M ij=mij∣i〉〈 j∣⇒ {M⋅A=(∑ij mij∣i〉〈 j∣)(∑k αk∣k 〉)=∑ij mij α j∣j 〉 B⋅M =(∑i 〈k∣βk)(∑ji m ji∣j〉〈i∣)=∑ji 〈 j∣βj mji . 4/60
  • 5. 1.6 States. Each state ∣i〉 can be simplified as a tensor product of the simplest possible states ∣0〉 and ∣1〉 , for example: a∣2〉+b∣3〉=a ∣ 10 ⏟ 2in binary 〉+b ∣ 11 ⏟ 3in binary〉=a ∣1〉⊗∣0〉 ⏟ tensor product of∣1〉and∣0〉 +b∣1〉⊗∣1〉 and similarly for row vectors and matrices, s.t. 〈i0 ...in−1 ⏟ i ∣j0... jn−1 ⏟ j 〉=δi0 j0 ...δin−1 jn−1 where iμ∈{0,1}, jν∈{0,1} are μ th , ν th bits of i , j in the binary representation. 1.7 Generalisation. Splitting matrices and operators into spinors brings many advantages, in allowing quantum mechanics to be built from spinors: ∣0〉 , ∣1〉 , 〈0∣ , 〈1∣ and complex numbers, mij ,α ,β , although “digitising” spacetime, ∣x ,t 〉→∣x0 ... xn−1 ,t0...tn−1〉 , breaks Lorentz Invariance, requiring a modified approach. The tutorial section “Introduction to quantum mechanics” will show the reader how Pauli matrices and spinors can perform rotations, Dirac matrices and spinors can be used to do Special Relativity and how the De Broglie relations can be justified by considering how the Fourier transformation of a probability distribution extending over spacetime behaves under Special Relativity. It also includes examples of how to use the simulator to demonstrate Bell's inequality and the double-slit experiment. Finally, spinors are quite general and can be used to create any vector or matrix, including those outside of quantum mechanics, and this simulator supports non-Unitary/Hermitian/square matrices and operations such as: (M =∑i=0, j=0, k=0 i=I −1, j=J −1, k=K−1 mijk∣i〉〈 j∣⊗〈k∣ ⏟ I× N ⏟ J×K ≠I non-square matrix≡I ×N OR I ×J ×K )(∑j=0 J −1 αj∣j〉) ⏟ J ×1vector =∑i=0, j=0, k=0 i=I −1, j=J −1,k=K −1 mijk αj∣i 〉〈k∣ ⏟ I×K matrix . 1.8 Illustrating Dirac notation for a matrix and vectors. A simple illustration shows how to interpret Dirac notion in terms of a row vector, matrix and column vector: (〈0∣1,〈1∣2,〈2∣0) ⏟ 〈00∣1+〈01∣2 ⏞ row vector ( 0∣00〉〈00∣ 1∣00〉〈01∣ 0∣00〉〈10∣ 0∣01〉〈00∣ 4∣01〉〈01∣ 0∣01〉〈10∣ 6∣10〉〈00∣ 0∣10〉〈01∣ 8∣10〉〈10∣) ⏟ 1∣00〉 〈01∣+4∣01〉〈01∣+6∣10〉〈00∣+8∣10〉 〈10∣ ⏞ matrix ( 0∣0〉 3∣1〉 5∣2〉)}3∣1〉+5∣2〉 ⏞ column vector We see the operators ignore zero-elements. They can represent jagged matrices and allow operations that would be disallowed using matrices. Operators free us from matrices and vectors when we can work with individual elements. The astute reader may have noticed that the 3×3 matrix above can be interpreted as a 4×4 matrix with the last row and column zeroed out. This type of flexibility allows us to decompose a matrix into other matrices of a different dimension, in ways that would normally be disallowed were we restricted to working with matrices and vectors. 1.9 Real-world example of using the simulator to solve a mathematical problem. The Pauli matrices are 2×2 matrices given by σ1=∣0〉〈1∣+∣1〉〈0∣ , σ2=−i∣0〉〈1∣+i∣1〉〈0∣ σ3=∣0〉〈0∣−∣1〉〈1∣ . We are given a 4×4 matrix: M =∑i=1, j =i+1 i=3, j =3 aij σi⊗σ j , with aij 5/60
  • 6. and σi ,σj unknown and we want the coefficients aij . We can solve this problem by noting that the anti-commutator {σi ,σ j}:=σi σ j+σ j σi=2δij , so that: aij= ∣∣1 2 {1 2 {M ,σi⊗I }, I⊗σ j}∣∣HS ∣ ∣σ∣ ∣HS 2 = ∣∣aij δij⊗δij∣∣HS ∣ ∣σ∣ ∣HS 2 . Here we are double-matching, on σi to the left and σ j to the right, and getting rid of the ∣∣σi⊗σ j∣ ∣HS norm, to give us aij . We could also have done it using traces, since tr (σ)=0 tr (δij )=2 , so tr(σi σ j)= {0 iff i≠ j 2 iff i= j We now write this into the simulator: //The solution auto solution=[](auto sig_i, auto sig_j, auto M) { return (_|_({_({M,sig_i*I}),I*sig_j})/4|_)/(_|sig_i|_^2); }; The test code then creates a matrix and verifies that the coefficients are extracted: //(1) Use simulator's geometric algebra package to create Pauli matrices // _3D_ defines 3D space, Euclidean metric is just the 3X3 identity auto e= _3D_[_|00_2>_<00_2|_+_|01_2>_<01_2|_+_|10_2>_<10_2|_]; //(2) Loop over all combinations sig_i sig_j and sum Oper<2,2> op; for(auto [i,j]:std::vector<std::pair<size_t,size_t>>{{1,2},{1,3},{2,3}}) { //(3) Create tensor of form 12*sig_1*sig2 + 23*sig_2*sig_3 ... op+=(10*i+j)*e[i].oper()*e[j].oper(); } //(4) Loop over sig_i sig_j for(auto [i,j]:std::vector<std::pair<size_t,size_t>>{{1,2},{1,3},{2,3}}) { //(5) Print out components auto result=solution(e[i].oper(),e[j].oper(),op); std::cout << "(e[" << i << "]*e[" << j << "]).(op)=" << result << std::endl; } This is the output: (e[1]*e[2]).(op)=(12+0i) (e[1]*e[3]).(op)=(13+0i) (e[2]*e[3]).(op)=(23+0i) 1.10 Multiplying dissimilar matrices and vectors The main advantage to using spinors over vectors and matrices is that spinors do not care about the vector or matrix to which they belong, allowing us to do operations that would be forbidden if we stuck with matrices. As an example, Pauli matrices are 2×2 and Dirac matrices are 4×4 . Ordinarily, we would need both to be of the same dimensions in order to multiply them. With operators, however, we need only recognise that (〈i∣) (∣ j k 〉)=δij∣k 〉 , for example: (〈0∣) ⏟ 2-vector (∣01〉) ⏟ 4−vector = ∣1〉 ⏟ 2−vector . Multiplying a 2×2 into a 4×4 , element-by-element, then becomes possible, for example, (∣1〉〈0∣) ⏟ 2×2 (∣01〉〈11∣) ⏟ 4×4 =(∣11〉〈11∣) ⏟ 4×4 . This can be made clearer using tensor products: σx (σx⊗σy )=I⊗σy≡(σx σx)⊗σy . More generally, we can also pad matrices so that they look to be of the same dimension: 6/60
  • 7. a0,0∣00〉〈00∣+⋯+a2,2∣01〉〈01∣ ⏟ 3×3 ≡a0,0∣00〉〈00∣+⋯+a3,3∣11〉〈11∣ ⏟ 4×4 ,ai, 3=a3,i=0∀i , which operators do naturally by omitting zero-elements, since this is the only way spinors can express an N ×N matrix when N ≠2 n . 1.11 Spinors as elements of geometry. We may choose 〈i∈{0,1}∣,∣j∈{0,1}〉 to satisfy 〈i∣ ⋅∣j 〉≡〈i∣ j〉=δij≡ {1 iff i= j 0 iff i≠ j , which correspond to orthonormal vectors that describe a particle with two possible spins, up and down. Of necessity, a general spinor and its conjugate may be written e iα (cos θ 2 ∣0〉+e iϕ sinθ 2 ∣1〉), e −iα (〈0∣cosθ 2 +〈1∣e −iϕ sinθ 2 ) , for which the simulator syntax is: (e^(i*alpha))*(cos(theta/2)|0_1>_ + (e^(i*phi))*sin(theta/2)|0_1>_);. This encodes three Euler angles and a conceptual picture is a unit vector, pointed along (θ ,ϕ) and rotated by α about its own axis. Half-angles are used, for the same reason they are used in quaternions and this will be explained later in the Introduction to Quantum Mechanics, where it is shown that spinors are entities that perform rotations and how quantum mechanics can be used to do translations, rotations and Lorentz boosts for computer graphics. The angles appearing in the spinor determine the probability of getting 0 or 1, when it is measured: p(0)=cos 2 θ/2 , p(1)=sin 2 θ/ 2 . The angle α is a global phase and treated as “unobservable”, but does have consequences for interactions with photons. The angle ϕ is called a relative phase and can generate the interference for which quantum mechanics is renowned. We must, therefore, regard probabilities to form a “vector” whose components will be different in different coordinate systems, S , related by some “rotation” operator ̂ O : ∣01⋯0n〉S1 ≡ ∣ψ〉S2 =∑i αi∣i 〉= ̂ O∣01⋯0n〉 ≡ ∣ψ' 〉S3 =∑i αi '∣i〉= ̂ O'∣01⋯0n〉 . This is forced on quantum mechanics by Special Relativity, which demands that probability distributions be invariant under spacetime translations, 3D rotations, and Lorentz boosts. 1.12 Entanglement. Two spinors can generate 4 outcomes: (∣0〉+∣1〉)⊗(∣0〉+∣1〉)→∣00〉 ⏟ ∣0〉⊗∣0〉 +∣01〉+∣10〉+∣11〉 . If the possible outcomes are restricted to ∣00〉+∣11〉 then the two qubits are said to be “entangled”, such that measuring one of them determines the other. In simulations, this is done through a unitary operator ̂ O that can be viewed as a matrix that rotates a complex, higher dimensional unit vector to a new direction, so that its components change. 1.13 Factorisation of state vectors and operators. This simulator effects speed-ups by factorising expressions, for example: ∑i=0 2 n−1 ∣i 〉→(∣0〉+∣1〉) ⊗n , effects an exponential reduction in computational complexity from 2 n summands to a tensor product of n subspaces. More often than not, state vectors and operators are not fully factorisable and, instead, a large reduction in the number of summands leads to a nested partitioning into subspaces, consisting of sums of tensor products of subspaces, where the subspaces contain sums of tensor products and so forth. Operators can also be factorised. As an example, the operator, cu_0_1_2_0_swp_4_1_3, that swaps qubits 1 and 3 iff qubit 0 is 1 and qubit 2 is 0, after it is factorised it may be printed with the command table_table(cu_0_1_2_0_swp_4_1_3), which produces: 7/60
  • 8. Truth table for cu_0_1_2_0_swp_4_1_3=(2.8284271247+0i)|0><0| * [(0.7071067812+0i)|0><0| * {(0.7071067812+0i)| 0><0| * ((0.7071067812+0i)|0><0|+(0.7071067812+0i)|1><1|) + (0.7071067812+0i)|1><1| * ((0.7071067812+0i)|0><0| +(0.7071067812+0i)|1><1|)} + (0.7071067812+0i)|1><1| * {(0.7071067812+0i)|0><0| * ((0.7071067812+0i)|0><0| +(0.7071067812+0i)|1><1|) + (0.7071067812+0i)|1><1| * ((0.7071067812+0i)|0><0|+(0.7071067812+0i)|1><1|)}] + (2.8284271247+0i)|1><1| * [(0.7071067812+0i)|0> * {(0.7071067812+0i)|0> * ((0.7071067812+0i)|0><000| +(0.7071067812+0i)|1><100|) + (1+0i)|1><0| * ((0.5+0i)|0><10|+(0.5+0i)|1><11|)} + (0.7071067812+0i)|1> * {(0.7071067812+0i)|0> * ((0.7071067812+0i)|0><001|+(0.7071067812+0i)|1><101|) + (1+0i)|1><1| * ((0.5+0i)|0><10| +(0.5+0i)|1><11|)}] --------------------------------------- | Input | Output | --------------------------------------- | (1+0i)|0000> | (1+0i)|0000> | | (1+0i)|0001> | (1+0i)|0001> | | (1+0i)|0010> | (1+0i)|0010> | | (1+0i)|0011> | (1+0i)|0011> | | (1+0i)|0100> | (1+0i)|0100> | | (1+0i)|0101> | (1+0i)|0101> | | (1+0i)|0110> | (1+0i)|0110> | | (1+0i)|0111> | (1+0i)|0111> | | (1+0i)|1000> | (1+0i)|1000> | | (1+0i)|1001> | (1+0i)|1100> | | (1+0i)|1010> | (1+0i)|1010> | | (1+0i)|1011> | (1+0i)|1011> | | (1+0i)|1100> | (1+0i)|1001> | | (1+0i)|1101> | (1+0i)|1101> | | (1+0i)|1110> | (1+0i)|1110> | | (1+0i)|1111> | (1+0i)|1111> | --------------------------------------- Factorisation can produce reordering, for example: ∣00〉〈0∣+∣10〉〈1∣→(∣0〉〈0∣+∣1〉〈1∣)⊗(∣0〉) . A factorised expression is only produced if it results in a reduction in computational complexity, which is not the case in this example because factorised and unfactorised expressions both contain the same number of summands, so there is no difference in their computational complexity. Since quantum algorithms are a sequence of unitary operators applied to an initial state-vector, we can factorise the state vector after each unitary operation. 1.14 Support for un-normalised spinors. This simulator supports un-normalised spinors, r e iα (cos θ 2 ∣0〉+e iϕ sin θ 2 ∣1〉) , to emphasise the geometry. Normalised spinors can only rotate a unit-vector to a new direction, whilst un- normalised spinors can also change the length, with r 2 as the scaling factor. 1.15 Support for Geometric Algebra, metric tensors and matrix decomposition. Geometric algebra is one of the more interesting branches of mathematics. It is based on the work of Grassmann and Clifford in the 19th Century. One can think of basis vectors as being “variables” satisfying ei e j=−e j ei ,i≠ j and ei 2 =±1 . From these simple rules, one can describe spaces of any dimension, the two most common being 3D Euclidean space, with ei 2 =1,1≤i≤3 , and 4D spacetime, with e1 2 =±1,ei 2 =∓1,2≤i≤4 . In these two spaces, the basis vectors can be represented by the Pauli and Dirac matrices from quantum mechanics. Any complex matrix can be decomposed as a0 e0 ⏟ identity +(a1e1+⋯+an en )+(a12 e1e2+⋯+an−1, n en−1 en )+⋯+a12 ⋯n e1⋯en . Given a user-defined diagonalisable metric tensor, this simulator will generate anti-commuting basis vectors, e. For example, a Minkowski metric will generate Dirac gamma-matrices as bases. Multivectors are then built, eg, multi=(1.0l+0.0il)+2*e[2]+((0.0l+12.0il)*e[1]^e[2]). The grade operator is given by _<multi>_(grade) and standard operations in GA are supported. The simulator can use factorised operators as a compact and efficient representation, and can decompose matrix-operators with respect to the generated basis vectors, using 8/60
  • 9. combinatorial pruning to skip terms making zero contribution. 1.16 Solutions to eigenvalue problems. This simulator provides an efficient method for obtaining the eigenvalues and eigenvectors of any square matrix, including matrices with degenerate eigenvalues. This simplifies one of the more difficult topics in quantum mechanics, namely, addition of angular momentum and Clebsch-Gordan coefficients. 1.17 Equations developed for this simulator. This simulator is based on the following equations, developed by the author: (1) An equation for diagonalising any square matrix, requiring a small number of matrix multiplications to achieve convergence. (2) An equation for separating a matrix into two matrices containing even and odd grade multivector blades, without the need to decompose the matrix into a full multivector. (3) An equation for decomposing a matrix into a multivector using combinatorial pruning, to reduce the search-space from 2 N possible blades to n , where n is the number of blades present in the matrix. This is equivalent to decomposing the matrix as a Clifford Algebra. (4) An equation for extracting multivector blades of a given grade from a matrix, without decomposing the matrix. This should not be used to construct the full multivector, since it contains redundant computation, insofar as different blades have common elements. (5) An equation for factorising matrices and vectors into tensor products. In the ideal case, 2 N summands become a tensor product of N subspaces. In a non-ideal case, the number of summands is reduced, but each summand is a tensor product of spaces, which contain summands and so on recursively. This recursive partitioning into subsapces can vary from summand to summand and between the operands to the inner product. These equations depend heavily on the inner product function used by this simulator. Due to the complexity of factorised, tensored expressions, this inner product function is far slower than matrix operations performed using libraries, such as BLAS, that do not require the additional logic needed and subspace copying to process complicated, tensored expressions. Finding a faster alternative is an ongoing concern and the simulator offers a feature to convert Dirac notation to the matrix notation of MATLAB and Mathematica, which can avail of fast, vectorised matrix operations. 1.18 Teaching quantum mechanics in high schools. The author has developed a technique for distilling derivations down to a few lines, enabling advanced quantum mechanics to be taught in high schools. School teachers familiar with quaternions will grasp the technique quite quickly. Quantum mechanics is largely geometry, in a form discovered much earlier by the classical geometers Grassmann, Clifford, Hamilton and Lie. It is a special case of geometric algebra and Dirac notation. It only appears odd, because we are taught geometry a different way in high schools that leaves us unprepared for Special Relativity and quantum mechanics, which are taught in an overly complicated way that obscures the geometrical simplicity one would expect of the fundamental building blocks of the Universe. In order to address this, Sections 8 and 9 contain two tutorials on quantum mechanics and geometric algebra. The former includes advanced topics and the latter is especially useful in showing that quantum mechanics is, largely, geometry. These tutorials contain coding examples that illustrate, for example, how to do Special Relativity with the simulator by using the quantum mechanics developed in the tutorial. The author believes that this can be taught in high schools. 9/60
  • 10. Section 2: Definitions and syntax Required header file and namespace: dirac.hpp, Quantum.. 2.1 Amplitudes An amplitude is defined through the following format: Amplitude := AmpOrPhase(long double +/- long double il) := “_” → AmpOrPhase(1.0l+0.0il); := (long double)*e^( long double il) := (long double or int)_f OR _C Examples: _, 1.0l+1.0il, 2.0l*e^(2*pi/3), 1_f. Un-normalised spinors are supported. 2.2 States A state is defined according to the following formats: State := integer _ number of qubits State := binary string _ number of qubits State := State<N>(integer) Example: 3_4, “0011”_4, State<4> state(3), State<4>(3) 2.3 Bras A bra is defined according to the following format: Bra := _<State|AmpOrPhase Example: _<3_4|(1.0il), _<“0011”_4|_ 2.4 Kets A ket is defined according to the following format: Ket := AmpOrPhase|State>_ Example: (1.0il)|3_4>_, _|“0011”_4>_ 2.5 Outer Products An outer product is defined according to the following format: Outer := AmpOrPhase|State>_<State|_ Example: (1.0il)|3_4>_<2_2|_, _|“0011”_4>_<2_2|_ 2.6 State Vectors A state vector is defined according to the following formats: [bra] State Vector := Bra +/- Bra … [ket] State Vector := Ket +/- Ket … where Fock spaces are disallowed and each bra or ket must have the same number of qubits. Example: _<3_2|(1.0il)+_<“10”_2|_, (1.0il)|3_2>_ + _|“10”_2>_ 2.7 Operators An operator is defined according to the following format: Operator := Outer +/- Outer … where the outer products must have the same number of qubits Example: (1.0il)|3_4>_<2_2|_ + _|“1000”_4>_<1_2|_ 2.8 Tensor Products and sums of tensor products A tensor product is defined according to the following formats: Tensor Product := (State Vector)*(State Vector)... Tensor Product := (Operator)*(Operator)... where the terms do not have to have the same number of qubits and state vectors are wholly bra or ket. Tensor products may be summed and further tensored: Tensor Sum := Tensor Product +/- Tensor Product ... Tensor Product := (Tensor Sum)*(Tensor Sum)... ⋮ Terms in a tensor sum must have the same number of qubits, terms in a tensor product do not. 10/60
  • 11. 2.9 Inner products An inner product is defined according to the following formats: Inner Product := ([bra] State Vector) | ([ket] State Vector) Inner Product := (Operator) | ([ket] State Vector) Inner Product := ([bra] State Vector) | (Operator) Inner Product := (Operator)(Operator) where state vectors and operators may be tensor products and sums of tensor products. 2.10 Conjugate transpose The conjugate transpose of a state vector or operator is defined according to the following formats: Conjugate Transpose := (State Vector)^dag Conjugate Transpose := (Operator)^dag where state vectors and operators may be tensor products and sums of tensor products. 2.11 Measurement and collapse Required header file and namespace: measurement.hpp, Quantum::Measurement. A partial or full collapse of a state vector is specified through the syntax M(_|0_1>_<0_1|_) and M(I), with I=_|0_1>_<0_1|_+_|1_1>_<1_1|_, where the former collapses a qubit and the latter leaves it in a superposition. These are tensored to match the dimensionailty of the state vector. The operator “^_XN” and “^_X(N)” will exponentiate these to the power N. Examples: H=(M(I)^_X2)*M(_|0_1>_<0_1|_)*(M(I)^_X(3))*(_|0_1>_<0_1|_) collapses only qubits 2 and 6 out of qubits 0 to 7, H=M(_|0_1>_<0_1|_)^_X8 collapses all 8 qubits out of qubits 0 to 7 and H=M(I)^_X8 collapses no qubits. To effect collapse, apply the operator H to the state vector: H|S>, <S|H. Qubits to be measured will collapse either to 0 or 1, whilst qubits not being measured will remain in their superposition state. This is a slow operation and if all qubits need to be collapsed then the user may define the operator: auto samp=sample(state vector). Once defined, this operator will generate a state at random, state=samp(), weighted by the modulus-squared of its probability amplitude. 2.11.1 Entangling a measuring device When a state vector collapses it may trigger some reaction or “hit” in a measuring device. This simulator models a device as a callback function: Device device(const AmpOrPhase a, const state& s, const std::string& str) { // “a” holds amplitude of collapsed state. // “s” holds the collapsed state, e.g. |001> // “str” holds the binary string, e.g. “001” for use in std::bitset }; The type of the state may be declared explicitly, e.g. KET<3> , or deduced, e.g decltype(_<”001”_3|_). The device is then entangled: auto H=M(...)*...*M(...)*M(device); auto samp=sample(state vector, device); Examples of the use of measurement are contained in the Introduction to quantum mechanics section, in which the double-slit is simulated. 11/60
  • 12. 2.12 Geometric Algebra and matrix decomposition Required header file and namespace: ga.hpp, Quantum::GA. Users not familiar with geometric algebra may wish to consult the chapter on this subject, before commencing with the simulator commands that implement the algebra. 2.12.1 Creating basis vectors The first step in using the simulator for GA is defining the Clifford Group CLp ,q through a diagonal metric tensor, M, eg: auto Euclidean=_|0_2>_<0_2|_ + _|1_2>_<1_2|_ + _|2_2>_<2_2|_; auto Minkowski= -1|0_2>_<0_2|_ + _|1_2>_<1_2|_ + _|2_2>_<2_2|_ + _|3_2>_<3_2|_; The user may then create basis vectors through the commands: auto e=_3D_[Euclidean]; and auto e=_4D_[Minkowski]; The basis vector, ei , is created dynamically and cached by the command e[i]. The basis vectors are the Pauli matrices for 3D Euclidean space, the Dirac matrices for 4D Minkowski space and the simulator will generate other bases for a specific metric and dimension: _{N}D_[Metric]. 2.12.1 Creating a multivector The user may now use the basis vectors to create a multivector from blades, using “^”: auto multivector=a + a_i*e[i] + a_j*e[j] + … + a_ij*e[i]^e[j] + ...; with the a's complex numbers. The simulator will generate a representation as an operator, which can be factorised into an equivalent operator with reduced computational complexity. Geometric products cannot be written as A B, in C++, and the syntax for this is: (A)(B). An N-dimensional multivector has up to 2 N coefficients ∑i=0 N ai ei+∑i , j≠i aij ei∧e j+⋯+a1⋯n e1∧⋯∧eN , corresponding to a 2 ⌊N /2⌋ ×2 ⌊N /2⌋ matrix. If a 2 ⌊N /2⌋ ×2 ⌊N /2⌋ matrix has complex elements, then the multivector is either N-dimensional and complex or (N+1)-dimensional and real, for example: N Basis vectors/Multivector 2 σ1 ,σ3 - the Pauli X and Z matrices / a0+a1 σ1+a3 σ3+a31σ3∧σ1 ⏟ 4 real or 4 complex 3 σ1 ,σ3 , i σ3σ1 ⏟ σ2- Pauli-Y / a0+a1 σ1+a3σ3+a2 σ2+a12σ1σ2+a23 σ2σ3+a31 σ31+a123 σ1 σ2σ2 ⏟ 8 real numbers can hold2×2complex numbers 4/5 γ0 ,γ1, γ2 ,γ3 and γ5=i γ0 γ1 γ2 γ3 Dirac matrices This property of dimensions is well-known to group theoreticians familiar with the Clifford Group. This simulator is based on equations developed by the author allowing fast matrix operations using GA and fast GA operations using matrix operations. 2.12.2 Selecting grades A particular grade, g, is obtained via: _<multivector>_(g); or they may be listed via: for(auto g:_<multivector>_all) std::cout << _<multivector>_(g) << std::endl; 12/60
  • 13. 2.12.3 Decomposing matrices A matrix operator, OP, can be decomposed with respect to basis vectors through the commands: auto mv=_<(OP,BASIS)>_; eg _<(2|0_1>_<0_1|_+ …,_3D_[Euclidean])>_; auto grade=_<(OP,BASIS)>_(g); eg _<(2|0_1>_<0_1|_+ …,_3D_[Euclidean])>_(2); A square matrix not in the form 2 ⌊N /2⌋ ×2 ⌊N /2⌋ can still be decomposed, with rows and columns being zeroed out. Operators allow this because, for example, M (3×3) =∣00〉〈00∣+∣00〉〈01∣+∣00〉〈10∣+∣01〉〈00∣+∣01〉 〈01∣+∣01〉〈10∣+∣10〉〈00∣+∣10〉〈01∣+∣10〉〈10∣ is a 3×3 matrix formed by setting the last row and column of a 4×4 matrix to zero. This is valid, because it may be applied to a 3-vector, such as, V(3×1) =∣00〉+∣01〉+∣10〉 , which is equivalent to the 4-vector V(4×1) =∣00〉+∣01〉+∣10〉+(0)∣11〉 , with the last component set to 0. 2.13 General Geometric Algebra commands A plethora of notational variations has arisen amongst proponents of GA, so this simulator shall employ a more uniform syntax. The following operations of geometric algebra are supported: GA Operation Grade operator Example/meaning Simulator command Decompose matrix NA Decompose a matrix, written as an operator, wrt a basis, e.g. _3D_[Euclidean] _<(OP,Basis)>_ Grade extraction NA Do not decompose matrix, just obtain a grade, k. _<(OP,Basis)>_(k) Even and odd grades NA Do not decompose matrix, just seperate into two matrices with even and odd grades m= _<OP,Basis>_even_an d_odd m[0] – even m[1] - odd Involution NA B=ei e j⋯ek ⏟ k-blade →(−1) k ei ej ⋯ek B^_ or _<(m[0]-m[1],Basis)>_ Reversion ̃ A NA Reversion: ei e j ⋯ek →ek ⋯e j ei ~A or (for Hermitian bases) _<(A^dag,Basis)>_ AB= ∑k , k ' Ak Bk ' NA Geometric product: (x1 ex+y1 ey+⋯) (x2 ex+y2 ey+⋯)= x1 y1+x2 y2+x1 y2ex ey+⋯ (A)(B) Scalar product A∗B 〈 AB〉0 a ⏟ number ⋅ v ⏟ vector =〈a v〉0=0 〈(x1 ex+y1 ey )(x2ex+y2 ey )〉0 = x1 y1+x2 y2 A*B or _<A,B>_0 Outer product Ak∧Bk ' Ak∧Bk '=〈 AB〉k+k ' A∧B=∑ k , k ' 〈〈 A〉k 〈 B〉k ' 〉k+k ' a ⏟ number ∧ v ⏟ vector =〈a v〉1=av 〈(x1 ex+y1ey )(x2 ex+y2e y)〉2 = (x1 y2−x2 y1)ex ey A^B Right contraction Ak ⌊ Bk '≤k 〈Ak Bk ' 〉k−k ' (B⋅A∥B) A⊥B Example: A|_(B) 13/60
  • 14. A ⌊ B= ∑ k , k '≤k 〈〈A〉k 〈B〉k ' 〉k−k ' ≡I ((I −1 A)∧B) a(e1e2)⌊ be2=abe1 Left contraction Ak ⌋ Bk '≥k 〈Ak Bk ' 〉k '−k A ⌋ B= ∑ k , k '≥k 〈〈A〉k 〈B〉k ' 〉k−k ' ≡( A∧(B I −1 )) I (A⋅B∥A)B⊥A Example: a e1 ⌋b(e1 e2)=ab e2 ~((~B)|_(~A)) or _(A)|B; Inverse Ak −1 A −1 ̃ Ak 〈Ak Ak 〉0 ≡ Ak 〈Ak Ak 〉0 The inverse: Ak −1 Ak =Ak Ak −1 =1 A^(-1) Projection P{Bk } Ak ' (Ak ⌋ Bk ' )Bk ' −1 ≡(Ak ⌋ Bk ' −1 )Bk ' Component of Bk parallel to Ak ' : B∥A P_[B](A) Rejection R{Bk } Ak ' (Ak∧Bk ' )Bk ' −1 Component of Bk perpendicular to Ak ' : B⊥ A R_[B](A) e multivector NA Exponentiation, e.g Rx=e e2∧e3 θ/2 e^multivector or _e_^multivector log NA Logarithm of multivector log(multivec) Square root NA Square root of multivector Mvec^0.5 or std::sqrt|mvec mvec p NA Multivector to the power p mvec^p Eigen decompos NA Eigenvalues and eigenvectors of multivector auto m=eig(mv); m[0] – eigenvectors as columns m[1] eigenvalues as diagonal matrix m[2]=m[0]^-1 Pseudoscalar I N NA I N =e1∧⋯∧eN I N 2 =−1 [I N =odd ,ei ]=0 commutes. {I N =even ,ei }=0 anticommutes. auto e= _{N}D_[Metric]; auto I_{N}=e[-1]; with {N} an integer dimension, e.g. 4. These form the basic elements from which the user can implement equations from standard texts. The simulator provides for the basis qualifiers _0D_ to _59D_, so that _3D_[Euclidean] will compile. Additional qualifiers can be created by the user in blocks of 10, through the command: GEN10(N1,N2,N3,N3,N5,N6,N7,N8,N9), or just one with GEN1(N1), where each N is an integer not previously used. For example, should the user need _100D_[Metric], they can call GEN1(100), either in a header file or locally scoped to some function. 14/60
  • 15. Section 3: Functions Required header file and namespace: functions.hpp, Quantum. 3.1 Norm: _|(...)|_ The norm of a state vector or Hilbert-Schmidt norm of an operator are defined according to the following formats: Norm := _|(State Vector)|_ Norm := _|(Operator)|_ where state vectors and operators may be tensor products and sums of tensor products, and the norm is a long double. The norm to a power is also supported: _|(...)|_^power. 3.2 Tensor power (“^_X” and “P”) A state vector or operator may be tensored N times, at compile-time, through the format: Tensor := (State Vector)^_XN or _X(N) Tensor := (Operator)^XN or _X(N) Example: (_|0_1>_<0_1|_ + _|1_1>_<1_1|_)^_X5 creates a 5-qubit identity operator. The related operator _X(CONSTANT EXPRESSION) may be used with arithmetic expressions, example: (_|0_1>_<0_1|_ + _|1_1>_<1_1|_)^_X(2+3). For the run-time exponent, i, we use Tensor := (State Vector)^P{i} Tensor := (Operator)^P{i} 3.3 Trace The trace of a square operator is defined according to the following format: Trace := tr(Operator) where operators may be tensor products and sums of tensor products. 3.4 Commutators and anticommutators The commutator of two operators is defined through the following format: Commutator := _[Operator,Operator] The anticommutator of two operators is defined through the following format: Anticommutator := _({Operator,Operator}) with the latter having a slightly different syntax due to the restrictions of the C++ compiler. 3.5 Eigendecomposition The eigenvalues and eigenvectors of a square operator are obtained in the following way: auto decomp = eig(Operator) or eig(Operator, Simultaneous) where Simultaneous is a second operator, such as J z that commutes with Operator and the result contains the right eigenvectors, as columns, the diagonal matrix of eigenvalues and the left eigenvectors as columns, so that Operator=(decomp[0])(decomp[1]) (decomp[2]). This simulator uses a proprietary method for obtaining eigenstates that applies generally and does not require raising and lowering operators to be defined. It may be used to obtain ∣J , J z 〉 eigenstates from ∣J 1 , J z 1 〉⊗∣J 2 , J z 2 〉 , bypassing the standard method for addition of angular momentum. An example of this is given in Introduction to quantum mechanics. 3.6 Matrix exponential and other functions This simulator allows the exponential and powers of a matrix to be obtained, via e^(operator), operator^(power). Any C++ STL function that accepts a complex value can be applied to a matrix, via func|operator, where std::func represents an STL function, e.g. std::log. User-defined functions are also supported, where func takes the form: auto func=[](const AmpOrPhase& c){ return some_func(c); }. 15/60
  • 16. 3.7 Relational operations State vectors and operators may be checked for equality, up to a global phase: [State Vector or Operator] == [State Vector or Operator] [State Vector or Operator] != [State Vector or Operator] In the case of equality, the global phase difference may be extracted: phase=[State Vector or Operator]/[State Vector or Operator] These operations are slow and involve checking whether the state vectors or operators are parallel. Amplitudes can also be checked for equality: eq(AmpOrPhase,AmpOrPhase) or eq(AmpOrPhase,AmpOrPhase,tolerance(real,imag)) 3.8 Combining additions Required header and namespace: vec.hpp, Quantum. Very often, additions lead to duplicated terms, e.g. S+=_|0>_ → (2.0l+1.0il)|0>_+_|0>_ . This can be avoided by using auto merge=merge_additions(S) and merge+=variable; This will combine terms, e.g. S->(3.0l+1.0il)|0>_. This applies to state vectors and operators and also to merge-=variable. 3.9 Printing state vector and operators State vectors and operators are displayed through the following constructs: std::cout << State Vector << std::endl; std::cout << Operator << std::endl; They are displayed in Dirac notation, with tensor products denoted by “*”. 3.9.1 Converting to vectors, matrices and Octave Required header file and namespace: common.hpp, Quantum. The function to_matrix(State Vector or Operator) will convert a bra-vector to a row vector, a ket-vector to a column vector and an operator to a matrix. The functions to_octave(to_matrix(State Vector or Operator)) and to_wa(to_matrix(State Vector or Operator))convert the vector or matrix to the Matlab and Wolfram Alpha format, respectively, for copying and pasting into these applications. 3.10 Running Octave Required header file and namespace: common.hpp, Quantum. If Octave is installed as some_dir/octave-cli.exe the simulator can send commands to Octave, via: auto octave_object=Octave(“some_dir/octave-cli.exe”); octave_object << “command1” << “command2” … << “commandN” << run; This is useful for such operations as plotting results. An Octave window remains open and the execution of the simulator blocks, until the user exits Octave. Each of the commands will be sent to Octave, each is terminated by a semi-colon “;” and after “run” Octave will open and execute each of these commands, as if they had been entered manually. 3.11 Random numbers Required header file and namespace: common.hpp, Quantum. A random, complex number in the ranges (lower_real,upper_real),(lower_imag,upper_imag) may be generated from the commands: random({lower_real,lower_imag},{upper_real,upper_imag}) random({upper_real,upper_imag}) where the second function uses default values of zero for the lower bounds. 16/60
  • 17. Section 4: Gates Required header file and namespace: gates.hpp, Quantum::Gates. 4.1 Standard gates (X, Y, Z, H, T, S, R( θ )) and the truth_table command The single-qubit gates X, Y, Z, H, T, S and R are supported and their truth table may be generated through the command truth_table(gate); Example truth_table(Gates::H) : Truth table for H=(0.70710678118655+0i)|0><0|+(0.70710678118655+0i)|0><1|+(0.70710678118655+0i)|1><0|+(-0.70710678118655+0i)|1><1| -------------------------------------------------------------------------- | Input | Output | -------------------------------------------------------------------------- | (1+0i)|0> | (0.70710678118655+0i)|0>+(0.70710678118655+0i)|1> | | (1+0i)|1> | (0.70710678118655+0i)|0>+(-0.70710678118655+0i)|1> | -------------------------------------------------------------------------- This command applies to any operator or quantum algorithm on N qubits, but caution is warranted when the number of input states, 2 N , is large, since it will enumerate all of them. Outputs are not given as vectors or matrices, because these are often large, sparse and obscure the simplicity of their representation as spinors. It is the exponentially large size of the state-space that prevents all quantum algorithms being reduced to lookups on their truth tables, during inner products and measurements: For example, an operator or algorithm may yield (∣0〉+∣1〉) ⊗N 2 N , whose modulus would require (2N ) 2 =22N inner products on the summands if expanded out, but only N inner products on the (〈0∣+〈1∣) and (∣0〉+∣1〉) subspaces in the operands that are then multiplied. 4.2 SWAP An N-qubit swap-operator that swaps qubits qi and q j is specified through the following format: auto swp_4_1_3=SWAP(N,q_i,q_j); where N is the number of qubits and qubits q_i and q_j are to be swapped. 4.3 Controlled-U An N-qubit unitary operator to be applied iff the control-qubits {qi ,q j ,...} satisfy the bit-pattern {bi ,bj ,...} is specified through the following format: auto cu = CU([U] Operator, C( qi ,bi ),C( q j ,b j ),...) Example - Controlled-SWAP auto swp_4_1_3=SWAP(4,1,3); CU(swp_4_1_3, C(0,1),C(2,0)); swaps qubits 1 and 3 iff qubit 0 is 1 and qubit 2 is 0. CU(swp_4_1_3, C(1,1),C(3,0)); swaps qubits 1 and 3 iff qubit 1 is 1 and qubit 3 is 0. The truth table for the factorised CU(swp_4_1_3, C(1,1),C(3,0)) is given below: 17/60
  • 18. Truth table for cu_0_1_2_0_swp_4_1_3=(2.8284271247+0i)|0><0| * [(0.7071067812+0i)|0><0| * {(0.7071067812+0i)| 0><0| * ((0.7071067812+0i)|0><0|+(0.7071067812+0i)|1><1|) + (0.7071067812+0i)|1><1| * ((0.7071067812+0i)|0><0| +(0.7071067812+0i)|1><1|)} + (0.7071067812+0i)|1><1| * {(0.7071067812+0i)|0><0| * ((0.7071067812+0i)|0><0| +(0.7071067812+0i)|1><1|) + (0.7071067812+0i)|1><1| * ((0.7071067812+0i)|0><0|+(0.7071067812+0i)|1><1|)}] + (2.8284271247+0i)|1><1| * [(0.7071067812+0i)|0> * {(0.7071067812+0i)|0> * ((0.7071067812+0i)|0><000| +(0.7071067812+0i)|1><100|) + (1+0i)|1><0| * ((0.5+0i)|0><10|+(0.5+0i)|1><11|)} + (0.7071067812+0i)|1> * {(0.7071067812+0i)|0> * ((0.7071067812+0i)|0><001|+(0.7071067812+0i)|1><101|) + (1+0i)|1><1| * ((0.5+0i)|0><10| +(0.5+0i)|1><11|)}] --------------------------------------- | Input | Output | --------------------------------------- | (1+0i)|0000> | (1+0i)|0000> | | (1+0i)|0001> | (1+0i)|0001> | | (1+0i)|0010> | (1+0i)|0010> | | (1+0i)|0011> | (1+0i)|0011> | | (1+0i)|0100> | (1+0i)|0100> | | (1+0i)|0101> | (1+0i)|0101> | | (1+0i)|0110> | (1+0i)|0110> | | (1+0i)|0111> | (1+0i)|0111> | | (1+0i)|1000> | (1+0i)|1000> | | (1+0i)|1001> | (1+0i)|1100> | | (1+0i)|1010> | (1+0i)|1010> | | (1+0i)|1011> | (1+0i)|1011> | | (1+0i)|1100> | (1+0i)|1001> | | (1+0i)|1101> | (1+0i)|1101> | | (1+0i)|1110> | (1+0i)|1110> | | (1+0i)|1111> | (1+0i)|1111> | --------------------------------------- 18/60
  • 19. Section 5: Creating and debugging quantum algorithms. Required header file and namespace: algorithm.hpp, Quantum::Algo. An N-qubit quantum circuit is a unitary operator that itself comprises M unitary operators, “stages”, applied sequentially, the quintessential example being the quantum Fourier transform. To create a quantum algorithm, A, one simply derives from the class Algo::Algorithm and then adds the M unitary operators using (*this)+=operator. The following functions are then available to A: A|State Vector>_ and _<State Vector|A – runs the algorithm on the state vector. A^dag – returns the inverse algorithm, such that (A^dag)(A)=(A)(A^dag)=I. A.size() – returns the number of stages. std::cout << A; – Prints, sequentially, each of the M unitary operators. 5.1 Adding measurements The user may add a measurement, described in the section “Measurement and collapse”, after each of the M unitary operators has been applied. The Algorithm class allows for the attachment of a callback function: A >> measure; This must be done before execution of the algorithm begins and the callback must have the form: Algo::Measure measure=[&](size_t i, const State Vector& after) { //i – contains the sequence number of the operator, 0 to M-1 //after - contains the state vector after the i-th operator. //Perform measurement on after return after; // Must return to quantum algorithm. }; To avoid recursive calls to the callback when the algorithm is used in the callback, a copy must be made and the callback switched off: algo_copy >> Measure(); 5.2 Debugging In order to simplify debugging, the Algorithm class allows for the attachment of a callback function: A >> debug; This must be done before execution of the algorithm begins and the callback must have the form: Algo::Debug debug=[&](size_t i, const Operator& op, const State Vector& before, const State Vector& after) { //i – contains the sequence number of the operator, 0 to M-1 //op – contains the i-th operator. //before - contains the state vector before the i-th operator //after - contains the state vector after the i-th operator. }; To avoid recursive calls to the callback when the algorithm is used in the callback, a copy must be made and the callback switched off: algo_copy >> Debug(); 19/60
  • 20. 5.3 Coding example – 3 qubit Quantum Fourier Transform. An n-qubit quantum Fourier transform satisfies: QFT∣x〉 = 1 √2 n ⊗j=1 j=n (∣0〉+[e i 2π x2n− j /N ]∣1〉) . It can be implemented as unitary operator with Hadamard, H, and phase, R, gates (Credit: Wikipedia): followed by reversing the order of the output qubits, using swap gates. It is very easy to implement this, using the simulator: //N-qubit quantum Fourier transform circuit template<size_t N> struct QFT : public Algorithm<N> { QFT(void) { create(); } void create(void) { using namespace Gates; auto& t=*this; //Loop over stages for(size_t i=0; i<N; ++i) { //Add the Hadamard gate t+=(I^P{i})*H*(I^P{N-(i+1)}); //Add the phase gates for(size_t j=1; j<(N-i); ++j) { AmpOrPhase phase=2.0l*pi/((2.0l+0il)^(j+1)); auto gate=(I^P{i})*R(phase)*(I^P{N-(i+1)}); t+=CU(OP<N>(gate),C(i+j,1)); } } //Add the final swap gates for(size_t i=0; i<(N/2); ++i) { t+=swp(N,i,N-1-i); } } }; We then wish to test it. To do this, we use the truth_table function on the 3-qubit algorithm QFT<3> , which will invoke the algorithm against |000> to |111> . We attach a callback function, which will be called for each invocation, after each stage of the algorithm, and verifies that the final stage output is correct and also that (QFT^1 QFT)|input>=|input> . Finally, we also attach a mock measurement callback, which only prints out the output of each stage, but that could do a measurement after each stage. 20/60
  • 21. //Create 3-qubit QFT static constexpr size_t N=3; QFT<N> qft; //Debugging callback to perform sanity checks on algorithm //Will be called every time the truth_table function calls qft|input_state> size_t input_state=0; //to be incremented with each truth_table call Algo::Debug debug= [&](size_t stg, const OP<N,N>& op, const KET<N>& before,const KET<N>& after) { //Wait until end of algorithm bool run_sanity_checks=(stg==qft.size()-1); if(run_sanity_checks) { std::bitset<N> input(input_state); std::cout << "Sanity checks on |"<< input << ">" << std::endl; typedef AmpOrPhase A; KET<0> tmp; //Manually calculate expected result of qft|input_state> for(size_t j=1; j<=N; ++j) { AmpOrPhase normalisation=(1.0l/(AmpOrPhase(2.0l)))^(0.5l); AmpOrPhase a=(e^(2_f*pi*i/(2_f^N)))^(A(input_state)*(2_f^(N-j))); if(j==1) tmp=normalisation*(_|0_1>_ +a|1_1>_); else tmp*=(normalisation*(_|0_1>_ +a|1_1>_)); } auto ket=KET<N>(tmp); //Check expected results equals actual result expected(ket)==actual(after); expected(true)==actual(eq(1,ket/after,tolerance(1e-15,1e-15))); //Check that (qft^1 qft)|input_state> == |input_state> auto tmp_qft=qft; tmp_qft >> Debug() >> Measure(); //switch off callback recursion auto in=_|State<3>(input_state)>_; expected((tmp_qft^dag)|after>_)==actual(in); expected(true)==actual(eq(1,((tmp_qft^dag)|after>_)/in, tolerance(1e-15,1e-15))); ++input_state; } }; //Callback to to a mock measurement Algo::Measure measure=[&](size_t i, const KET<N>& aft) { std::cout << "measure: " << i << " " << aft << std::endl; return aft; }; //Attach callbacks to quantum algorithm qft >> debug >> measure; //Run quantum algorithm by calling the truth table truth_table(qft); The output for the first input state, |000>, is shown, below, along with the truth table: 21/60
  • 22. measure: 0 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * (1+0i)|00> measure: 1 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * (1+0i)|00> measure: 2 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * (1+0i)|00> measure: 3 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * (1+0i)|0> measure: 4 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * (1+0i)|0> measure: 5 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] Sanity checks on |000> Test 1): [File: undefined, function: operator(), line: 144]: ket[aka [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>]] == after[aka [(0.7071067812+0i)| 0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>]] is true Test 2): [File: undefined, function: operator(), line: 145]: true[aka true] == eq(1,ket/after,tolerance(1e-15,1e-15))[aka true] is true Test 3): [File: undefined, function: operator(), line: 150]: (tmp_qft^dag)|after>_[aka (1+0i)|000>] == in[aka (1+0i)|000>] is true Test 4): [File: undefined, function: operator(), line: 151]: true[aka true] == eq(1,((tmp_qft^dag)|after>_)/in, tolerance(1e-15,1e-15))[aka true] is true measure: 6 [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] ⋮ Truth table for qft= Stage 0: [(0.7071067812+0i)|0><0|+(0.7071067812+0i)|0><1|+(0.7071067812+0i)|1><0|+(-0.7071067812+0i)|1><1|] * [(1+0i)|0><0|+(1+0i)|1><1|] * [(1+0i)|0><0|+(1+0i)|1><1|] Stage 1: [(1+0i)|0><0|+(0+1i)|1><1|] * (1+0i)|1><1| * [(1+0i)|0><0|+(1+0i)|1><1|] + [{(1+0i)|0><0|+(1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} + {(-1+0i)|0><0|+(-1+0i)|1><1|} * (1+0i)|1><1| * {(1+0i)|0><0| +(1+0i)|1><1|}] Stage 2: [(1+0i)|0><0|+(0.7071067812+0.7071067812i)|1><1|] * [(1+0i)|0><0|+(1+0i)|1><1|] * (1+0i)|1><1| + [{(1+0i)|0><0|+(1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} + {(-1+0i)|0><0|+(-1+0i)|1><1|} * {(1+0i)| 0><0|+(1+0i)|1><1|} * (1+0i)|1><1|] Stage 3: [(1+0i)|0><0|+(1+0i)|1><1|] * [(0.7071067812+0i)|0><0|+(0.7071067812+0i)|0><1|+(0.7071067812+0i)|1><0|+(-0.7071067812+0i)|1><1|] * [(1+0i)|0><0|+(1+0i)|1><1|] Stage 4: [(1+0i)|0><0|+(1+0i)|1><1|] * [(1+0i)|0><0|+(0+1i)|1><1|] * (1+0i)|1><1| + [{(1+0i)|0><0|+(1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} + {(-1+0i)|0><0|+(-1+0i)|1><1|} * {(1+0i)|0><0|+(1+0i)|1><1|} * (1+0i)|1><1|] Stage 5: [(1+0i)|0><0|+(1+0i)|1><1|] * [(1+0i)|0><0|+(1+0i)|1><1|] * [(0.7071067812+0i)|0><0|+(0.7071067812+0i)|0><1|+(0.7071067812+0i)|1><0|+(-0.7071067812+0i)|1><1|] Stage 6: (1+0i)|0><0| * [(1+0i)|0><0|+(1+0i)|1><1|] * (1+0i)|0><0|+(1+0i)|1><0| * [(1+0i)|0><0|+(1+0i)|1><1|] * (1+0i)|0><1|+(1+0i)|0><1| * [(1+0i)|0><0|+(1+0i)|1><1|] * (1+0i)|1><0|+(1+0i)|1><1| * [(1+0i)|0><0|+(1+0i)|1><1|] * (1+0i)|1><1| ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | Input | Output | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | (1+0i)|000> | [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] | | (1+0i)|001> | [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0+0.7071067812i)|1>] * [(0.7071067812+0i)|0>+(0.5+0.5i)|1>] | | (1+0i)|010> | [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0+0.7071067812i)|1>] | | (1+0i)|011> | [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0-0.7071067812i)|1>] * [(0.7071067812+0i)|0>+(-0.5+0.5i)|1>] | | (1+0i)|100> | [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] | | (1+0i)|101> | [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0+0.7071067812i)|1>] * [(0.7071067812+0i)|0>+(-0.5-0.5i)|1>] | | (1+0i)|110> | [(0.7071067812+0i)|0>+(0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0-0.7071067812i)|1>] | | (1+0i)|111> | [(0.7071067812+0i)|0>+(-0.7071067812+0i)|1>] * [(0.7071067812+0i)|0>+(0-0.7071067812i)|1>] * [(0.7071067812+0i)|0>+(0.5-0.5i)|1>] | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ 22/60
  • 23. Section 6: Header files and namespaces The following header files and namespaces are required to compile the various packages offered by the simulator: Header file Namespace Description dirac.hpp Quantum Required in all code and allows Dirac notation to be complied and run, using C++ operator-overloading. measurement.hpp Quantum::Measurement Provides measurement operations. gates.hpp Quantum::Gates Provides quantum gates. algorithm.hpp Quantum::Algo Provides template for quantum algorithms and circuits. functions.hpp Quantum Provides matrix functions and eigendecomposition. ga.hpp Quantum::GA Allows geometrical algebra notation to be compiled and run, provides GA package of functions. truth_table.hpp Quantum Provides truth table display. common.hpp Quantum Provides helper functions to_matrix, to_octave, to_wa, Octave - command pipe and the random number generator function random. verify.hpp Test Provides the expected(val)==actual(result) command, terminates on first failure, prints out function name and line number of the test and the the number of tests and passes. See section “Miscellaneous - Testing” vec.hpp Quantum Provides merge_additions. dirac.hpp Quantum::Fixed_Point_Arithmetic Provides fixed point arithmetic functions. 23/60
  • 24. Section 7: Miscellaneous 7.1 Testing Required header file and namespace: verify.hpp, Test. The simulator offers a very simple testing interface. The syntax expected(A)==actual(B) compares the expected value, A, against the actual value, B. It prints the name of the function and line number, together with true if the comparison is true or false otherwise. Execution will terminate on the first failed test. At the end, it will print the total number of tests and number that passed. 7.2 Conventions 7.2.1 Qubit left-to-right numbering The simulator uses ∣q0 q1 ...qn−1〉 . 7.2.2 Inner product convention for kets and bras The inner product between two kets is, by convention, taken to be the tensor product: ∣kl 〉|∣kr 〉→∣kl kr 〉 . For bras, we have (∣00〉〈1∣)(∣11〉)=∣001〉⇒(〈11∣)(∣1〉〈00∣)=(∣001〉) † =〈001∣ ⇒ 〈1∣ ∣ 〈00∣=〈001∣⇒〈i∣ ∣ 〈 j∣=〈 j∣⊗〈i∣ (∣00〉〈1∣)(∣11〉〈11∣)=∣001〉〈11∣ ⇒ (∣11〉〈11∣)(∣1〉〈00∣)=(∣001〉〈11∣) † =∣11〉〈001∣ ⇒ (∣11〉〈1∣)(〈00∣)=∣11〉〈001∣⇒(∣i 〉〈 j∣)(〈k∣)=∣i 〉〈k∣⊗〈 j∣ Example: L| R (L| R) † =R † | L † L =(2+0i)|000><10|+(3+0i)|001><11| 012 01 012 01 LLL LL LLL LL R =(0+2i)|100><000|+(0+3i)|110><001| 012 012 012 012 RRR RRR RRR RR L|R=(0+4i)|0000><000|+(0+9i)|0010><001| 0123 012 0123 012 LR =(0-2i)|000><100|+(0-3i)|001><110| 012 012 012 012 LLL LLL LLL LLL L † =(2+0i)|10><000|+(3+0i)|11><001| 01 012 01 012 RR RRR RR RRR R † | L † =(0-4i)|000><0000|+(0-9i)|001><0010| 012 0123 012 0123 RL 7.3 Ongoing and future development This includes: 1. Replacing the inner product function, which is slow, because it contains logic needed to handle complicated factorised experessions. It can fail. 2. Numerical solutions to the Dirac equation. 3. Lorentz-invariant spacetime discretisation and simulation of General Relativity as a point- wise similarity transformation of the Minkowski metric. 24/60
  • 25. 7.4 Rounding errors Rounding errors have proven to be a significant problem. A result that is only zero to within some tolerance, δ , has a precision of √δ in the modulus of null-vectors: ∣∣NULL 〉=(∣ψ〉−∣ψ〉)∣= √〈 NULL∣NULL〉≈√δ . This causes checks for zero, to within some tolerance, to fail, which can lead to a crash. It can also lead to tests for equality between two results to fail when they are the same, which is a problem when checking that a factorised expression is the same as an unfactorised expression. It also leads to very much reduced precision for eigenvectors and eigenvalues. This problem is under investigation and checks for equality between state vectors or operators use ψ1 is parallel to ψ2 , which gives higher accuracy than the test ∣ψ1−ψ2∣≈0 The simulator defaults to the precision of a long double (18 significant figures) in calculations, and 15 to 18 significant figures for comparisons ad 14 significant figures in printed values. 7.4.1 Display precision Required header file and namespace: dirac.hpp, Quantum. The commands: SetPrecision precision(integer N_significant_figures); SetPrecision precision(integer N_significant_figures, integer N_decimal_places); set the number of significant figures to N_significant_figures in printed values, with rounding, and, optionally, also round to N_decimal_places. Upon going out of scope, the local variable, “precision”, restores the previous values. This can be used, case-by-case, to round to the nearest integer, to improve readability, for example: -0.99999999999999 → -1, 1.009999999999999 → 1.01. The outputs in this user-guide generally use SetPrecision precision(14,10). 7.4.2 Exploiting rounding errors It is often the case that rounding errors can be exploited in tests. Suppose, for example, one has the state-vector ψ=(α∣0〉+β∣1〉)⊗∣q∈{0,1}〉 and wishes to test whether q is 0. This may be done through ∣[(〈0∣+〈1∣)⊗〈0∣]∣ψ〉∣≠0 , even when β=−α , provided 〈q=i∣q= j〉=δij with exactitude. This is because of rounding errors on the first qubit, which will result in a small, but non-zero value. This, however, would fail for exact or very precise arithmetic and the alternatives ∣[(〈0∣(1+δ)+〈1∣(1−δ))⊗〈0∣]∣ψ〉∣≠0 or ∣[〈0∣⊗〈0∣]∣ψ〉∣+∣[〈1∣⊗〈0∣]∣ψ〉∣≠0 would be necessary. This can, of course, give rise to unintended consequences, in which results are correct until precision is improved, at which point they become incorrect. 25/60
  • 26. Section 8: Tutorial - Introduction to Quantum Mechanics 8.1 Qubits, spinors and higher dimensional Hilbert spaces We denote a qubit as ∣0〉 or ∣1〉 , which correspond to the column vectors (1 0) and (0 1) , respectively. We denote their duals as 〈0∣ or 〈1∣ , corresponding to the row vectors (1,0) and (0,1) , respectively. We denote the inner product as 〈i∈{0,1}∣j∈{0,1}〉= δij . We denote a spinor as α0∣0〉+α1∣1〉 , corresponding to the column vector (α0 α1) , where α∈ℂ and ∣α0∣ 2 +∣α1∣ 2 =r2 , with r a real “length”, which is 1 in quantum mechanics. We denote the dual as ̄ α0〈0∣+ ̄ α1 〈1∣=(α0∣0〉+α1∣1〉) † , corresponding to the row vector ( ̄ α0 , ̄ α1) , where ̄ α denotes the complex conjugate and † denotes the conjugate transpose, aka Hermitian transpose. We denote a 2×2 complex matrix-operator as M =∑i=0, j=0 i= j , j=1 mij∣i 〉〈 j∣ , which corresponds to the matrix (m00 m01 m10 m11 ) , m∈ℂ . Each term in the matrix operator can be applied, on the left, to a spinor and, on the right, to some dual: (mij∣i〉〈 j∣)(αk∣k 〉)≡mij αk∣i 〉〈 j∣k 〉= mij αk δ jk∣i 〉 and (〈k∣βk )(mij∣i〉〈 j∣)≡mij βk 〈k∣i〉〈 j∣= 〈 j∣mij βk δki . This spinor belongs to a complex, 2D Hilbert space, which simply means a 2D vector with complex components. We can enlarge our space to any dimension, by increasing the number of qubits, so that N qubits produce a 2 N dimensional column vector, ∑i=1 2 N −1 αi∣i 〉=∑i=1 2 N −1 ∣bit0(i)〉⊗⋯⊗∣bit2 N −1 (i)〉 or row vector, which belongs to a complex 2 N - dimensional Hilbert space, and a 2 N ×2 N matrix-operator: M =∑i , j mij∣i 〉〈 j∣ One may well ask how we represent matrices and vectors whose dimensionality, D , is not a power of 2. The most straightforward way to do this is to create vectors of size 2⌈log2( D)⌉ , matrices of size 2⌈log2( D)⌉ ×2⌈log2 (D)⌉ and then remove rows and columns by setting them to zero. For example, a 3-vector would become a 4-vector with the last element set to 0, a0∣00〉+a1∣01〉+a2∣10〉 , and a 5×3 matrix would be an 8×8 matrix with the last 3 rows and the last 5 columns set to zero, ∑i=0, j=0 i=4, j=2 mij∣i〉〈 j∣ , where i and j contain ⌈log2(5)⌉=3 qubits, giving a 2 3 ×2 3 matrix that has been pared down to a 5×3 matrix. This will not produce zeros for determinants and eigenvalues, since, for example, a 4×4 matrix with the last row and column zeroed, will behave exactly the same as a 3×3 matrix. Finally, quantum mechanics also contains continuous variables, such as position and momentum, for which the best we can do is “digitise” them, using a sufficient number of qubits to achieve a 26/60
  • 27. desired accuracy, whilst being aware that this is not terribly rigorous, in terms of continuously differentiable manifolds. It is well-known that this breaks Special Relativity, because it “pixelates” spacetime, with each “pixel” being unable to undergo Lorentz contraction and time dilation. 8.2 Pauli matrices and SU(2) Paul matrices comprise the 2×2 identity matrix-operator, σ0=∣0〉〈0∣+∣1〉〈1∣ and the three matrix-operators σx=σ1=∣0〉〈1∣+∣1〉〈0∣, σy=σ2=−i∣0〉〈1∣+i∣1〉〈0∣, σz=σ3∣0〉〈0∣−∣1〉〈1∣ . They satisfy the following: (1) σi=σi † (2) σi 2 =1 (3) {σi ,σj }=σi σ j+σ j σi =2δij I ⇒σi>0σ j>i=−σ j σi From these we find the further identities: (σ1 σ2σ3) 2 =−1 and σi σ j=δij+i ϵijk σk .These properties make them suitable to be treated as “orthonormal basis vectors” and in quantum mechanics the Pauli-vector is defined to be vPauli=x1σ1+x2 σ2+x3 σ3 , corresponding to the matrix ( x3 x1−i x2 x1+i x2 −x3 ) . The qubits ∣0〉 and ∣1〉 are the eigenvectors of σ3 , whilst (x1=r sinθcosϕ)σ1+( x2=r sinθsin ϕ)σ2+( x3=r cosθ)σ3 has corresponding eigenvectors {∣S0〉=cos(θ/2)e −i ϕ/2 ∣0〉+sin(θ/2)e iϕ/2 ∣1〉 〈S1∣S0 〉=0⇒∣S1〉=sin(−θ/2)e −iϕ/2 ∣0〉+cos(θ/2)e +i ϕ/2 ∣1〉 , with eigenvalues ±r , and eigenspinors √r∣S0〉 , √r∣S1〉 the proof of which will be given in the section on SU(2) rotations. Denoting ∣si〉 to be the eigenvector of σi , we can easily see that xi=〈si∣v∣si〉 Eigenvectors may look different, when they are just the same eigenvector multiplied by some global “phase” r e iα . Since the simulator returns eigenvectors as a column matrix P , where each column is an eigenvector, we can apply a complex constant to all the eigenvectors through P ( r1 e iα1 0 ⋯ 0 0 r2e iα2 ⋯ 0 ⋱ 0 0 ⋯ rn e iαn ), with some convention, such as making the top entry 1 for all eigenvectors. We can also check for equality and extract the global phase difference for two eigenvectors with: bool equal=(eigenvector_1==eigenvector_2); auto phase=(eigenvector_1/eigenvector_2); 8.2.1 Coding Example: Spinors We use the simulator to obtain eigenvectors and eigenvalues for each of the Pauli matrices and then for a Pauli vector. Finally, we compare the eigenvectors for the Pauli-vector with the spinors corresponding to this Paul-vector, to show that the spinors are just the eigenvectors: 27/60
  • 28. //Pauli matrices std::cout << "sigma_z=" << Z << std::endl; //Get eigendecomposition. Apply global phases (top entry of eigenvecs-->1) auto eig_decomp=eig(Z); auto global_phase_1=(_<0_1|eig_decomp[0]|0_1>_)^(-1); auto global_phase_2=(_<1_1|eig_decomp[0]|1_1>_)^(-1); auto mat=global_phase_1|0_1>_<0_1|_+global_phase_2|1_1>_<1_1|_; std::cout << "eigen vectors with global phase=" << to_matrix((eig_decomp[0])(mat)); std::cout << "eigenvalues=" << to_matrix(eig_decomp[1]); std::cout << "sigma_x=" << X << std::endl; //Get eigendecomposition. Apply global phases (top entry of eigenvecs-->1) eig_decomp=eig(X); global_phase_1=(_<0_1|eig_decomp[0]|0_1>_)^(-1); global_phase_2=(_<0_1|eig_decomp[0]|1_1>_)^(-1); mat=global_phase_1|0_1>_<0_1|_+global_phase_2|1_1>_<1_1|_; std::cout << "eigen vectors with global phase=" << to_matrix((eig_decomp[0])(mat)); std::cout << "eigenvalues=" << to_matrix(eig_decomp[1]); std::cout << "sigma_y=" << Y << std::endl; //Get eigendecomposition. Apply global phases (top entry of eigenvecs-->1) eig_decomp=eig(Y); global_phase_1=(_<0_1|eig_decomp[0]|0_1>_)^(-1); global_phase_2=(_<0_1|eig_decomp[0]|1_1>_)^(-1); mat=global_phase_1|0_1>_<0_1|_+global_phase_2|1_1>_<1_1|_; std::cout << "eigen vectors with global phase=" << to_matrix((eig_decomp[0])(mat)); std::cout << "eigenvalues=" << to_matrix(eig_decomp[1]); //Pauli vector v=r(sin theta cos phi,sin theta sin phi, cos theta) AmpOrPhase theta=pi/3_f, phi=pi/5_f; auto pauli_vector= 100*(sin(theta)*cos(phi)*X+sin(theta)*sin(phi)*Y+cos(theta)*Z); std::cout << "Pauli vector=" << to_matrix(pauli_vector); //Get eigendecomposition. Apply global phases (top entry of eigenvecs-->1) eig_decomp=eig(pauli_vector); global_phase_1=(_<0_1|eig_decomp[0]|0_1>_)^(-1); global_phase_2=(_<0_1|eig_decomp[0]|1_1>_)^(-1); mat=global_phase_1|0_1>_<0_1|_+global_phase_2|1_1>_<1_1|_; std::cout << "eigen vectors with global phase=" << to_matrix((eig_decomp[0])(mat)); std::cout << "eigenvalues=" << to_matrix(eig_decomp[1]); //eigenspinor auto spinors=cos(theta/2_f)*(e^(-i*phi/2_f))|0_1>_<0_1|_+ (e^(i*phi/2_f))*sin(theta/2_f)|1_1>_<0_1|_+ sin(-theta/2_f)*(e^(-i*phi/2_f))|0_1>_<1_1|_+ (e^(i*phi/2_f))*cos(theta/2_f)|1_1>_<1_1|_; global_phase_1=(_<0_1|spinors|0_1>_)^(-1); global_phase_2=(_<0_1|spinors|1_1>_)^(-1); mat=global_phase_1|0_1>_<0_1|_+global_phase_2|1_1>_<1_1|_; std::cout << "spinors with global phase=" << to_matrix((spinors)(mat)); The output for this is: sigma_z=(1+0i)|0><0|+(-1+0i)|1><1| eigen vectors with global phase= (1+0i) (0+0i) (0+0i) (1+0i) eigenvalues= (1+0i) (0+0i) (0+0i) (-1+0i) sigma_x=(1+0i)|0><1|+(1+0i)|1><0| eigen vectors with global phase= (1+0i) (1+0i) (0.9999999996-4e-10i) (-1.0000000003-1.2e-09i) eigenvalues= (1+0i) (0+0i) (0+0i) (-1+0i) sigma_y=(0-1i)|0><1|+(0+1i)|1><0| eigen vectors with global phase= (1+0i) (1+0i) (0+1i) (0-1i) eigenvalues= (1+0i) (0+0i) (0+0i) (-1+0i) Pauli vector= (50+0i) (70.0629269222-50.9036960455i) (70.0629269222+50.9036960455i) (-50+0i) eigen vectors with global phase= (1+0i) (1+0i) (0.4670861796+0.3393579723i) (-1.401258537-1.0180739284i) eigenvalues= (100+0i) (0+0i) (0+0i) (-100+0i) spinors with global phase= (1+0i) (1+0i) (0.4670861795+0.3393579736i) (-1.4012585384-1.0180739209i) 28/60
  • 29. 8.3 Rotations We can guess, from the previous section, that if σ3 ⇒∣0〉 and ̂ v=cosθcos ϕσ1+cosθsin ϕσ2+sinθσ3 ⇒cos(θ/2)e −iϕ/2 ∣0〉+sin(θ/2)e iϕ/2 ∣1〉 , then the general spinor can be obtained by a rotation on ∣0〉 . This is indeed the case and we can use e iσk α =cos α+i sinα σk , σμ σν=−σν σμ , i σk=σiσ j to show an interesting property of SU(2): e −iσk α/2 (aiσi+aj σ j+ak σk)e iσk α/2 =e −iσk α/2 e −i σk α/2 (ai σi+a j σj)+ak σk =(cosα−σiσ j sinα)(ai σi+a j σj)+ak ek =(ai cosα−a j sinα)σi+(a j cosα+ai sinα)σ j+ak σk This can be seen to be a rotation that leaves the σk component invariant and rotates vectors in the perpendicular plane through angle α . We now seek to generalise this, through an Euler rotation. 8.3.1 Euler rotations We saw that e −i σk α/2 ̂ v e iσk α/2 rotates the σi and σ j components of ̂ v , whilst leaving the σk component unchanged. Thus, we may write sinθcos ϕσ1+sin θsin ϕσ2+cosθσ3 = e −i σz ϕ/2 e −iσy θ/2 σ3 e i σyθ/2 e iσz ϕ/2 and I cos α/2+i(sinθ cosϕσ1+sinθsin ϕσ2+cosθ σ3)sin α/2 =e −iσz ϕ/ 2 e −iσy θ/2 e iσ3 α/2 e iσy θ/2 e i σz ϕ/2 This is an Euler rotation expressed through the exponential R=e −iσ⋅̂ n α/2 , where ̂ n 2 =1 . The exponential R=e −iσ⋅̂ n α/2 is a 2×2 matrix belonging to the SU(2) group. We can now ask how rotations affect spinors. Let ∣s〉 be the “spin-up” eigenvector of the Pauli vector ̂ v , then 〈0∣σ3∣0〉= 〈s∣v∣s〉=1= 〈0∣R −1 Rσ3 R −1 ⏟ v R∣0〉 ⏟ ∣s〉 . Thus, some spinor ∣u〉 transforms under the rotation R=e −iσ⋅̂ n α/2 as R∣u〉 . NB: This is different to defining the rotation as 〈0∣Rσ3 R −1 ⏟ v ∣0〉 =〈0∣R ⏟ 〈 s∣ σ3 R −1 ∣0〉 ⏟ ∣s〉 and chosen so that ∣ψ〉〈 ψ∣→ R(∣ψ〉 〈 ψ∣) R −1 . Example, using σy=−i σz σx , σx∣0〉=∣1〉, σz∣i∈{0,1}〉=(−1) i ∣i 〉 : Let R=e −iσz ϕ/2 e −iσy θ/2 R∣0〉 = e −iσz ϕ/2 (I cos θ 2 −i σy sinθ 2 )∣0〉 = e −iσz ϕ/2 (I cos θ 2 ∣0〉−σzsin θ 2 ∣1〉 ) = cos(θ/2)e −iϕ/2 ∣0〉+sin(θ/2)e iϕ/2 ∣1〉 . These will be the same for the Paul-vector v=r ̂ v , but the eigenvalues become ±1→±r . Suppose we have the spinor ∣s〉=R∣0〉 , but do not know the rotation that produced it. We can still recover v=Rσ3 R −1 . We denote ∣s j〉 to be the “spin-up” eigenvector of σ j and note that 〈s j∣σi∣s j 〉=δij ⇒vi=〈s∣σi∣s〉 . The following code illustrates these mathematical results: 8.3.2 Coding example: SU(2) rotations using spinors In the following code we demonstrate how to rotate σ3 →v and then how to reverse this using the inverse rotation: 29/60
  • 30. using namespace Quantum; using namespace Gates; using std::sin, std::cos; //x,y and z spinors (eigenvectors of Pauli matrices Gates::X, Y Z) auto s_x=(1/sqrt(2))*(_|0_1>_+_|1_1>_); auto s_y=(1/sqrt(2))*(_|0_1>_+i|1_1>_); auto s_z=_|0_1>_; //Pauli vector (x=sin theta cos phi, y=sin theta sin phi, z=cos theta) AmpOrPhase theta=pi/3_f, phi=pi/5_f, norm=100; auto pauli_vector=sin(theta)*cos(phi)*X+sin(theta)*sin(phi)*Y+cos(theta)*Z; pauli_vector*=norm; std::cout <<"pauli vector: " << "100*(sin(pi/3)cos(pi/5),sin(pi/3)cos(pi/5),cos(pi/3))=" << "(" << norm*sin(theta)*cos(phi) << ", " << norm*sin(theta)*sin(phi) << ", " << norm*cos(theta) << ")" << std::endl << to_matrix(pauli_vector) << std::endl; auto eigs=eig(pauli_vector); std::cout << "eig(pauli_vector)=" << to_matrix(eigs[0]) << to_matrix(eigs[1]) << to_matrix(eigs[2]); std::cout << "Pauli vector from eigen decomposition=" << to_matrix((eigs[0])(eigs[1])(eigs[2])) << std::endl; //Rotation: theta about Y, then phi about Z auto R=(e^(-i*Z*phi/2))(e^(-i*Y*theta/2)); //Check that 100*Z --> Pauli vector std::cout << "R (100*Z) R^-1=" << to_matrix((R)(100*Z)(R^dag)); //Rotation via spinor auto s=cos(theta/2_f)*(e^(-i*phi/2_f))|0_1>_+ sin(theta/2_f)*(e^(i*phi/2_f))|1_1>_; s*=norm^(0.5); std::cout << "spinor with global phase=" << to_matrix(s*((_<0_1|s)^(-1))); std::cout << "<s|sigma_x|s>=" << (_<s|X|s>_) << std::endl; std::cout << "<s|sigma_y|s>=" << (_<s|Y|s>_) << std::endl; std::cout << "<s|sigma_z|s>=" << (_<s|Z|s>_) << std::endl; s/=norm^(0.5); std::cout << "<s|pauli_vector|s>=" << (_<s|pauli_vector|s>_) << std::endl; std::cout << "R|0>=" << to_matrix((R)|0_1>_); //Rotate eigen-spinors to Pauli vector frame, Z', and check we get 100*Z' s_x=R|s_x>_; s_y=R|s_y>_; s_z=R|s_z>_; //Check Pauli vector --> (x=0,y=0,z=1) std::cout << "Inverse rotation using spinors" << std::endl; std::cout << "(_<s_x|pauli_vector|s_x>_)=" << (_<s_x|pauli_vector|s_x>_) << std::endl; std::cout << "(_<s_y|pauli_vector|s_y>_)=" << (_<s_y|pauli_vector|s_y>_) << std::endl; std::cout << "(_<s_z|pauli_vector|s_z>_)=" << (_<s_z|pauli_vector|s_z>_) << std::endl; The output is as follows: 30/60
  • 31. pauli vector: 100*(sin(pi/3)cos(pi/5),sin(pi/3)cos(pi/5),cos(pi/3))=((70.0629269222+0i), (50.9036960455+0i), (50+0i)) (50+0i) (70.0629269222-50.9036960455i) (70.0629269222+50.9036960455i) (-50+0i) eig(pauli_vector)= (-0.6510155548+0.5711206067i) (-0.1069063702-0.4884373327i) (-0.4978947001+0.0458352227i) (-0.3474618464+0.7932655705i) (100+0i) (0+0i) (0+0i) (-100+0i) (-0.6510155548-0.5711206067i) (-0.4978947001-0.0458352227i) (-0.1069063702+0.4884373327i) (-0.3474618464-0.7932655705i) Pauli vector from eigen decomposition= (50+0i) (70.0629269222-50.9036960455i) (70.0629269222+50.9036960455i) (-50+0i) R (100*Z) R^-1= (50+0i) (70.0629269222-50.9036960455i) (70.0629269222+50.9036960455i) (-50+0i) spinor with global phase= (1+0i) (0.4670861795+0.3393579736i) <s|sigma_x|s>=(70.0629269222+0i) <s|sigma_y|s>=(50.9036960455+0i) <s|sigma_z|s>=(50+0i) <s|pauli_vector|s>=(100+0i) R|0>= (0.8236391035-0.2676165673i) (0.4755282581+0.1545084972i) Inverse rotation using spinors (_<s_x|pauli_vector|s_x>_)=(0+0i) (_<s_y|pauli_vector|s_y>_)=(0+0i) (_<s_z|pauli_vector|s_z>_)=(100+0i) 8.4 Hyperbolic rotations and Special Relativity Pauli matrices have the property {σiσ j}= σi σj+σ j σi = 2δij . This means they satisfy a Euclidean metric, which is the 3X3 identity matrix, from which we obtain Pythagoras' Theorem: (x , y , z) ( 1 0 0 0 1 0 0 0 1)( x y z)= x 2 +y 2 +z 2 . This relationship also means that σi>0σ j>i=−σiσ j , which is a defining property of perpendicular vectors: (U +V )(U+V )=U 2 +V 2 +U V +V U ⇒U V+V U =2U⋅V U⋅V := 1 2 {U ,V } U⋅V ⊥U= 1 2 {U ,V ⊥U }=0⇒U V ⊥U =−V ⊥U U U∧V := 1 2 [U ,V ] U V = 1 2 {U ,V }+ 1 2 [U ,V ] U V=U⋅V +U ∧V The metric also endows Pauli matrices with another nice property: (I 3:=σ1 σ2σ3) 2 =−1 , so we can write a rotation as e −iσi θ/2 =e −I 3σiθ/2 . We now want to move to four dimensions, so we need four matrices that satisfy γi≥0 γj>i=−γi γj and (I 4:=γ0 γ1 γ2 γ3) 2 =−1 . This is equivalent to {γi γ j}=2 ηij , where η is a 4X4 metric: (x0, x1, x2, x3) ( 1 0 0 0 0 −1 0 0 0 0 −1 0 0 0 0 −1 )( x0 x1 x2 x3 )= x0 2 −(x1 2 +x2 2 +x3 2 ) . The four matrices are Dirac gamma matrices and the metric is the Minkowski metric of Special Relativity, where (ct ) 2 −(x 2 +y 2 +z 2 )=(ct ) 2 −(vt ) 2 is a 4D version of Pythagoras' Theorem that satisfies the rule that it is the same “length squared” when you rotate to some new coordinate-system 31/60
  • 32. (ct ) 2 −(x 2 +y 2 +z 2 )=(ct ') 2 −(x' 2 + y' 2 +z' 2 ) . These gamma matrices will be explored later and be shown to generate Special Relativity, quantum mechanically. 8.4.1 Hyperbolic rotations In the absence of gamma matrices we are restricted to the four Pauli matrices and the Pauli vector v=(ct )σ0+∑i=1 i=3 xi σi = (ct+x3 x1−i x2 x1+i x2 ct−x3 ) . The 3D rotation (x , y , z)→(x '=x cosθ−ysinθ , y' =xsin θ+y cosθ , z '=z) satisfies x ' 2 +y' 2 +z ' 2 =x 2 +y 2 +z 2 . Similarly, we can define a hyperbolic rotation (ct , x , y ,z)→(ct '=ct cosh ζ−x sinhζ , x '=−ct sinh ζ+x cosh ζ , y '=y , z' =z) , which satisfies (ct ')2 −x'2 −y'2 −z '2 =(ct)2 −x2 −y2 −z2 . The hyperbolic angle ζ is given by tanh ζ= sinhζ cosh ζ = x ct =β:= vx c ⇒ζ=tanh −1 β and viewed as a rotation in the t−x plane, since we can no longer define a perpendicular axis of rotation. Since lim v →c (tanh −1 (v /c))=∞ , we cannot attain v=c and the Universe has the regions v<c ⏟ massive/timelike , v=c ⏟ massless/lightlike , v>c ⏟ tachyonic/spacelike . Let γ=(1−β2 )−1/2 =cosh(ζ) . A Lorentz transformation, Λ , performs a hyperbolic rotation: ( ct ' x' y ' z ' )= [Λ=cosh(ζ) ( 1 −tanh(ζ) 0 0 −tanh(ζ) 1 0 0 0 0 1 0 0 0 0 1 )]( ct x y z )=γ ( 1 −β 0 0 −β 1 0 0 0 0 1 0 0 0 0 1 )( ct x y z ) . The hyperbolic functions can be written cosh ζ=cosi ζ, sinh ζ=−i sin i ζ , tanh ζ=−tan i ζ . We note that e ±iσk (iζ) =I cosi ζ±i σk sinh i ζ = I cosh ζ∓σk sinhζ and e −σk ζ/2 (ct σ0+xi σi+x j σj+xk σk )e −σk ζ/2 =e −σk ζ (ct σ0+xk σk)+xi σi+x j σj =(I cosh ζ−σk sinh ζ)(ct σ0+xk σk )+xi σi+x j σ j =(ct cosh ζ−xk sinhζ)σ0+(−ct sinhζ+xk cosh ζ)σk+xi σi+x j σ j , which is the Lorentz transformation in the t−xk plane. A Lorentz transformation in a general direction σk=sin θ cosϕσ1+sin θsin ϕσ2+cosθσ3 is then e −(sin θcosϕσ1+sinθsin ϕσ2+cosθσ3)ζ/2 . It should be obvious that the eigenspinors for u=(ct )σ0+∑i=1 i=3 xi σi are the same as before for v=∑i=1 i=3 xiσi ⇔√r∣s〉 , but the eigenvalues acquire the additive term ct , because we have only added a scaled identity. We now have a four-component vector: (〈s∣σ0∣s〉, 〈s∣σi∣s〉) . Since the zeroth component is 〈s∣σ0∣s〉=r , we conclude that ct=r , corresponding to a massless particle travelling at v=c , where r=vt . This limitation is the result of σ0 not satisfying σ0σi=−σi σ0 , which is a requirement for σ0 to be treated as a “basis vector”. This limitation is overcome with Dirac gamma matrices that do satisfy γ 0 γ i =−γ i γ 0 . It is worth noting, however, that the eigenspinors of u correspond with Weyl spinors and neutrinos were thought to be Weyl spinors until it was discovered they are not massless. 32/60
  • 33. 8.5 Dirac matrices, Dirac equation and Special Relativity Pauli matrices limit us to (ct ) 2 −( x 2 +y 2 +z 2 )=0 , so we need four “basis vectors” satisfying γi γj =−γ j γi , (γ0 γ1 γ2 γ3 )2 =−1 . Dirac matrices achieve this, with the properties: (1) (γ 0 ) † =γ 0 , (γ μ>0 ) † =−γ μ>0 , (2) (γ 0 ) 2 =1, (γ μ>0 ) 2 =−1 , (3) {γ μ , γ ν }=2ημ ν ⇒γ μ γ ν>μ =−γ ν γ μ , where ημ ν is the Minkowski metric discussed earlier. Two common representations are (γchiral(or standard) μ=0 =σ 1(or3) ⊗I 2 , γ i∈{1,2,3} =i σ 2 ⊗σ i ) and we will use the Chiral basis. With this extended basis we can now write a “Dirac-vector”: V=c τ ̂ V =c τ [cosh ζ γ 0 −sinh ζ(sin θcos ϕγ 1 +sin θsinϕγ 2 +cos θ γ 3 ) ⏟ ̂ x⋅γ c.f. Pauli vector ]≡γμ x μ . Having four basis vectors removes the restriction (c τ) 2 =(ct) 2 −(x 2 +y 2 +z 2 )=0 present with Pauli matrices and allows c τ≥0 . The Dirac-vector may be obtained from γ 0 by a boost ̂ V=e − ̂ x⋅γ γ 0 ζ/2 γ 0 e ̂ x⋅γ γ 0 ζ/2 =e − ̂ x⋅γ γ 0 ζ γ 0 =cosh ζ γ 0 −sinh ζ ̂ x⋅γ . The eigenvectors of the exponential, e − ̂ x⋅γ γ 0 ζ/2 are the same as those of its exponent: −̂ x⋅γ γ 0 ζ/ 2=−(sin θcos ϕγ 1 +sinθsin ϕ γ 2 +cosθ γ 3 )γ 0 ζ/2 =−ζ/2[i σ 2 ⊗(sin θcosϕσ 1 +sinθsin ϕσ 2 +cosθ σ 3 )][σ 1 ⊗I2] =−ζ/2[σ 3 ⊗(sin θcos ϕσ 1 +sin θsin ϕσ 2 +cosθσ 3 )] We can see that eigenvectors comprise ∣S〉=∣s± 3 〉⊗∣sPauli ± ̂ xB 〉 , such as ∣S〉= 1 √2 (∣0〉⊗∣s ̂ xB 〉+∣1〉⊗∣s − ̂ xB 〉) . The useful identity cosh ζ=2cosh 2 ζ 2 −1 gives cosh ζ 2 =(cosh ζ+1 2 ) 1/2 =[γ+1 2 ] 1/2 =[t+τ 2 τ ] 1/2 , sinh ζ/2=[cosh 2 ζ/2−1] 1/2 =[t−τ 2 τ ] 1/2 , where γ=t /τ , and, using √t 2 −τ 2 =sinh(ζ) , the boost is: ∣SB 〉=e +̂ x⋅γ γ0 ζ/2 1 √2 (∣0〉+∣1〉)⊗∣s〉rest frame =(cosh ζ/2+sinh ζ/2σ3⊗ ̂ x⋅σ) 1 √2 (∣0〉+∣1〉)⊗∣s〉 = 1 √4 τ(t+τ) [I2⊗([t+τ] I 2+sinh(ζ) ̂ x⋅σ)∣0〉⊗∣s〉+I 2⊗([t+τ] I2−sinh(ζ) ̂ x⋅σ)∣1〉⊗∣s〉] From γ0 ∣S=Srest 〉=∣S 〉 , (̂ x⋅γ γ 0 ) † = ̂ x⋅γ γ 0 , we get ̂ V μ =〈S∣e ̂ x⋅γ γ 0 ζ/2 γ 0 γ μ e ̂ x⋅γ γ 0 ζ/2 ∣S 〉 . Finally, using A μ Bμ ≡∑μ A μ Bμ and xμ=(t ,−x) so that xμ xμ=t2 −∣x∣ 2 , we can show: (γ μ xμ )∣SB〉= τ[cosh ζ γ 0 −sinh ζ(−̂ x⋅γ)]= τ e + ̂ x⋅γ γ 0 ζ/2 γ 0 e − ̂ x⋅γ γ 0 ζ/2 ∣SB〉 = τ(e + ̂ x⋅γ γ 0 ζ/2 (γ 0 =σ 1 ⊗I2)) 1 √2 (∣0〉+∣1〉)⊗∣s〉rest frame = τ(e + ̂ x⋅γ γ 0 ζ/2 ) 1 √2 (∣1〉+∣0〉)⊗∣s〉rest frame= τ∣SB 〉 }⇒(γ μ xμ−τ)∣SB〉=0 . Under the quantum mechanical substitution (ct ,−x)→(E ,− p)→i ℏ(∂/∂t , ∇) this becomes the Dirac equation: (i γ μ ∂/∂ x μ −m0)∣SB〉=0 and the Klein-Gordon equation is (i γ μ ∂/∂ x μ +m0)(i γ μ ∂/∂ x μ −m0)∣S ' 〉=0 , in the Planck system of units, discussed later. 33/60