22 Scheme Physics For Cse Module 3 Notes
22 Scheme Physics For Cse Module 3 Notes
DEPARTMENT OF PHYSICS
Module 3 Notes
3 Quantum Gates 27
3.1 Single Qubit Gates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.1.1 Quantum NOT gate (Pauli-X gate) . . . . . . . . . . . . . . . . . . . . 28
3.1.2 Pauli-Z gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3
CONTENTS
Syllabus
Principles of Quantum Information and Quantum Computing
Introduction to Quantum Computing, Moore’s law and its end, Differences between
Classical and Quantum computing. Concept of qubit and its properties. Representation
of qubit by Bloch sphere. Single and Two qubits. Extension to N qubits.
1.1 Introduction
5
1.2. CLASSICAL VS. QUANTUM COMPUTING
1.4 Qubits
1.4.1 Concept of qubit
A qubit, the fundamental unit of information in quantum computing, distinguishes itself from
classical bits by its ability to exist in a superposition of states. While classical bits can only
represent a single value of either 0 or 1, qubits can simultaneously represent both 0 and 1
due to their unique properties.
Physically, a qubit can be realized using different systems, such as the two spin states
of an electron (spin up and spin down) or the two polarizations of a photon (horizontal
and vertical polarization). These physical implementations provide a basis for encoding and
manipulating qubits in quantum computing systems.
1. Superposition: Unlike classical bits that represent a single value, qubits can exist in
a superposition of states, simultaneously representing both 0 and 1. This superposi-
tion enables quantum computers to perform multiple calculations in parallel, vastly
expanding computational possibilities.
3. Probabilistic Nature: Qubits are described probabilistically, meaning that their states
can only be determined with certain probabilities. This probabilistic nature introduces
4. Unitarity: Qubits must maintain unitarity, which ensures that the sum of probabilities
for all possible states of a qubit equals 1. This requirement preserves the reversibility
of quantum computations and ensures the conservation of total probability throughout
quantum operations.
where |ψ⟩ represents the qubit, |0⟩ and |1⟩ represent the 0 and the 1 bits. |⟩ is the notation
given to something called a ket vector. A ket vector |ψ⟩ is analogous to the Euclidian vector,
say ⃗a = a1⃗i + a2⃗j. (In mathematics, the unit vectors ⃗i and ⃗j are also called as basis vectors.
Similarly, in our case, |0⟩ and |1⟩ are the basis vectors. In particular, these two are called
the computational basis.)
We see that the above expression for the qubit is a linear combination of the pure bits
0 and 1. This is also called a superposition state (the qubit is in both the 0 and 1 states).
The coefficients α and β are in general complex numbers and they have a probabilistic
interpretation. |α|2 is the probability that you would get a 0 if you measured the qubit |ψ⟩.
Similarly, |β|2 is the probability that you would get a 1 if you measured the qubit |ψ⟩. And
from the rules of probability, the sum of probabilities of these two independent events must
be equal to 1. Therefore, we get
|α|2 + |β|2 = 1
This normalization condition guarantees that the total probability remains conserved
throughout quantum computations.
above, we need 4 real numbers, which also makes it impossible for us to visualize such a
ket vector in our restricted 3-dimensional space. But there is a way for us to reduce the 4
numbers to 2. We can omit an overall phase factor to reduce the total required numbers to
3. We can also use the condition that the sum of probabilities must be one; this reduces the
total required numbers to 2. After following these steps, the mathematical form for the qubit
changes to the following
θ iϕ θ
|ψ⟩ = cos |0⟩ + e sin |1⟩ (1.1)
2 2
We see here that we need only two numbers θ and ϕ to uniquely describe a ket vector.
We call these numbers as θ and ϕ because they represent respectively the polar angle and
azimuthal angle in the 3-dimensional spherical polar coordinates.
Remember that to uniquely represent a Euclidian vector in 3D space, we need three
numbers. These 3 numbers depend on the coordinate system we use. If we use the Cartesian
coordinate system, the three numbers are x, y, z. If we use the spherical polar coordinates,
the three numbers are r, θ, ϕ. In our qubit representation, we have these θ and ϕ and we
consider r = 1. This means that depending on the values of θ and ϕ, we have an arrow in
3D space pointing in a certain direction and has length of 1.
The definitions for θ, ϕ are as follows:
θ: This is the angle made by the vector with the positive z-axis such that 0 ≤ θ ≤ π.
ϕ: This is the angle made by the vector with the positive x-axis along the xy-plane
such that 0 ≤ ϕ ≤ 2π.
So given a value of θ and ϕ, we shall start with a unit vector pointing in the positive z
direction. We shall rotate the vector by an angle θ from the positive z-axis along the xz-plane.
Then we will rotate the vector by an angle ϕ from the positive x-axis along the xy-plane.
Note:
You will need to remember this formula (called Euler’s formula) for the following section:
Now, let’s see where some common qubit states are present on the Bloch sphere.
For θ = 0, ϕ = 0
Since both angles are zero, our unit vector stays on the positive z-axis (we call this the north
pole of the sphere). Let’s see which state these values correspond to. Substitute these angle
values in (1.1). We get
0 i∗0 0
|ψ⟩ = cos |0⟩ + e sin |1⟩
2 2
|ψ⟩ = |0⟩
since cos(0) = 1 and sin(0) = 0. So at this point (the north pole), we have the state |0⟩.
For θ = π, ϕ = 0
For these angles, the unit vector rotates by 180◦ with the positive z-axis and now points in
the negative z-axis (we call this the south pole of the sphere). Let’s see which state these
values correspond to. Substitute these angle values in (1.1). We get
π π
|ψ⟩ = cos |0⟩ + ei∗0 sin |1⟩
2 2
|ψ⟩ = |1⟩
π π
= 0, e0 = 1 and sin
since cos 2 2 = 1. So at this point (the south pole), we have the state
|1⟩.
For θ = π/2, ϕ = 0
For these angles, the unit vector rotates by 90◦ with the positive z-axis and now points in
the positive x-axis. Let’s see which state these values correspond to. Substitute these angle
values in (1.1). We get
π π
|ψ⟩ = cos |0⟩ + ei∗0 sin |1⟩
4 4
1 1
|ψ⟩ = √ |0⟩ + √ |1⟩
2 2
since cos π4 = sin π4 = √12 and e0 = 1. So at this point, we have the state √12 |0⟩ + √1
2
|1⟩.
This state is so common in quantum computing that it is given a name: |+⟩, i.e.,
1 1
|+⟩ = √ |0⟩ + √ |1⟩
2 2
For θ = π/2, ϕ = π
For these angles, the unit vector rotates by 90◦ with the positive z-axis and then by 180◦
with the positive x-axis along the xy-plane to now point in the negative x-axis. Let’s see
which state these values correspond to. Substitute these angle values in (1.1). We get
π π
|ψ⟩ = cos |0⟩ + eiπ sin |1⟩
4 4
1 1
|ψ⟩ = √ |0⟩ − √ |1⟩
2 2
since cos π4 = sin π4 = √12 and eiπ = −1 (from (1.2)). So at this point, we have the state
√1 |0⟩ − √12 |1⟩. This state is so common in quantum computing that it is given a name: |−⟩,
2
i.e.,
1 1
|−⟩ = √ |0⟩ − √ |1⟩
2 2
Syllabus
Dirac Representation and Matrix Operations
Matrix representation of |0⟩ and |1⟩ states, Identity Operator I, Applying I to |0⟩ and
|1⟩ states, Pauli Matrices and its operations on |0⟩ and |1⟩ states. Explanation of (i)
Conjugate of a matrix and (ii) Transpose of a matrix. Unitary matrix U , Examples:
Row and Column Matrices and their multiplication (Inner Product), Probability, and
Quantum Superposition, normalization rule. Orthogonality, Orthonormality. Numerical
Problems
2.1 Introduction
Linear algebra is crucial in quantum mechanics, offering a mathematical foundation for han-
dling quantum states using state or ket vectors in complex vector spaces. Linear op-
erators facilitate transformations on these states. Matrix representation allows efficient
calculations by representing operators as matrices based on selected basis states. Matrix
multiplication of operator and state matrices predicts quantum system evolution in quantum
mechanics and is vital in quantum computing for algorithm design and computations.
13
2.2. MATRIX REPRESENTATION OF 0 AND 1 STATES
and compare it with the original vector form ⃗a = a1 î + a2 ĵ, we can write
1 0
î = and ĵ =
0 1
This is the matrix representation of the two-dimensional unit vectors î and ĵ.
In a similar manner, we get the matrix representations of the |0⟩ and |1⟩ states. Since a
general ket vector |ψ⟩ can be written as |ψ⟩ = α |0⟩ + β |1⟩, its matrix representation is given
as
α
|ψ⟩ =
β
whereas the matrix representation of the basis kets are written as
1 0
|0⟩ = and |1⟩ = (2.1)
0 1
I |ψ⟩ = |ψ⟩
Now, let us find the matrix representation of the identity operator. To do that, we need
to know the action of the operator on the basis states |0⟩ and |1⟩. But we already know that
from the definition of the identity operator:
Replacing the |0⟩ and |1⟩ states with their matrix representations, we have
1 1 0 0
I = and I =
0 0 1 1
For valid matrix multiplications of the above two equations, I must be represented by a
2 × 2 matrix. So let us write a general 2 × 2 matrix for I as
a b
I=
c d
So we get a = 1 and c = 0.
Next, the second equation becomes
1 b 0 0
=
0 d 1 1
b 0
=
d 1
So we get b = 0 and d = 1.
Finally, we can write
1 0
I=
0 1
This is the matrix representation of the identity operator in the basis of |0⟩ and |1⟩.
You can verify that this is the correct representation by multiplying this matrix with the
matrix representation of the basis kets to get the corresponding results.
0 −i
σy = σ2 = Y =
i 0
1 0
σz = σ3 = Z =
0 −1
0 1 0
X |1⟩ =
1 0 1
1
=
0
=⇒ X |1⟩ = |0⟩
Pauli-Y matrix
0 −i 1 0
Y |0⟩ = =
i 0 0 i
0
= i
1
=⇒ Y |0⟩ = i |1⟩
0 −i 0 −i
Y |1⟩ = =
i 0 1 0
1
= −i
0
=⇒ Y |1⟩ = −i |0⟩
Pauli-Z matrix
1 0 1
Z |0⟩ =
0 −1 0
1
=
0
=⇒ Z |0⟩ = |0⟩
1 0 0 0
Z |1⟩ = =
0 −1 1 −1
0
= −1
1
=⇒ Z |1⟩ = − |1⟩
U U † = U †U = I
Next, consider D† D,
1 1 −i 1 1
D† D =
2 1 i i −i
1 − i 2 1 + i2
1
=
2 1 + i2 1 − i2
1 2 0 1 0
= =
2 0 2 0 1
D† D = I
This convention of using angular brackets and vertical lines to represent state vectors is
called the Dirac’s bra-ket notation.
For example, consider the following ket vector
√
1/ 2
|ϕ⟩ = √
i/ 2
In a similar manner, we can write the bra forms for the 0 and 1 states.
h i h i
⟨0| = 1 0 and ⟨1| = 0 1
†
Now, just as ⟨ψ| = |ψ⟩† , we can also write |ψ⟩ = ⟨ψ|† since |ψ⟩† = |ψ⟩.
⃗u · ⃗v = u1 v1 + u2 v2
So if we use the matrix representation of vectors, the dot product of two vectors can be
written as the matrix multiplication of a row matrix with a column matrix.
In a similar manner, we have the inner product of two ket vectors. Consider two ket
vectors
|ϕ⟩ = α1 |0⟩ + β1 |1⟩ and |ψ⟩ = α2 |0⟩ + β2 |1⟩
Or, in matrix representation we have
α1 α2
|ϕ⟩ = and |ψ⟩ =
β1 β2
The inner product of |ϕ⟩ with |ψ⟩ is denoted as ⟨ϕ|ψ⟩ (notice the single vertical line in
the center) and given by
h i α2
⟨ϕ|ψ⟩ = α1⋆ β1⋆
β2
⟨ϕ|ψ⟩ = α1⋆ α2 + β1⋆ β2
Note that the left side of the inner product is the bra form of the given vector |ϕ⟩.
Unlike the dot product of arrow vectors, the inner product of ket vectors is not commu-
tative, i.e., ⟨ϕ|ψ⟩ ̸= ⟨ψ|ϕ⟩ in general. For example, consider the same two ket vectors, |ϕ⟩
and |ψ⟩. The inner product of |ϕ⟩ with |ψ⟩ is as shown above.
The inner product of |ψ⟩ with |ϕ⟩ is
h i α1
⟨ψ|ϕ⟩ = α2⋆ β2⋆ = α2⋆ α1 + β2⋆ β1
β1
⟨ϕ|ψ⟩ = ⟨ψ|ϕ⟩⋆
where ⟨ψ|ϕ⟩⋆ is the complex conjugate of ⟨ψ|ϕ⟩. You can verify this...
2.12 Probability
Consider a 2-dimensional arrow vector in physical space ⃗a = 5î + 2ĵ. What is the meaning of
the coefficients of the unit vectors, in this case 5 and 2? Referring to figure 2.1, we see that
the vector has 5 units of contribution from the î direction whereas only 2 units of contribution
from the ĵ direction. In other words, we could say that the vector is tilted more toward the
î direction than the ĵ direction. This idea is important for the following discussion.
Now let us consider a ket vector, say, |ψ⟩ = α |0⟩ + β |1⟩, where α and β are in general
complex numbers. What is the meaning of these coefficients? In the context of quantum
mechanics, these are called probability amplitudes. The ket vector |ψ⟩ represents a quantum
state that is in a superposition of the 0 and 1 classical states. By itself, the quantum state
will be in this superposition state indefinitely, but if the state is measured, it will collapse to
(or become) any one of the two classical states (this is one of the fundamental postulates of
quantum mechanics). α and β tell us what is the probability of getting a 0 or a 1 respectively
as the outcome of the measurement of |ψ⟩. Actually, since these coefficients are complex
numbers, they are not actual probabilities, but their modulus squares are. In other words,
|α|2 is the probability of getting a 0 state after measuring |ψ⟩, whereas |β|2 is the probability
of getting a 1 state after measuring |ψ⟩. As the 0 and 1 states are mutually exclusive
measurement results, we can say that the sum of |α|2 and |β|2 is equal to 1 (since the sum
of probabilities of different events is always equal to 1), i.e.,
|α|2 + |β|2 = 1
So all ket vectors in quantum mechanics and quantum computing have to satisfy this
condition. There is also another way to represent this condition, in the bra-ket notation.
Consider the inner product of |ψ⟩ with itself:
h i α
⟨ψ|ψ⟩ = α⋆ β ⋆
β
= α⋆ α + β ⋆ β
⟨ψ|ψ⟩ = |α|2 + |β|2
where we have used the fact that for a complex number z, its modulus square is given by
|z|2 = z ⋆ z with z ⋆ being the complex conjugate of z.
Note that since probability is always a real number between 0 and 1, the modulus square
of the coefficients has to be a real number between 0 and 1, i.e., 0 ≤ |α|2 ≤ 1 and 0 ≤ |β|2 ≤ 1.
We can now write the above condition as
⟨ψ|ψ⟩ = 1
This is also called the normalization condition. The ket vectors which satisfy this con-
dition are said to be normalized ket vectors. For example, |0⟩ and |1⟩ are normalized ket
vectors since
h i 1
⟨0|0⟩ = 1 0 = 1
0
h i 0
⟨1|1⟩ = 0 1 = 1
1
⟨ψ|ϕ⟩ = 0
For example, |0⟩ and |1⟩ are orthogonal to each other since
h i 0
⟨0|1⟩ = 1 0 = 0
1
h i 1
⟨1|0⟩ = 0 1 = 0
0
2.13.2 Orthonormality
Two ket vectors are said to be orthonormal if they are orthogonal to each other and are
individually normalized. For example, |0⟩ and |1⟩ are orthonormal since they are orthogonal
to each other and are both normalized.
The orthonormality of |0⟩ and |1⟩ is described by four equations:
⟨0|0⟩ = 1, ⟨1|1⟩ = 1
⟨0|1⟩ = 0, ⟨1|0⟩ = 0
There is another concise way of writing these four equations, as a single equation
⟨m|n⟩ = δmn
Q 1. Mention the Pauli’s matrices. Discuss the operations of Pauli matrices on |0⟩ and |1⟩
states.
Q 3. Mention the matrix representation of |0⟩ and |1⟩ states and apply the Identity operator
to show there is no change in states.
2.15 Numericals
Q 1. A Linar Operator X operates such that X |0⟩ = |1⟩ and X |1⟩ = |0⟩. Find the matrix
representation of X.
Given:
X |0⟩ = |1⟩ and X |1⟩ = |0⟩
1 0 0 1
X = and X =
0 1 1 0
We find the elements of this matrix using the defintion of the X gate. From the first
expression,
1 0
X =
0 1
x x12 1 0
11 =
x21 x22 0 1
x 0
11 =
x21 1
0 −i
Q 2. Given A = . Prove that A† = A.
i 0
We know that
A† = (A∗ )T
∗ T
0 −i
=
i 0
T
0 i
=
−i 0
0 −i
=
i 0
=⇒ A† = A
√1 √1
Q 3. Show that the matrix U = 2 2 is unitary.
√i − √i2
2
This question is already solved in section 2.9.
Q 4. Find the inner product of states |0⟩ and |1⟩ and draw conclusions on the result.
This question is already solved in section 2.13.1.
The result shows that the two states are orthogonal.
α1 β1
Q 5. Given |ψ⟩ = and |ϕ⟩ = , prove that ⟨ψ|ϕ⟩ = ⟨ϕ|ψ⟩∗
α2 β2
This question is already solved in section 2.11, but with different symbols. So be careful.
Quantum Gates
Syllabus
Quantum Gates
Single Qubit Gates: Quantum Not Gate, Pauli X, Y and Z Gates, Hadamard Gate,
Phase Gate (or S Gate), T Gate
Multiple Qubit Gates: Controlled gate, CNOT Gate (Discussion for 4 different input
states), Representation of Swap gate, Controlled-Z gate, Toffoli gate
27
3.1. SINGLE QUBIT GATES
To get the result of the action of a quantum gate on an input state, we multiply the matrix
representation of the gate with the matrix (column vector) representation of the input state.
On the other hand, if we don’t already know the matrix representation of the gate but
know the result of the action of the gate on an input state, we can find out the matrix
representation of the gate in some suitable basis.
But what ifwe have a general superposition state such as |ψ⟩ = α |0⟩ + β |1⟩ or in matrix
α
form |ψ⟩ = ? We can write
β
0 1 α
X |ψ⟩ =
1 0 β
β
X |ψ⟩ =
α
The action of the Pauli-X gate on a general qubit state is to switch the coefficents. This
can be seen explicitly if we consider the bra-ket notation:
The action of the quantum NOT gate is summarized as shown in table 3.2b.
Input Output
|0⟩ |1⟩
|1⟩ |0⟩
X
α |0⟩ + β |1⟩ β |0⟩ + α |1⟩
(a) Circuit symbol (b) Truth table
To see how we get the definition, consider the Pauli-Z matrix acting on the |0⟩ state:
1 0 1
Z |0⟩ =
0 −1 0
1
=
0
Z |0⟩ = |0⟩
But what ifwe have a general superposition state such as |ψ⟩ = α |0⟩ + β |1⟩ or in matrix
α
form |ψ⟩ = ? We can write
β
1 0 α
Z |ψ⟩ =
0 −1 β
α
Z |ψ⟩ =
−β
The action of the Pauli-Z gate on a general qubit state is to flip the sign of the second
coefficent. This can be seen explicitly if we consider the bra-ket notation:
Input Output
|0⟩ |0⟩
|1⟩ − |1⟩
Z
α |0⟩ + β |1⟩ α |0⟩ − β |1⟩
(a) Circuit symbol (b) Truth table
To see how we get the definition, consider the Pauli-Y matrix acting on the |0⟩ state:
0 −i 1
Y |0⟩ =
i 0 0
0 0
= = i
i 1
Y |0⟩ = i |1⟩
The action of the Pauli-Y gate on a general qubit state is to switch the coefficents and
flip the sign of the second coefficient, upto a global phase factor. This can be seen explicitly
if we consider the bra-ket notation:
Y |ψ⟩ = Y (α |0⟩ + β |1⟩)
= αY |0⟩ + βY |1⟩
= iα |1⟩ − iβ |0⟩
Y |ψ⟩ = −i(β |0⟩ − α |1⟩)
The action of the Y gate is summarized as shown in table 3.4b.
Input Output
|0⟩ i |1⟩
|1⟩ −i |0⟩
Y
α |0⟩ + β |1⟩ −i(β |0⟩ − α |1⟩)
(a) Circuit symbol (b) Truth table
1 1
H |0⟩ = √ |0⟩ + √ |1⟩
2 2
1 1
H |1⟩ = √ |0⟩ − √ |1⟩
2 2
1 1
|+⟩ = √ |0⟩ + √ |1⟩
2 2
1 1
|−⟩ = √ |0⟩ − √ |1⟩
2 2
They are called the ”plus” state and the ”minus” state respectively, for obvious reasons.
Note: Just as the |0⟩ and |1⟩ states form something called the computational basis
in our single-qubit space, the |+⟩ and |−⟩ states form an alternate set of basis in our
single-qubit space and are called the Hadamard basis. This distinction is important
to note because the matrix representations of states and gates are always written with
respect to a particular basis. In our case, we use the computational basis. If we used
the Hadamard basis instead, the matrix elements of all the entities would change.
Another thing to be noted is that we can always express one set of basis in terms of the
other set of basis and vice versa. For example, in the above expressions, the Hadamard
basis is written in terms of the computational basis. One can also rearrange the terms
and also write the computational basis in terms of the Hadamard basis.
The matrix representation of the |+⟩ and |−⟩ states in the computational basis is written
as
√1 1 1 √1 1 1
|+⟩ = 2 = √ and |−⟩ = 2 =√
√1 2 1 − √12 2 −1
2
Now, we can find the matrix representation of the H gate using its above mentioned
definition and following the same method as was done for the X gate. If we do so, we get
the following:
√1 √1 1 1 1
H= 2 2 =√
√1 − 12
√ 2 1 −1
2
What about the action of the H gate on a general single qubit state such as |ψ⟩ =
α
α |0⟩ + β |1⟩ or in matrix form |ψ⟩ = ? We can write
β
1 1 1 α
H |ψ⟩ = √
2 1 −1 β
1 α + β
=√
2 α−β
α+β
√
H |ψ⟩ = 2
α−β
√
2
Input Output
|0⟩ √1 |0⟩ + √1 |1⟩
2 2
|1⟩ √1 |0⟩ − √1 |1⟩
H 2 2
α+β α−β
α |0⟩ + β |1⟩ √
2
|0⟩ + √
2
|1⟩
The S gate can also be called the square-root-of-Z gate, because we get the matrix represen-
tation of the S gate by taking the square root of the elements of the Z gate matrix. Therefore
we can write:
1 0
S=
0 i
√
where i = −1.
Let’s look at the action of the S gate on the |0⟩ and |1⟩ states.
1 0 1
S |0⟩ =
0 i 0
1
=
0
S |0⟩ = |0⟩
1 0 0
S |1⟩ =
0 i 1
0 0
= = i
i 1
S |1⟩ = i |1⟩
But what ifwe have a general superposition state such as |ψ⟩ = α |0⟩ + β |1⟩ or in matrix
α
form |ψ⟩ = ? We can write
β
1 0 α
S |ψ⟩ =
0 i β
α
S |ψ⟩ =
iβ
The action of the S gate on a general qubit state is to multiply the second coefficent with
i. This can be seen explicitly if we consider the bra-ket notation:
3.1.6 T gate
The T gate (or π/8 gate) can also be called the square-root-of-S gate, because we get the
matrix representation of the T gate by taking the square root of the elements of the S gate
matrix. Therefore we can write:
1 0
T =
1+i
0 √
2
√ √
where i = (1 + i)/ 2
Input Output
|0⟩ |0⟩
|1⟩ i |1⟩
S
α |0⟩ + β |1⟩ α |0⟩ + iβ |1⟩
(a) Circuit symbol (b) Truth table
To find the square root of i, we make use of Euler’s formula: eiθ = cos θ + i sin θ.
First, note that eiπ/2 = cos(π/2) + i sin(π/2) = i.
Next, take square root on both sides:
√
i = (eiπ/2 )1/2 = eiπ/4
√ √
= cos(π/4) + i sin(π/4) = 1/ 2 + i/ 2
√ 1+i
i= √
2
Let’s look at the action of the T gate on the |0⟩ and |1⟩ states.
1 0 1
T |0⟩ =
0 eiπ/4 0
1
=
0
T |0⟩ = |0⟩
1 0 0
T |1⟩ =
0 eiπ/4 1
0 0
= = eiπ/4
eiπ/4 1
T |1⟩ = eiπ/4 |1⟩
But what if we have a general superposition state such as |ψ⟩ = α |0⟩ + β |1⟩ or in matrix
α
form |ψ⟩ = ? We can write
β
1 0 α
T |ψ⟩ =
0 eiπ/4 β
α
T |ψ⟩ =
e iπ/4 β
The action of the T gate on a general qubit state is to multiply the second coefficent with
eiπ/4 . This can be seen explicitly if we consider the bra-ket notation:
Input Output
|0⟩ |0⟩
|1⟩ eiπ/4 |1⟩
T
α |0⟩ + β |1⟩ α |0⟩ + eiπ/4 β |1⟩
(a) Circuit symbol (b) Truth table
For historical reasons, the T gate is sometimes also called the π/8 gate. This is because
we can write the matrix of T gate as follows
e −iπ/8 0
T = eiπ/8
0 e iπ/8
Controlled gates
These gates act on something called a target qubit and one or more control qubits. The
action of these gates depends on the state of the control qubit. The target qubit will be
affected by the gate only when the control qubit(s) is(are) in the |1⟩ state(s), otherwise the
target qubit remains as is. In any case, the control qubit(s) always remain the same after
the action of such gates.
|a⟩ • |a⟩
|b⟩ X |a ⊕ b⟩
The above circuit is equivalently and more frequently written as shown in figure 3.9.
|a⟩ • |a⟩
|b⟩ |a ⊕ b⟩
So according to the above description of the action of the CNOT gate, we can write the
outputs for the four different input states as follows:
Input |00⟩: Since the first qubit (control) is 0, the second qubit (target) which is also
0 remains as is. So the output is |00⟩.
Input |01⟩: Since the first qubit (control) is 0, the second qubit (target) which is 1
remains as is. So the output is |01⟩.
Input |10⟩: Since the first qubit (control) is 1, the second qubit (target) which is 0 flips
to 1. So the output is |11⟩.
Input |11⟩: Since the first qubit (control) is 1, the second qubit (target) which is also
1 flips to 0. So the output is |10⟩.
All the above cases are summarized in the truth table as follows:
Input Output
|00⟩ |00⟩
|01⟩ |01⟩
|10⟩ |11⟩
|11⟩ |10⟩
Now, looking at the truth table of the CNOT gate, specifically, the input states and the
second qubit of the output state, we notice a pattern. The second qubit is the result of a
classical XOR operation between the input qubits. To make it clearer, let’s take a look at
the truth table of the classical XOR gate as shown in figure 3.11.
Input Output
0 0 0
0 1 1
1 0 1
1 1 0
So we can write a general expression for the action of the CNOT gate on a two-qubit
system in terms of the XOR operation. If the input state is |a, b⟩ where a, b ∈ {0, 1}, then
the result is
UCNOT |a, b⟩ = |a, a ⊕ b⟩
where ⊕ represents the XOR operation.
Note: The XOR operation is sometimes also called bit-wise addition or modulo-2 addition.
Here are all the rules for the XOR operation (this can also be seen from the truth table
of XOR):
0⊕0=0 0⊕1=1 1⊕0=1 1⊕1=0
All these rules can be generalized into a simple mathematical expression:
(
0 if x = y
x⊕y =
1 if x ̸= y
0⊕x=x⊕0=x and 1 ⊕ x = x ⊕ 1 = x̄
|a⟩ × |b⟩
|b⟩ × |a⟩
According to the defintion of the SWAP gate, the truth table is written as shown in
figure 3.13.
Input Output
|00⟩ |00⟩
|01⟩ |10⟩
|10⟩ |01⟩
|11⟩ |11⟩
But how is it that the two qubits are swapped due to this gate? The SWAP gate actually
consists of three consecutive CNOT gates aligned in an alternating manner as shown in
figure 3.14. The circuit shown in figure 3.12 is actually an equivalent/conventional way of
representing the circuit shown in figure 3.14.
|b⟩ •
|a ⊕ b⟩ |a ⊕ b⟩ |(a ⊕ b) ⊕ b⟩ = |a⟩
Figure 3.14: Working circuit symbol of SWAP gate
Let’s look at the actions step by step. The input state is |a, b⟩.
For the first CNOT gate, |a⟩ is the control qubit, |b⟩ is the target qubit. So the result
of the action of the first CNOT gate is |a, a ⊕ b⟩.
The output of the first CNOT gate will be the input to the second CNOT gate, but
this time the bottom qubit |a ⊕ b⟩ is the control and the top qubit |a⟩ is the target. So
the result of the action of the second CNOT gate is |a ⊕ (a ⊕ b), a ⊕ b⟩. But from the
rules of the XOR operation, we can write
a ⊕ (a ⊕ b) = (a ⊕ a) ⊕ b = 0 ⊕ b = b
The output of the second CNOT gate will be the input to the third CNOT gate where
|b⟩ is the control qubit and |a ⊕ b⟩ is the target qubit. So the result of the action of the
third CNOT gate is |b, (a ⊕ b) ⊕ b⟩. Again, we can write
(a ⊕ b) ⊕ b = a ⊕ (b ⊕ b) = a ⊕ 0 = a
Input Output
|00⟩ |00⟩
• |01⟩ |10⟩
|10⟩ |10⟩
Z
|11⟩ − |11⟩
(a) Circuit symbol (b) Truth table
unchanged. In both cases, the control qubit stays the same after the action of the gate. The
circuit for the CZ gate and its truth table are shown in figure 3.15.
Remember the action of the Z gate: Z |0⟩ = |0⟩ and Z |1⟩ = − |1⟩.
The matrix representation of the CZ gate is as follows:
1 0 0 0
0 1 0 0
UCZ =
0 0 1 0
0 0 0 −1
|a⟩ • |a⟩
|b⟩ • |b⟩
|c⟩ |c ⊕ ab⟩
Since there are 3 qubits taken as input in this gate, there are 8 different possible combi-
nations of input states. And remember, according to our convention, the first number inside
the ket represents the top-most qubit in the circuit, the second number represents the middle
qubit in the circuit and the third number represents the bottom-most qubit in the circuit.
So the truth table will be as shown in figure 3.17.
And since there are 8 different possible combinations of input states, the matrix repre-
Input Output
|000⟩ |000⟩
|001⟩ |001⟩
|010⟩ |010⟩
|011⟩ |011⟩
|100⟩ |100⟩
|101⟩ |101⟩
|110⟩ |111⟩
|111⟩ |110⟩
Q 1. Explain the controlled NOT gate (CNOT gate) with four different input states with
the truth table.
Q 2. Describe the working of controlled-Z gate mentioning its matrix representation and
truth-table.
Q 3. Explain the operations of phase gate (S gate) with |0⟩ and |1⟩ states, with truth table.
Mention its matrix representation.
Q 4. Explain the Hadamard gate. Show that the Hadamard gate is unitary.
Q 5. Explain single qubit gate and multiple qubit gate with example for each.
3.4 Numericals
Q 1. Using Matrix multiplication show that on applying Hadamard gate twice to a |0⟩ results
in its original state.
To show that:
HH |0⟩ = |0⟩
Q 2. Using two X-gates in series show that two not gates in series are equivalent to a
quantum wire.
To show that:
XX = I
H † = (H ∗ )T
∗ T
1 1 1
= √
2 1 −1
T
1 1 1
= √
2 1 −1
1 1 1
=√
2 1 −1
H† = H
It turns out that the Hadamard operator is also Hermitian, which simplifies our work,
because to show H is unitary, we only need to prove HH = I.
1 1 1 1 1 1
HH = √ √
2 1 −1 2 1 −1
1 2 0
=
2 0 2
1 0
=
0 1
=⇒ HH = I
Q 4. Two qubits are passed through a CNOT gate. If the first qubit is the control qubit
then what is the output for the following initial states 1) |00⟩, 2) |01⟩, and 3) |11⟩.
We know that the action of the CNOT gate is to convert |a, b⟩ −→ |a, a ⊕ b⟩. So,