A Prequel to Coding Quantum Circuits

Quantum measurements, Born’s rule, and Unary operators

Madeline Farina
QubitCo
8 min readSep 15, 2020

--

In my last post, I provided an overview of qubits, including the Bloch sphere and single qubit operations, which served as an introduction to the world of quantum computing. I would like to further elaborate on these topics in preparation for coding quantum circuits in Qiskit, which will require a general knowledge of single qubit gates and unary operations which I will be discussing below.

First, let’s review the Bloch sphere, shown below:

If you will recall, we know this sphere to be a geometric representation of a qubit and its number of possible states. We see the states |0⟩ and |1⟩ represented as two antipodal points on the z-axis, antipodal meaning “two points on the surface of a sphere which are diametrically opposite.” By this logic, there are an infinite number of antipodal points on a sphere. The four other states — |+⟩ and |-⟩, |+i⟩ and |-i⟩ — can be antipodal points on the x- and y-axes, respectfully. These states are orthogonal, i.e. they represent qubit states which are orthogonal in the Hilbert Space.

The Hilbert Space is a term well-used in discussions of quantum mechanics, and it is defined as an abstract vector space that allows length and angle to be measured. More specifically, it is the inner product space and the two terms can be used interchangeably. For those unsure of what an inner product is (like those who have embarrassingly forgotten most of linear algebra, like myself), the inner product will be defined later on.

Also, let it be noted that on the Bloch sphere, angles are twice as large as they would appear in the Hilbert space. So when seeing the angle θ on the Bloch sphere, know that it is really θ/2 in the Hilbert space.

Quantum Measurements

When we perform a measurement onto an orthogonal basis, the qubit collapses to a state in the particular basis you are using to measure, with a probability given by the corresponding amplitude:

|Ψ⟩ = cos(θ/2)|0⟩ + sin(θ/2)e^(iφ)|1⟩

This could also be viewed as a wave function given the cos and sin coefficients. If we perform a projective measurement onto the z-axis (the states |0⟩ and |1⟩) we get the probabilities:

P(0) = cos²(θ/2) 
P(1) = sin²(θ/2)

It can therefore be inferred that points in the northern hemisphere of the Bloch sphere are more likely to collapse to the North pole (state |0⟩), while points in the southern hemisphere are more likely to collapse to the South pole (state |1⟩).

But what about a general formula for arbitrary points on the sphere? This is where Born’s Rule comes into play.

Born’s Rule

Born’s Rule states that the probability a state |Ψ⟩ collapses during a projective measurement onto a basis {|x⟩,|x⊥⟩} to the state |x⟩ is as follows:

P(x) = |⟨x|Ψ⟩|²
P(x⊥) = |⟨x⊥|Ψ⟩|²

(x⊥ simply refers to the corresponding antipodal point on the Bloch sphere)

In other words, for a qubit represented as an arbitrary point on the Bloch sphere which will collapse after measurement, the probability of it collapsing onto a particular basis (which is represented as one of the axes of the sphere) is equal to square of the inner product of the supposed basis and the given state of the system.

Now, for a definition of inner product: the inner product of two vectors is the numerical quantity obtained by multiplying the corresponding coordinates of two vectors and adding the products, like so:

It is also called the “dot product” or the “scalar product” in linear algebra. It allows for the length of a vector or the angle between two vectors to be found, and if the inner product of two vectors is 0, they are orthogonal. A vector is normalized if its inner product with itself is 1.

Another type of vector product you might encounter (particularly when using Dirac notation) is the outer product. The outer product of two coordinate vectors is a matrix, and can also be referred to as the tensor product. Given vectors u and v, the outer product is as follows:

Outer (tensor) product

Now that this review has been provided, let us transition to another important precursor of quantum circuits: unary operators.

Unary Operators

Quantum circuits often contain quantum gates, which are represented by unitary transformations (matrices). A unitary transformation preserves the norm (also known as the size) of whatever its operating on, typically a vector or matrix. For example, a rotation is unitary, since the size of the matrix/vector doesn’t change. For a single qubit gate, U can be a 2x2 unitary matrix. U†U implies a unitary transformation multiplied by its conjugate transpose which is usually also its inverse, and this product is equal to the Identity matrix.

There is a set of particular common unitary transformations called unary operators or unary gates, and they can be seen below. It should be noted that they all act on a single qubit.

X gate

The X gate (also known as the Pauli-X gate, or δₓ) is equivalent to the NOT operator in classical circuits and appears in quantum circuits like so:

Pauli-X Gate
NOT gate

The X gate performs a bit flip operation and is equivalent to the following matrix:

δₓ = [ 0 1 ]
[ 1 0 ]

which is equivalent to the follow outer product:

δₓ = |0⟩⟨1| + |1⟩⟨0|

On the Bloch sphere, it is a rotation of the point around the x-axis by π (180 degrees).

To summarize:

X|0⟩ = |1⟩
X|1⟩ = |0⟩
X|+⟩ = |+⟩
X|-⟩ = |-⟩
X|+i⟩ = |-i⟩
X|-i⟩ = |+i⟩

You will see that the X gate has no effect on the |+⟩ and |-⟩ states, which is because it is a rotation around the x-axis, and since |+⟩ and |-⟩ lie on the x-axis, there is consequently no change.

Z gate

The Z gate (also known as the Pauli-Z gate, or δz) is the phase flip operator and appears in quantum circuits like so:

Pauli-Z Gate

It is equivalent to the following matrix:

δz = [ 1 0 ]
[ 0 -1]

And outer product:

δz = |0⟩⟨0| - |1⟩⟨1|

On the Bloch sphere, it is a rotation around the z-axis by π.

To summarize,

Z|0⟩ = |0⟩
Z|1⟩ = |1⟩
Z|+⟩ = |-⟩
Z|-⟩ = |+⟩
Z|+i⟩ = |-i⟩
Z|-i⟩ = |+i⟩

You will see that the Z gate has no effect on the |0⟩ and |1⟩ states. Again, this is because the Z gate is a rotation around the z-axis and |0⟩ and |1⟩ lie on the z-axis.

Y gate

The Y gate (also known as the Pauli-Y gate, or δᵧ) is a bit and phase flip. It is equivalent to the following matrix:

δᵧ = [ 0 -i]
[ i 0 ]

It is a rotation around the y-axis of the Bloch sphere by π.

To summarize,

Y|0⟩ = i|1⟩
Y|1⟩ = -i|0⟩
Y|+⟩ = -i|-⟩
Y|-⟩ = i|+⟩
Y|+i⟩ = |+i⟩
Y|-i⟩ = |-i⟩

Phase shift operators

The general phase shift operator is the matrix:

Rφ = [ 1 0 ]
[ 0 e^iφ]

Which is an operation that leave the basis state |0⟩ unchanged but maps |1⟩ to e^iφ|1⟩, which modifies the phase of the state |1⟩.

For φ = π, which is also the Z gate:

R =  [ 1 0 ]
[ 0 -1]

For φ = π/2, which is referred to as the S gate:

R =  [ 1 0 ]
[ 0 i ]

and for φ= π/4, which is referred to as the T gate:

R =  [ 1 0 ]
[ 0 e^iφ]

Hadamard Operator

The Hadamard gate can be applied to switch from the Z to X basis, and vice versa. On the Bloch sphere, it is the combination of two rotations, π / 2 about the Y-axis, then by π about the Z-axis. As a matrix, it can be represented as a matrix with the coefficient 1/ √2 like so:

H =  1/√2 [ 1 1 ]
[ 1 -1]

Which is the following outer product:

H = 1/√2( |0⟩⟨0| +|0⟩⟨1| + |1⟩⟨0| -|1⟩⟨1| )

The Hadamard gate is the 1-qubit version of the quantum Fourier Transform (it’s important, but more on that later). To summarize,

H|0⟩ = |+⟩
H|1⟩ = |-⟩
H|+⟩ = |0⟩
H|-⟩ = |1⟩
H|+i⟩ = |-i⟩
H|-i⟩ = |+i⟩

Conclusion

While I realize the above is not particularly exciting for those interested in actually coding quantum circuits, the information is important for a basic understanding of what your code will be doing. I promise my next post shall include actual code in Qiskit and relevant visuals which I think are a little more interesting. Moreover, it will be more appealing to people like me who are focused on the “practical” applications of quantum computing (quantum circuits, coding quantum algorithms, etc.) instead of pure theory.

As always, I welcome questions, comments, and suggestions about how to improve my work. I am no expert by any means and aim to make these as accurate and educational as possible. A list of references has been provided below for those in search of further reading.

References

Nielsen, M. A., & Chuang, I. L. (2000). Quantum computation and quantum information. Cambridge: Cambridge University Press.

Townsend, J. S. (1992). A modern approach to quantum mechanics. New York: McGraw-Hill.

The Qiskit Team. (2020). Learn Quantum Computation using Qiskit. Retrieved September 04, 2020, from https://qiskit.org/textbook/preface.html

--

--

Madeline Farina
QubitCo

Quantum Physics, InfoSec, and general scientific nonsense