Multiple Qubits and Quantum Logic Gates
Manipulating and combining qubits
In the previous article, we had learned about what qubits are, single qubit states and a few operations on them. But in most physical systems, we almost always deal with more than one qubit.
In this article, we will be doing exactly that. We will learn how to combine multiple qubits to get a ket representation of them. We will also learn about a few basic quantum logic gates that you can apply to change the state of a quantum system.
So let’s get started!
How do we combine multiple qubits?
The first thing you need to know about to do this would be, the tensor product.
Tensor product
The tensor product is nothing but a means of combining two matrices of arbitrary sizes into a single block matrix. A block matrix is just another larger matrix that combines the two matrices, and this will be indicative of its two components. The block matrix being indicative of the two-component matrices.
That having been said, we can use this mathematical operation to combine two or more qubits and the result we get is also a qubit state! Let’s dive deeper into some of the finer details about the tensor product.
The tensor product is represented by the symbol ⨂ and it operates on a given vector like so –
If,
Then,
Properties of the tensor product
- The tensor product is distributive, i. e:
2. The tensor product is associative, i. e:
3. The tensor product is NOT commutative. That is,
except for when,
Here’s the definition of tensor product:
“Given two vectors |ψ₁⟩ ∈ ℂᵈ¹ and |ψ₂⟩ ∈ ℂᵈ² respectively, the tensor product is given by:
where |ψ₁⟩⨂|ψ₂⟩ lies in the state space ”
Here, Cᵈ¹ and Cᵈ² are vector spaces.
Examples of the tensor product
Let’s look at an example to see how the tensor product helps with multiple qubits –
We got to |10⟩! This is how we represent a 2-qubit state.
Multiple qubit states
Classically, if we have n bits, we can write them as a string of n numbers. Same as before, we represent these as vectors. You can do this by making the vector zero at all places except at the position indexed by i, where i represents the number which is being represented by the string. Since we can represent classical strings as vectors, we can consider the superposition of these vectors.
Or, to formalize it further, we can define it as follows —
Consider the state space of n qubits ℂᵈ, where d = 2ⁿ. For each distinct string x ∈ {0, 1}ⁿ, associate x with a distinct integer i ∈ {1, 2, …, d}. The standard basis ℂᵈ is an orthogonal basis given by
where |x⟩ are d-dimensional vectors,
An n qubit state can thus be written as a superposition of standard basis elements —
With 𝛼ₓ ∈ ℂ, and where, n is a natural number.
The amplitude of this n-qubit state can be calculated as –
Or, in other words, the length of the vector is 1, which is the condition for a state to be a valid qubit.
Example of a 2-qubit state
I find teleportation to be one of the coolest applications of quantum computing which means that information can be communicated between two distant places instantly. Can you imagine how far the field of communication would go? This is possible due to one property of quantum particles, i.e, entanglement.
Here’s an example of how two qubits are combined, or in other words, entangled —
How is this state obtained, then?
We use the previously learned tensor product here —
Here, |+⟩ is one of the symbols of the Hadamard basis. Hadamard basis is an orthogonal basis with H = {|+⟩, |–⟩}, where,
Graphically, the Hadamard basis is represented as —
There is also a quantum logic gate with this name which you will come across later in the article.
As a fun exercise, you can check if this quantum state’s amplitude is 1 to check its validity as a qubit.
The above discussed 2-qubit state is called the EPR state, which is named after 3 scientists — Einstein, Podolsky, and Rosen. This is a widely discussed and a rather important quantum state in the field of quantum computing.
Quantum logic gates
Made it this far? Awesome! Let’s continue exploring.
As we now know, qubits are nothing but vectors. Sometimes we may need to change the direction of these vectors to successfully perform certain operations, here’s where quantum gates come in!
Gates are operations that manipulate the input according to our needs. Logic is quite well defined in the classical system for computing and we have many gates like — OR, AND, NOT, XOR, etc.
Quantum logic gates are nothing but unitary operators, meaning
The above equation is read as U dagger U is equal to U U dagger is equal to identity matrix, where, U dagger means the hermitian conjugate of U. A hermitian conjugate matrix is the conjugate transpose matrix of U. A conjugate transpose matrix is the conjugate of element of the transpose of matrix U.
This is the major difference between classical gates and quantum gates. Classical gates are irreversible whereas, quantum gates are reversible.
We have gates in quantum computing as well, perhaps logic is the basis for computing. The quantum gates we will be learning about today are — the Pauli operators (X, Y, Z), the Hadamard gate, and Controlled-NOT.
The Pauli Operators
The simplest quantum gates are the Paulis; X, Y, and Z. Their action is to rotate the qubit along the x, y, and z-axis respectively on the Bloch sphere.
Pauli X
The action of the X gate on |0⟩ and |1⟩ is as follows:
The Pauli X operator inverts the input qubit. It is analogous to the classical NOT gate. This operation is also known as the bit flip operation.
Pauli Z
The Pauli-Z operator acts on the standard basis by introducing a phase flip.
The action of the Z gate on |+⟩ and |–⟩ is as follows:
To be more precise,
Thus the Pauli Z acts as a bit flip on the Hadamard basis, while it acts as a phase flip on the standard basis.
Pauli Y
Applying a bit and a phase flip gives Y = iXZ.
The action of Y on the standard basis is as follows:
The matrix representations of these gates are –
A visualization of how exactly the qubit is moved about the x, y, and z-axis is given below –
Pauli X –
Pauli Y –
Pauli Z –
Let’s now move on to the Hadamard gate.
The Hadamard gate
Like, the Paulis, the Hadamard is also a half rotation about the Bloch sphere. However, the difference is that it rotates about an axis that is exactly between the X and the Z axes. This gives it the illusion of rotating states that point along the Z-axis to those pointing along the X-axis.
Performing a Hadamard transformation on the zero or one state creates a state of equal superposition between the two basis states, meaning that only when you choose to measure the qubit will its state be determined.
Note: The Hadamard gate is not the same as the Pauli Z gate.
Controlled NOT gate
The controlled-Not gate or the CNOT gate is a 2 qubit quantum gate, wherein the second qubit gets flipped if the first qubit is SET, i.e, the first qubit is 1. Otherwise, it does nothing.
It is represented in the quantum circuit as follows –
The |x⟩ qubit is called the control qubit and the |y⟩ qubit is called the target qubit.
The above circuit implements –
The shorter notation for the above is –
The matrix representation of the CNOT gate is –
Note: this represents the output states of the qubits. Imagine each row represents a, b, c, and d from the equation –
a|00⟩ + b|01⟩ + c|10⟩ + d|11⟩
Here’s the truth table to show what happens to the standard basis upon applying the CNOT —
Other than the standard basis, what happens when we apply the CNOT gate to the Hadamard basis?
Another interesting property of the CNOT gate is
You’re amazing, you’ve made it to the end!
Oof… that’s a lot of information to process, isn’t it? I hope you learned something fun and interesting in this article. I can’t wait to come back and learn with you!
Contributors to this article: Madhav Jivrajani and Mugdha Pattnaik.
References:
[1] IBM — Introduction to quantum circuits,
[2] Jonathan Hui’s medium article — QC — Programming with Quantum Gates (2-Qubit operators)
[3] Michael A. Nielsen, Isaac L. Chuang — Quantum Computation and Quantum Information.
[4] Stephanie Wehner and Nelly Ng — Lectures and Lecture Notes, CaltechDelftX: QuCryptox.
[5] Desiree Vogt-Lee — Introduction to Quantum Unitary Operators