Visualizing Single Qubit Quantum Logic Gates

Amogh Shetty
Quantum Untangled
Published in
9 min readFeb 8, 2021

We have qubits. Great! But how do we work with them? Well, just as classical computers make use of logic gates to work with normal bits, quantum computers make use of quantum logic gates to manipulate qubits. This first part in the series will concern visualizing the Pauli-X, Pauli-Y, and Pauli-Z gates.

Image cred: qiskit.org

This article will be covering a lot about Bloch spheres, so if you don’t know what Bloch spheres are, I would recommend reading this article about them.

Another important concept in this article is multiplying matrices. If you have not learned that yet, I would highly recommend you learn that before moving on.

A Brief Introduction to Quantum Logic Gates

When we apply a quantum gate to a qubit, we change it in someway. This is similar to how classical logic gates modify bits. For instance, the NOT gate in classical computing outputs a 1 if a 0 is inputted and vice versa.

Similarly, in Quantum computing, there is a gate called the Pauli-X gate. If you input |0〉to a Pauli-X gate, we would obtain |1〉 and vice versa. But what would be outputted if a Pauli-X gate was applied to a qubit that is in a superposition state of |0〉and |1〉. Well, to understand that, we must expand our definition of a Pauli-X gate beyond a simple truth table.

We can do that by representing it as a matrix. When we multiply matrices by vectors (which are essentially one dimensional matrices), we obtain an altered vector. For example, the Pauli-X gate (which is indicated with the symbol σₓ) can be expressed as the following matrix:

Created by the author using Microsoft Word

If we multiply the above matrix by |0〉we would obtain|1〉.

Created by the author using Microsoft Word

In the same way, if we multiply the above matrix by any vector that represents the superposition state of a qubit, we obtain a “flipped” state.

Created by the author using Microsoft Word

Do you see a pattern in the above? The Pauli-X gate flips the superposition state. This property is the reason why the Pauli-X gate is often called “bit-flip.” There is another interesting property to the Pauli-X gate. If we were to plot the quantum state of a qubit on a Bloch sphere, and then apply a Pauli-X gate, the output would be the input vector rotated 180º about the x-axis on the Bloch sphere.

Made by the author using Google Drawing

This article will concern analyzing those types of patterns in order to gain an intuitive sense of Quantum logic gates.

The Cartesian Plane and the Bloch Sphere

Before we dive into Bloch spheres, it may be simpler to learn how to visualize Quantum logic gates on Cartesian coordinates (with α as the x-axis and β as the y-axis). To do that, it is important to understand how to relate the Bloch sphere to the Cartesian plane.

The general formula for the position of a quantum state on the Bloch sphere is represented by the below equations. We can then rearrange them in the manner shown below.

From the information we have, we can create the below triangle.

We can then incorporate this triangle into our cartesian plane as shown below.

Here is where it gets interesting. Both the Bloch sphere and the cartesian plane resemble a circular object. However, they differ in that the angle between the α-axis and the vector of the cartesian plane is always half of the angle between the z-axis and the vector of the Bloch sphere. In other words, if we increased the angle of the cartesian plane by 90º, the angle θ of the Bloch sphere increases by 180º.

This allows us to make the statement that any two vectors that are orthogonal (90º) in the Cartesian Plane are parallel but in the opposite direction in the Bloch sphere (180º).

More importantly, this also allows us to make the statement that any two vectors that are parallel in the Cartesian Plane (180º) have the same direction on the Bloch sphere (360º≡0º).

Using what we’ve learned, we can create the below diagram that plots significant points from the Bloch Sphere onto a Cartesian Plane.

Created using GeoGebra 3D graphing calculator and Desmos Graphing Calculator.

The rest of the article depends heavily on this diagram, so it would be best if you stop and analyze the above diagram for a while. Note that that |i〉 and |-i〉 are not represented in the cartesian plane because they can only be found in the complex plane. We will look into the complex plane when we reach the Pauli-Y gate.

Pauli-X Gate

Just as we could use a matrix to alter a point on the Bloch sphere, we can do the same for a point on the Cartesian Plane.

Let’s pretend that we did not know the Pauli-X gate rotates a vector on the Bloch sphere 180º about the X-axis. How would we figure out it’s nature? Well one way is to understand how the Pauli-X gate applies to Cartesian coordinates (because it is easier to visualize), and then replicate our findings on the Bloch sphere.

Let’s find the dot product of the Pauli-X gate matrix and several coordinate points in the Cartesian Plane and see where they end up.

Note that some of these coordinates are not normalized.

We can see that the Pauli-X gate reflects points over the line y = x. Wait a minute? Doesn’t y = x represent the x-axis from the Bloch sphere.

So according to our analysis of the Cartesian plane, the quantum states are being reflected over the line y=x, which is analogous to the X-axis on the Bloch sphere. This makes sense for quantum states that do not contain complex values, but what if they do have complex values? In that case, we have to resort to the Bloch sphere.

So far, we are under the assumption that the Pauli-X gate reflects a quantum state across an axis. In the 3-dimensional Bloch sphere, we can extend our definition to say that the quantum state is being reflected over the X-Y plane. However, there is also the possibility that the Pauli-X gate may be rotating the quantum state about the X-axis 180º.

We are in a dilemma, so let’s do a test. We’ll apply the Pauli-X gate to |i〉. If the result is |i〉, then the state is being reflected over the X-Y plane. If the result is |-i〉, then the state is being rotated about the X-axis (if you do not understand this, you should reflect on it for a while by visualizing the Bloch sphere).

Note that there is a difference between |-i〉and i. The former is a Quantum state while the latter is the square root of -1.

We get a result of |-i〉. Therefore, we know that the Pauli-X gate rotates the quantum state 180º over the X-axis.

What about for other quantum states with complex values? Well, to show that it works from them also, let’s prove it algebraically now that we have an idea of what we are looking for. We want to prove that when a Pauli-X gate is applied to a quantum state on the Bloch sphere, two changes occur -

  • The quantum state must flip over the X-Y plane, or in other words, θ’ = π-θ.
  • The quantum state must flip over the X-Z plane, or in other words, φ’ = -φ .
Created by the author using Microsoft Word

We have mathematically proved that the Pauli-X gate rotates the quantum state 180º over the X-axis. Please understand that it is not being rotated 180º over the origin. Rather, it is being rotated over the X-axis.

Pauli-Z Gate

Just as the Pauli-X gate can be represented by a matrix, the Pauli-Z gate can also be represented by the below matrix.

Just as before, let’s first analyze the Pauli-Z gate using a Cartesian plane.

Note that some of these coordinates are not normalized.

We can see that the Pauli-Y gate reflects points over the line y = 0, which is analogous to the z-axis of the Bloch sphere.

If you’ve made it this far, you would probably be guessing that the Pauli-Z gate rotates quantum states 180º about the Z-axis. That is indeed true. In order to prove this algebraically, we need to show that when a Pauli-X gate is applied to a quantum state on the Bloch sphere:

  • θ’ = θ ; There is no transition across the X-Y plane, so θ does not change.
  • φ’ = π+φ ; This is a result of reflecting over both the X-Z and Y-Z planes.

The Pauli-Z gate rotates quantum states 180º about the Z-axis. Due to the nature of the Pauli-Z gate, it is often called the phase-flip gate.

Pauli-Y Gate

Just as the Pauli-Z gate rotates quantum states 180º about the Z-axis, the Pauli-Y gate does the same but for the Y-axis. However, portraying the effects of this gate on a Cartesian plane are more complicated because the gate contains complex values.

However, we can still prove that the Pauli-Y gate rotates a quantum state 180º about the Y-axis algebraically. In order to do so, we need to show that when a Pauli-Y gate is applied to a quantum state on the Bloch sphere, two changes occur -

  • The quantum state must flip over the X-Y plane, or in other words, θ’=π-θ.
  • The quantum state must flip over the Y-Z plane, or in other words, φ’=π-φ.

And we have successfully proved that the Pauli-Y gate rotates quantum states 180º about the Y-axis.

Why does this matter?

Qubits alone cannot do anything, just like bits in classical computing cannot do anything alone. Quantum computing gates allow us to manipulate qubits and create useful algorithms and circuits out of them. Learning to visualize the effects of Quantum gates using a Bloch sphere allows you to have a visual understanding of Quantum logic gates rather than as a series of math equations, which makes it easier to create your own algorithms using Quantum logic gates.

References

--

--