Professional Documents
Culture Documents
Appendix K:
Quantum computing 230,262
Quantum computing involves many things far beyond our experience here in the classical world, but the maths can
be surprisingly straightforward.
Vector notation
We can represent quantum bits (qubits) with the Dirac vector notation:
1 0
0 = |0 〉 = 1 = |1〉 =
0 1
The values in Dirac vectors represent the amplitude (probability) of the qubit collapsing to that value when measured:
√
α P(0)
|ψ〉 = α|0〉 + β|1〉 = = √
β P(1)
Where α and β are complex numbers and |α|2 + |β|2 = 1. The qubit will collapse to 0 with a probability of |α|2
1 0
and to 1 with a probability |β|2 . The qubit has a 100% chance of collapsing
to 0, and has a 100% chance
0 √1
1
of collapsing to 1. A qubit in an equal superposition of 0 and 1 has the value 12 , which shows that it has a
√
2
√1 2
2 = 2 chance of collapsing to 0 or 1.
1
We derive these Dirac vectors by taking the tensor product of the individual qubit vectors, which we call the
product state:
⎛ ⎞ ⎛ ⎞
c ac
a c ⎜ a
⎜ d ⎟ ⎜
⎟ ⎜ ad ⎟
⎟
⊗ = ⎜ ⎟ = ⎜ ⎟
b d ⎝ c ⎠ ⎝ bc ⎠
b
d bd
The Institution of Structural Engineers
Computational engineering | 263
where |ac|2 + |ad|2 + |bc|2 + |bd|2 = 1. We can factor the product state back to the individual state representation if
the qubits are not entangled. The product state of n bits is a vector of size 2n.
⎛ ⎞ ⎛ ⎞
1 0
⎜ ⎟ ⎜ ⎟
1 1 ⎜0⎟ 1 0 ⎜1⎟
0 = |00〉 = ⊗ =⎜ ⎟ 1 = |01〉 = ⊗ =⎜ ⎟
0 0 ⎝0⎠ 0 1 ⎝0⎠
0 0
⎛ ⎞ ⎛ ⎞
0 0
⎜ ⎟ ⎜ ⎟
0 1 ⎜0⎟ 0 0 ⎜0⎟
2 = |10〉 = ⊗ =⎜ ⎟ 3 = |11〉 = ⊗ =⎜ ⎟
1 0 ⎝1⎠ 1 1 ⎝0⎠
0 1
⎛ ⎞
0
⎜0⎟
⎜ ⎟
⎜ ⎟
⎜0⎟
⎜
⎜0⎟
⎟
0 0 1 ⎜ ⎟
|6〉 = |110〉 = ⊗ ⊗ =⎜ ⎟
1 1 0 ⎜0⎟
⎜ ⎟
⎜0⎟
⎜ ⎟
⎜ ⎟
⎝1⎠
0
2
Note that 12 = 14, so there is a 1
4 chance of collapsing to |00〉, |01〉, |10〉, or |11〉.
While measuring a qubit will collapse it, we can manipulate the qubits without measuring them and thus leave them
in superposition. We mathematically manipulate the qubit vectors using matrix operations.
Logic gates
Classical computing uses a number of logic gates.
CNOT gate
The Controlled NOT or CNOT gate has a control bit that remains unchanged, but the target bit is flipped if the
control qubit is equal to 1.
CNOT
Input Output
0 0 0 0
0 1 0 1
1 0 1 1
1 1 1 0
CCNOT
Input A Input B Input C Output A Output B Output C
0 0 0 0 0 0
0 0 1 0 0 1
0 1 0 0 1 0
0 1 1 0 1 1
1 0 0 1 0 0
1 0 1 1 0 1
1 1 0 1 1 1
1 1 1 1 1 0
Hadamard gate
The Hadamard gate takes a 0- or 1-bit and puts it into equal superposition:
⎛ ⎞ ⎛ ⎞
√1 √1 √1
⎝ 2 2
⎠ 1 ⎝ 2
⎠
H|0〉 = =
√ √
1 −1 0 √
1
2 2 2
⎛ ⎞ ⎛ ⎞
√1 √1 √1
0
H|1〉 = ⎝ ⎠ ⎝ ⎠
2 2 2
=
√1 √
−1 1 √
−1
2 2 2
The Hadamard gate is reversible, so if we reapplied it to the superimposed qubits they would revert to their original
state: they would transition out of superposition without measurement and thus the quantum calculation can be
deterministic.
266
| The Institution of Structural Engineers
Computational engineering
Entanglement
We can entangle two qubits by using a Hadamard gate on one, then using it as the control of a CNOT gate with the
other (Figure K1). First initialise both qubits to |0〉, then pass one through the Hadamard gate to put it into
superposition, before using the CNOT gate to entangle them.
|0l
H C
⎛ ⎞⎛ √1 ⎞ ⎛ √1 ⎞
1 0 0 0
2
⎜ ⎟ ⎜ ⎟
2
√1 ⎜0 ⎟ ⎜ ⎟ ⎜ ⎟
1 1 1 ⎜ 1 0 0⎟ 0
⎟=⎜ 0 ⎟
CH1 ⊗ =C 2
⊗ = ⎜ ⎟⎜
0 0 √1 0 ⎝0 0 0 ⎜ 1 ⎟
1 ⎠⎝ √ ⎠ ⎝ 0 ⎟
⎜
⎠
2 2
0 0 1 0 √1
0 2
If the product state of two qubits cannot be factored back to the individual qubits, they are said to be entangled.
⎛ 1 ⎞
√
2
ac = √12
⎜ ⎟
⎜0⎟ ad = 0
⎜ ⎟= a ⊗ c
⎜0⎟ b d bc = 0
⎝ ⎠
√1 bd = √12
2
This has no solution but does have a 50% chance of collapsing to |00〉 and 50% to |11〉.
If a qubit had been initialised to |1〉 the entangled pair would collapse to |01〉 or |10〉, which I will leave to you to
prove.
For further reading, two important quantum algorithms are Grover’s algorithm263, for fast searching of unordered
databases, and Shor’s algorithm264, which factors exceptionally large numbers exponentially faster than a
classical computer.