Robert Zieba

07 Sep 2018

Quantum Simulator 101 Background

In the previous installation of this series, I mostly focused on the code and glossed over most of the mathematical and physical background. In this post I will go over more of the background behind quantum computing with the intention to give an intuitive understanding of the concepts. Hopefully, this will make the following blog posts make more sense than they would otherwise.

Qubits

The basis of quantum computing is qubits. Just as normal computers operate on bits, quantum computers operate on qubits. Normal bits can only be a zero or a one. However, a qubit can be in a superposition of zero and one. What this means physically is that when you measure a qubit there’s a probability that you’ll measure a zero and a probability that you’ll measure a one. The theory behind superpositions is slightly more complicated than that. A qubit, q can be written as

$$ \ket{q} = \alpha\ket{0} + \beta\ket{1} $$

The interesting thing is that α and β are complex numbers. This has very interesting implications because a probability, p, can only be 0≤p≤1. But α and β can be negative, or have imaginary parts. Clearly, these constants are not probabilities. They are probability amplitudes and can be converted to probabilities by multiplying the amplitude with its complex conjugate. The difference between probabilities and probability amplitudes is critical and is one of the keys things that makes quantum computing different from normal computing and probabilistic algorithms. Because probability amplitudes can be negative they can cancel-out, either partially or completely. This is of vital importance is many quantum algorithms.

The state of a number of qubits is a unit vector in a complex vector space. A single qubit is a 2-dimensional vector with the basis vectors \( \ket{0} \), \( \ket{1]} \). The state of two qubits is a 4-dimensional vector with basis vectors: \( \ket{00} \), \(\ket{01} \),\( \ket{10} \), \( \ket{11} \) and so on. Qubit vectors must be unit vectors because the sum of probabilities of outcomes must equal 1. This leads normalization constants to commonly involve square roots, for example a qubit with equal probability of zero and one can be written as

$$ \frac{1}{\sqrt{2}}\ket{0} + \frac{1}{\sqrt{2}}\ket{1} $$

The Bloch Sphere

Qubits are commonly represented graphically through use a sphere called the Bloch sphere. On the Bloch sphere the north pole is \( \ket{0} \), the south pole is \( \ket{1} \) and other states are in-between on the sphere. Both \( \ket{0} \) and \( \ket{1} \) line along the z-axis. The Bloch sphere is a very convenient way to visualize qubits for two reasons:

  • How close a qubit is to the poles indicates how likely it’ll measure as a zero or a one
  • Operations on qubits can be thought of as rotations of the Bloch sphere along different axes.

Phase

If, from a quantum state \( \ket{v} \), a complex number of the form \( e^{i\phi} \) can be factored out, then \( \phi \) is called the global phase. Global phase has no physical meaning. This means that \( \ket{0} \) and \( -\ket{0} \) are the same. This can be understood in the following way: global phase is a rotation of the Bloch sphere around the z-axis. Since \( \ket{0} \) and \( \ket{1} \) line along this axis, a rotation along the z-axis has no effect on them. Other vectors can be understood in a similar way: a rotation around the z-axis doesn’t change how far these vectors are from the poles. Consider the following vectors:

$$ \ket{+} = \frac{1}{\sqrt{2}}\ket{0} + \frac{1}{\sqrt{2}}\ket{1} $$ $$ \ket{-} = \frac{1}{\sqrt{2}}\ket{0} - \frac{1}{\sqrt{2}}\ket{1} $$

Though the later can be written as

$$ \ket{-} = \frac{1}{\sqrt{2}}\ket{0} + e^{i\pi}\frac{1}{\sqrt{2}}\ket{1} $$

\( \ket{+} \) and \( \ket{-} \) are not the same. Because the phase is not a global phase, it’s relative. Relative phase does have physical meaning because global phase rotates everything, but relative phase doesn’t. It’s like a football field. If the entire field is rotated, the outcome of the game doesn’t change, but if a single player spendes the game rotated 180 degrees, then the game will end up differently.

Entanglement

Entanglement is one of the most misunderstood and mystified quantum mechanical phenomena. I think quantum entanglement can best be introduced by showing an example of an entangled state before going into the mathematical background. Consider the state

$$ \ket{\Phi+} = \frac{1}{\sqrt{2}}\ket{00} + \frac{1}{\sqrt{2}}\ket{11} $$

There are two possible outcomes for this state with equal probability: 00 and 11. Imagine that you have one qubit and a friend (located a large distance away) holds the other. If you measure your qubit and get a zero, then you know that your friend’s qubit will be a zero and vice-versa. When explained this way, quantum entanglement doesn’t seem so strange. After all, if there are two possible sandwiches in bags, one chicken and one turkey, then if you pick a bag and get chicken then you know that the other is turkey. Naturally, it stands to question whether the qubits where ever in a superposition in the first place. Maybe the qubits were actually just in the state \( \ket{00} \), but we couldn’t tell. The latter is equivalent to saying that quantum mechanics has hidden variables. The state of the qubits had a definite value, but we couldn’t tell, its value is hidden from us. It turns out that it makes an experimental difference, as demonstrated by John S. Bell. Hence \( \ket{\Phi+} \) is know as a Bell state, there are three others. All experiments to date are consistent with the absence of hidden variables. This has interesting implications: somehow, no matter how distantly separated, the qubits somehow interact with each other.

Now, the mathematical background: qubits are entangled with each other when their state cannot be written as a product of single qubit states. Consider the state \( \ket{\Phi+} \), assume that it can be written as

$$ \ket{\Phi+} = (a\ket{0} + b\ket{1}) \otimes (c\ket{0} + d\ket{1}) $$

expanding out, we get

$$ \ket{\Phi+} = ac\ket{00} + ad\ket{01} + bc\ket{10} + bd\ket{11} $$

We now have:

$$ ac = bd = \frac{1}{\sqrt{2}} $$ $$ ad = bc = 0 $$

There is no solution and so \( \ket{\Phi+} \) cannot be written as a product of single qubit states. Intuitively, this means that entangled qubits cannot be thought of in terms of individual qubits, but have to be considered as a unit.

Linear Operators and Quantum Gates

Classical computers use logic gates to perform operations on bits. Quantum computers use quantum gates to perform operations on qubits. Quantum gates are linear operators that operator on quantum states. Linearity means that given a linear operator A,

$$ A(\alpha\ket{v}⟩ + \beta\ket{w}) = \alpha A\ket{v} + \beta A\ket{w}⟩ $$

Any linear operator can be expressed as a matrix. In particular, quantum gates are expressed as unitary matrices. Unitary matrices have two important properties: they conserve probability and they are invertible. This means that all quantum computations are reservable. An interesting sidenote: in theory, reservable computations can be performed without spending any energy. This applies to all computations, not just quantum ones.

Because quantum gates are linear operators, we only have to think about how they act on the basis vectors to understand them. I’m going to talk about a few single qubit quantum gates just to give a feel of what they do

  • X gate: the quantum version of a NOT gate. Maps \(\ket{0} \rightarrow \ket{1} \) and \(\ket{1} \rightarrow \ket{0} \)
  • Z gate: flips the sign of the ∣∣1⟩ coefficient, same thing as a phase shift of π. Maps \(\ket{0} \rightarrow \ket{0} \) and \(\ket{0} \rightarrow -\ket{1} \)
  • Hadamard gate: Maps

$$ \ket{0} \rightarrow \frac{1}{\sqrt{2}}\ket{0} + \frac{1}{\sqrt{2}}\ket{1} $$ $$ \ket{1} \rightarrow \frac{1}{\sqrt{2}}\ket{0} - \frac{1}{\sqrt{2}}\ket{1} $$

How quantum logic gates act on basis vectors can be thought off as the quantum equivalent of truth tables for normal logic gates.

Two and three qubit gates are common as well, but I will save those for a later post.

Conclusion

The goal of this post is not to make you an expert in these topics, but just introduce them. Don’t worry if they don’t make complete sense. I’m a big believer in hands-on learning and hope that just being familiar with them will help in the next posts in this series.