Quantum Architecture and Programming
Prof. Kunal Korgaonkar
BITS-Pilani, K K Birla, Goa Campus
September 13, 2024
1/21
Complex Numbers
Figure: Geometric Representation of Complex Number z = a + bi
⇒ A complex number z ∈ C is a number of the form a + bi.
⇒ a, b ∈ R, and i is the imaginary unit, where i 2 = −1.
√
⇒ Magnitude of z, is given by |z|. |z| = a2 + b 2
⇒ The product of two complex numbers z1 , z2 has magnitude
|z1 |.|z2 | and angle θ1 + θ2 .
⇒ The complex conjugate of a complex number z = a + bi is
defined as z = a − bi, also denoted as z ∗ or z † .
2/21
Quantum Bits
⇒ The two most common states for a qubit (quantum bit) are
the states |0⟩ and |1⟩.
⇒ Notation ”|⟩” is used as a way of distinguishing qubits from
classical bits.
⇒ Qubit x is written inside a ‘ket’, and looks like |x⟩. This is
called Dirac Notation, named after Paul Dirac.
⇒ The actual difference though is that a qubit can be in linear
combinations of states, also know as superpositions.
⇒ General form of a qubit is given by: |ψ⟩ = α|0⟩ + β|1⟩ where
α, β ∈ C and |α|2 + |β|2 = 1
⇒ Two other famous states which are commonly used are:
1 1 1 1
|+⟩ = √ |0⟩ + √ |1⟩ , |−⟩ = √ |0⟩ − √ |1⟩
2 2 2 2
⇒ Generally we view α and β as real instead of complex without
loosing much information.
3/21
Multiple Qubits and Qudit System
⇒ Example of a two qubit System. Here we have four possible
computational basis states, namely |00⟩, |01⟩, |10⟩ and |11⟩.
⇒ General form of such a system is:
|ψ⟩ = α00 |00⟩ + α01 |01⟩ + α10 |10⟩ + α11 |11⟩
where these amplitudes satisfy |α00 |2 + · · · + |α11 |2 = 1
⇒ One of the famous states for such a system are Bell states or
EPR pair(Einsetin, Podolski and Rosen) given by:
1 1
|ψ⟩ = √ |00⟩ + √ |11⟩
2 2
⇒ A Qudit is a d-dimensional system is a superposition of d
basis states. We can write this state as:
|ψ⟩ = α0 |0⟩ + α1 |1⟩ + · · · + αd−1 |d − 1⟩
where |α0 |2 + |α1 |2 + · · · + |αd−1 |2 = 1
4/21
Qubits as Matrices
⇒ Quantum state can be represented as a unit (column) vector
in C2 plane, spanned by basis states:
1 0
|0⟩ = , |1⟩ =
0 1
⇒ A general state |ψ⟩ can be written as:
α
|ψ⟩ = α|0⟩ + β|1⟩ =
β
where |α|2 + |β|2 = 1
⇒ A quantum state |ψ⟩ is a (column) vector, also known as a
ket, whereas a state ⟨ψ| is the (row) vector dual to |ψ⟩, also
know as a bra.
⇒ A bra vector is a conjugate transpose of a ket vector.
†
α
⟨ψ| = (|ψ⟩)† = = α† β†
β
5/21
Inner Product
⇒ Consider the two quantum states: |x1 ⟩ = α1 |0⟩ + β1 |1⟩ and
|x2 ⟩ = α2 |0⟩ + β2 |1⟩
⇒ The inner product (or dot product) of two quantum states
|x1 ⟩ and |x2 ⟩ is defined as ⟨x1 |.|x2 ⟩, which can be further
simplified as ⟨x1 |x2 ⟩.
⇒ Inner product of two states is distance between
two states commonly referred to as fidelity of
the states.
⇒ Inner product of |x1 ⟩ and |x2 ⟩ can be carried out:
α
⟨x1 |x2 ⟩ = α†1 β1† .
2
= α†1 α2 + β1† β2
β2
⇒ Inner product of |x1 ⟩ with itself is always 1.
⟨x1 |x2 ⟩ = α†1 α1 + β1† β1 = |α1 |2 + |β1 |2 = 1
6/21
Example
q
2 √i |11⟩ √1 |10⟩ √1 |11⟩.
⇒ Consider states: |ψ1 ⟩ = 3
|01⟩ + and |ψ2 ⟩ = +
3 2 2
q0
0 ! 0
2 0 0
r
3
2 −i −i
⟨ψ1 |ψ2 ⟩ = . √1 = 0 0 √ × √1 =
0 2 3 3 2 6
1 √1
√i √
3 2 2
⇒ Case 1: Inner Product of |0⟩ with itself:
1
⟨0|0⟩ = 1 0 =1
0
⇒ Case 2: Inner Product of |1⟩ with itself:
0
⟨0|0⟩ = 0 1 =1
1
⇒ Inner product of orthogonal states:
√1
!
0
1 √1
2
⟨0|1⟩ = 1 0 · = 0 , ⟨+|−⟩ = √2 · =0
1 2 − √1
2
7/21
Outer Product
⇒ Outer product of two quantum states |x1 ⟩ and |x2 ⟩ is defined
as |x2 ⟩ · ⟨x1 |, which is often written as |x2 ⟩⟨x1 |.
⇒ When you take the outer product of two state
vectors, such as |x1 ⟩ and |x2 ⟩, you generate a
matrix |x1 ⟩⟨x2 | that can represent transitions or
interactions between these states.
⇒ This time the result would be in fact a matrix, instead of a
complex number. Take the outer product of |x2 ⟩ and |x1 ⟩:
α α
α2 2 1 α2 β1
|x2 ⟩⟨x1 | = . α†1 β1† =
β2 β2 α1 α2 β1
⇒ The relationship between the outer and the inner product:
tr (|x2 ⟩⟨x1 |) = ⟨x1 |x2 ⟩
⇒ Outer Product is used to get density matrices
which work as projection operator in State
Tomography.
8/21
Example
⇒ Consider operator Z that maps computational basis states
|0⟩ 7→ |0⟩
|1⟩ 7→ −|1⟩
⇒ This operator can be written as
|0⟩⟨0| − |1⟩⟨1|
⇒ matrix representation with respect to the basis {|0⟩, |1⟩}:
1 0
0 −1
⇒ As a matrix multiplication with |0⟩ we can give it as:
1 0 1 1
= = |0⟩
0 −1 0 0
⇒ As a matrix multiplication with |1⟩ we can give it as:
1 0 0 0
= = −|1⟩
0 −1 1 −1
9/21
Tensor Products
⇒ Tensor Product is used determine joint state of
multiple qubits.
⇒ Consider the example of |x1 ⟩ and |x2 ⟩ states:
|x1 ⟩ ⊗ |x2 ⟩ = (α1 |0⟩ + β1 |1⟩) ⊗ (α2 |0⟩ + β2 |1⟩)
= α1 α2 |00⟩ + α1 β2 |01⟩ + β1 α2 |10⟩ + β1 β2 |11⟩
⇒ |x1 ⟩ ⊗ |x2 ⟩ can be shortened to |x1 x2 ⟩
⇒ Let us look at amplitudes:
|α1 α2 |2 + |α1 β2 |2 + |β1 α2 |2 + |β1 β2 |2 = (|α1 |2 + |β1 |2 ) · (|α2 |2 + |β2 |2 ) = 1
10/21
Examples
⇒ Consider matrices A and B given below:
a11 a12 b11 b12
A= B=
a21 a22 b21 b22
⇒ Tensor Product A ⊗ B is given as:
b11 b12 b11 b12
a 11 a12
a11 a12 b
⊗ 11
b12 b21 b22 b21 b22
=
a21 a22 b21 b22 b b12 b b12
a21 11 a22 11
b21 b22 b21 b22
a11 b11 a11 b12 a12 b11 a12 b12
a11 b21 a11 b22 a12 b21 a12 b22
=
a21 b11
a21 b12 a22 b11 a22 b12
a21 b21 a21 b22 a22 b21 a22 b22
11/21
Tensor Product Example with a Quantum state
⇒ Consider Quantum States |a⟩ and |b⟩ given as:
αa αb
|a⟩ = |b⟩ =
βa βb
⇒ Tensor product of these quantum states is given as
αb αa αb
αa βb αa βb
αa α
|a⟩ ⊗ |b⟩ = ⊗ b = =
βa βb α βa αb
βa b
βb βa βb
⇒ For a system with 3 qubits each qubit represented as:
|γj ⟩ = αj |0⟩ + βj |1⟩
where j = 1, 2, 3 the joint state is given as:
|γ1 γ2 γ3 ⟩ = |γ1 ⟩ ⊕ |γ2 ⟩ ⊕ |γ3 ⟩
= α1 α2 α3 |000⟩ + α1 α2 β3 |001⟩ + α1 β2 α3 |010⟩ + α1 β2 β3 |011⟩
+ β1 α2 α3 |100⟩ + β1 α2 β3 |101⟩ + β1 β2 α3 |110⟩ + β1 β2 β3 |110⟩
12/21
Characteristics of Tensor Product
⇒ For c ∈ C, |ψ1 ⟩ in H1 and |ψ2 ⟩ in H2
c |ψ1 ⟩ ⊗ |ψ2 ⟩ = c|ψ1 ⟩ ⊗ |ψ2 ⟩ = |ψ1 ⟩ ⊗ c|ψ2 ⟩ (1)
⇒ For |ψ1 ⟩, |φ1 ⟩ in H1 and |ψ2 ⟩ in H2
(|ψ1 ⟩ + |φ1 ⟩) ⊗ |ψ2 ⟩ = |ψ1 ⟩ ⊗ |ψ2 ⟩ + |φ1 ⟩ ⊗ |ψ2 ⟩ (2)
⇒ Tensor product is not commutative:
|ψ1 ⟩ ⊗ |ψ2 ⟩ =
̸ |ψ2 ⟩ ⊗ |ψ1 ⟩ (3)
13/21
Tensor Product use cases:
⇒ Applying Gates on multiple qubits:
⇒ Example: Hadamard gates on multiple qubits: H ⊗n |0⟩⊗n
⇒ For n = 2:
1 1 1
H ⊗2 |0⟩⊗2 = √ (|0⟩ + |1⟩) ⊗ √ (|0⟩ + |1⟩) = √ (|00⟩ + |01⟩ + |10⟩ + |11⟩)
2 2 22
⇒ For N = 3:
1
H ⊗3 |0⟩⊗3 = √ (|000⟩ + |001⟩ + |010⟩ + |011⟩ + |100⟩ + |101⟩ + |110⟩ + |111⟩)
23
⇒ We can generalize this equation as:
1 X
H ⊗n |0⟩⊗n = √ |x⟩
2n x∈{0,1}n
14/21
Quantum Operations
⇒ Hadamard Gate:
⇒ Hadamard Gate maps |0⟩ to |+⟩ and |1⟩ to |−⟩.
1 1 1 1
H|0⟩ = √ |0⟩ + √ |1⟩ = |+⟩ , H|1⟩ = √ |0⟩ − √ |1⟩ = |−⟩
2 2 2 2
√1 !
√1 !
1 1
1 1 1 2 1 1 0 2
H|0⟩ = √ = 1 = |+⟩ , H|1⟩ = √ = = |−⟩
2 1 −1 0 √ 2 1 −1 1 − √1
2 2
⇒ General U Gate:
⇒ U : Cd → Cd has to map from a quantum state to
another quantum state.
⇒ U has to be linear (i.e. U(|x1 ⟩ + |x2 ⟩) = U|x1 ⟩ + U|x2 ⟩)
⇒ In other words, U is a matrix.
15/21
Quantum Operations
⇒ Since both the input and the output should be quantum
states:
⟨ψ|ψ⟩ = 1, (U|ψ⟩)† U|ψ⟩
(U|ψ⟩)† U|ψ⟩ = 1
⇒ |ψ⟩U † U|ψ⟩ = 1
⇒ ⟨ψ|U † U|ψ⟩ = 1
⇒ U†U = 1
⇒ In other words U : Cd → Cd is unitary.
⇒ Unitary operations are invertible (reversible) and its inverse is
its conjugate transpose.
U † (U(|ψ⟩) = |ψ⟩
16/21
Multiple Qubit System
⇒ Consider a system with two qubit systems with |ψ1 ⟩ and |ψ2 ⟩.
⇒ |ψ1 ⟩ and |ψ2 ⟩ individually would be described as 2 × 1 column
vectors
⇒ Collectively we maintain joint state of the entire system,
written as 4 × 1 column vector.
⇒ Consider system where we apply U gate on |ψ1 ⟩ and V gate
on |ψ2 ⟩. We can represent this system as follows:
(U|ψ1 ⟩) ⊗ (V |ψ1 ⟩) = (U ⊗ V )(|ψ1 ⟩ ⊗ |ψ1 ⟩)
⇒ Consider 2-qubit state |ψ⟩.
|ψ⟩ = α00 |00⟩ + α01 |01⟩ + α10 |10⟩ + α11 |11⟩
⇒ When we apply (U ⊗ V ) on |ψ⟩:
(U ⊗V )|ψ⟩ = α00 (U ⊗V )|00⟩+α01 (U ⊗V )|01⟩+α10 (U ⊗V )|10⟩+α11 (U ⊗V )|11⟩
17/21
Example:
Single Z gate on Two qubit which are part of a
superposition:
Here we consider that Identity gate is applied on other qubit, and take
tensor product of the 2 before application on the qubits.
1 0 0 0 1 1
1 0 1 0 0 −1 0 0
0 0
Z |00⟩ = (Z ⊗ I )|00⟩ = ⊗ |00⟩ = = = |00⟩
0 −1 0 1 0 0 1 0 0 0
0 0 0 −1 0 0
1 0 0 0 0 0
1 0 1 0 0 −1 0 0
1
−1 = −|01⟩
Z |01⟩ = (Z ⊗ I )|01⟩ = ⊗ |01⟩ = =
0 −1 0 1 0 0 1 0 0 0
0 0 0 −1 0 0
1 0 0 0 0 0
1 0 1 0 0 −1 0 0
0
0
Z |10⟩ = (Z ⊗ I )|10⟩ = ⊗ |10⟩ = = = |10⟩
0 −1 0 1 0 0 1 0 1 1
0 0 0 −1 0 0
1 0 0 0 0 0
1 0 1 0 0 −1 0 0
0
0
Z |11⟩ = (Z ⊗ I )|11⟩ = ⊗ |11⟩ = = = −|11⟩
0 −1 0 1 0 0 1 0 0 0
0 0 0 −1 1 −1
18/21
Measurement
⇒ Consider qubit |ψ⟩ = α0 |0⟩ + α1 |1⟩, measurement results in 0
or 1 with probabilities |α0 |2 and |α1 |2 respectively.
⇒ Consider a 2-qubit system:
|ψ⟩ = α00 |00⟩ + α01 |01⟩ + α10 |10⟩ + α11 |11⟩
⇒ Then following holds true:
|00⟩ with the probability of |α00 |2
|01⟩ with the probability of |α01 |2
|10⟩ with the probability of |α10 |2
|11⟩ with the probability of |α11 |2
19/21
Partial Measurement
⇒ Consider a 2-qubit system:
|ψ⟩ = α00 |00⟩ + α01 |01⟩ + α10 |10⟩ + α11 |11⟩
⇒ Alice has one of the qubits and Bob measures other.
⇒ Consider that Alice measures its qubit first. Probability for
Alice can be given as:
|0⟩ with the probability of |α00 |2 + |α01 |2
|1⟩ with the probability of |α10 |2 + |α11 |2
⇒ Suppose Alice observed |0⟩.
⇒ Probability for Bob’s measurements follow rules of conditional
probability.
20/21
Partial Measurement
⇒ After Alice measured her qubit becomes:
α00 |00⟩ + α01 |01⟩ α00 |0⟩ + α01 |1⟩
p = |0⟩ ⊗ p
2
|α00 | + |α01 | 2 |α00 |2 + |α01 |2
⇒ Now when Bob measures, the probabilities will look like:
|0⟩ with the probability of |α00 |2 + |α01 |2
|1⟩ with the probability of |α10 |2 + |α11 |2
21/21