0% found this document useful (0 votes)
7 views

Quantum Computing Notes

The document discusses Dirac notation and concepts in quantum mechanics. It defines ket and bra vectors, tensor products, common bases like the computational and Hadamard bases, the Hadamard operator, and postulates of quantum mechanics including measurement operators and probabilities. Key concepts covered include Dirac notation, inner and outer products, unitary evolution, and the probabilistic nature of quantum measurements.

Uploaded by

kalin.kochnev
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Quantum Computing Notes

The document discusses Dirac notation and concepts in quantum mechanics. It defines ket and bra vectors, tensor products, common bases like the computational and Hadamard bases, the Hadamard operator, and postulates of quantum mechanics including measurement operators and probabilities. Key concepts covered include Dirac notation, inner and outer products, unitary evolution, and the probabilistic nature of quantum measurements.

Uploaded by

kalin.kochnev
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

Combined

Dirac Notation
Dirac Notation

Vectors
A column vector is represented as a "ket".

Outer Product
Tensor Product
|x⟩ ⊗ |y⟩ = |x⟩|y⟩ = |x, y⟩

ex: |00⟩ = |0⟩ ⊗ |0⟩

Common Bases
Bases

Standard vectors
|label⟩ =

A row vector is represented as a "bra"

⎢⎥


an
a1

⟨label| = [a 1 … a n ]

q-bits are always two dimensional


q-dits are always n dimension (digits)

Inner Product

0
0
|0⟩ = [ ], |1⟩ = [ ]
1

1 1
⎡ ⎤ ⎡ ⎤
√2 √2
|+⟩ = , |−⟩ =
1 1
⎣ ⎦ ⎣− ⎦
√2 √2

Z-basis -- the computational basis {|0⟩, |1⟩}


X-basis -- the hadamard basis {|+⟩, |−⟩}

Bell basis: {|Φ +


⟩, |Φ

⟩, |Ψ
+
⟩, |Ψ

⟩}

± 1 1
|Φ ⟩ = |00⟩ ± |11⟩
√2 √2

± 1 1
|Ψ ⟩ = |01⟩ ± |10⟩
√2 √2

Hadamard Operator
https://en.wikipedia.org/wiki/Hadamard_transform
H |0⟩ = |+⟩ and H |1⟩ = |−⟩

The hadamard operator is its own inverse. If you apply it twice, you end up
back at the start
It is NOT the change of basis from Z to X basis
This operator must be hermitian, so its adjoint is its inverse.
Additionally H is its own inverse, so H 2
= I

Postulates of Quantum Mechanics


Postulates of Quantum Mechanics

1: How are quantum states described?


Any quantum state for a closed system (every state is known) is represented as a
normalized vector.

2: How does a quantum system evolve over


time?
Any operation on a quantum state must be a unitary linear operator. This is
derived from Schrodinger's Equation.

3: How are Quantum measurements made?


What is a measurement?
If we have a quantum state of |ψ⟩ = α|0⟩ + β|1⟩, the coefficients of the basis |0⟩
and |1⟩ represent some superposition (an inbetween state) of |0⟩ and |1⟩. Or in
linear algebra terms, it is a linear combination of the two vectors.

We want to measure what state the quantum system "collapses" to. Before we
measure, the system is in some inbetween state. After measurement, it is either
or.

With the definition of |ψ⟩, there is a certain probability of either |0⟩ or |1⟩ (which we
will derive shortly).

How do we make a measurement?


There are certain outcomes that we are interested in measuring. The simplest
example is knowing if the system collapses to |0⟩ or |1⟩, so two outcomes.

What we need to do is define a "measurement operator", M for every outcome x


x

The set of all measurements operators (one for each outcome to measure)

{M x } x∈all outcomes

There is a restriction on what kind of meaurement operator we can define. The


following must be true

∑ Mx Mx = I

x∈X

For each measurement operator, the sum of all the measurement operators
applied to its adjoint must add up to one. This is in order to maintain a probability
distribution (the sum of all outcomes must add up to 1).

Outcome
The measurement operator is a mapping from M : V → V . It outputs a vector in V
space.

Post measured state


Measuring the outcome x on vector |ψ⟩

M x |ψ⟩

The post measured state is the quantum state of the system after measurement.
Since the application of a measurement collapses the system, M |ψ⟩ is not x

necessarily a quantum state since it may not be normalized.

The post measured state |ψ x⟩ is defined as simply the normalized vector


measurement.

M x |ψ x ⟩
|ψ x ⟩ =
√ ⟨M x |ψ x ⟩|M x |ψ x ⟩⟩

These are a lot of symbols, but if we break it down, let the measurement outcome
be |ψ ⟩ = M |ψ ⟩
O x x

|ψ O ⟩ |ψ O ⟩
|ψ x ⟩ = =
√ ⟨ψ O |ψ O ⟩ ∣∣ |ψ O ⟩ ∣∣

Probability of outcome x
The probability of measuring outcome x is simply the squared magnitude of the
measuredment outcome |ψ ⟩ = M |ψ ⟩
O x x

P (x) = ⟨ψ O |ψ O ⟩

Since we take the conjugate of the second argument, this results in taking the
adjoint of M and |ψ ⟩
x x


∗ ∗
⟨ψ O |ψ O ⟩ = I P (M x |ψ x ⟩, M x |ψ x ⟩) = M x |ψ x ⟩⟨ψ x |M x = ⟨ψ x |M x M x |ψ x ⟩

Quantum measurements are always with respect to some basis.


We want to define a set of outcomes that we would like to measure.

Quantum measurements are probabilistic.

Phase
Global phase

Relative phase is the phase between two basis vectors



a|0⟩ + e a|1⟩

Global phase you can pull out of every basis vector



|ψ⟩ → e |ψ⟩

The probability of measuring |ψ⟩ or e iθ


|ψ⟩ are identical. Doesn't effect
probability distribution

∗ −iθ ∗ iθ
p G (i) = w/ global phase = (⟨ψ|U e M i )(M i e U |ψ⟩)

iθ −iθ ∗ ∗
= e e (⟨ψ|U M M i U |ψ⟩)
i
∗ ∗
= ⟨ψ|U M i M i U |ψ⟩

= p(i) = w/o global phase

How does a vector end up picking up a phase? What's the


point?
phase is anything of form e iθ

it is something picked up exploring possible paths


the algorithms try to get phases to cancel out in order to collapse onto an
answer

Does measurement depend on the algorithm?


Algorithms can operate in whatever basis as long as you change to the z-
basis before measurement
Example:

Probablity of measuring state i in B basis is p(i) = | ⟨ψ|v i ⟩|


2

Let U convert psi in the B basis to the Z basis. |ψ⟩ → U |ψ⟩ = |ϕ⟩
n
˙ 2 2 2
p(i) = | ⟨i|ϕ⟩| = |⟨i|U |ψ⟩| = |⟨i| (∑ |j⟩⟨b j |)|ψ⟩|
j=1

If i and j are orthogonal, then 0. Othwerwise 1, so

˙ 2
p(i) =∣ ⟨b i |ψ⟩ ∣

4: Combining 2 systems
|ψ⟩ ∈ C
n
, |μ⟩ ∈ C n

The state space of a composite system is the Tensor Product of the individual
spaces.
Joint state: |ψ⟩ ⊗ |u⟩
See more Entangled systems

Q-bit dimension
Two qbits: C 2
⊗ C
2
≅C
4

{|00⟩, |01⟩, |10⟩, |11⟩}

This is why it is hard to simulate quantum algorithms because the space


scales exponentially

Example:
2 different particles and I want to apply two different operators A and B to each
particle

(A|ψ⟩) ⊗ (B|μ⟩)

Example:
Computing inner product with the bell basis

1 1
|ψ⟩ = |+⟩ ⊗ |+⟩ + |−⟩ ⊗ |−⟩
√2 √2
Find: ⟨Ψ +

+

1 1 1
( ⟨0| ⊗ ⟨0| + ⟨1| ⊗ ⟨1|) ( |0⟩ ⊗ |0⟩ +
√2 √2 √2

1 1 1 1
= (⟨0| ⊗ ⟨0|)(|0⟩ ⊗ |0⟩) + (⟨0| ⊗ ⟨0|)(|1⟩ ⊗ |1⟩) + (⟨1| ⊗ ⟨1|)(|0⟩ ⊗ |0⟩) + (⟨1|
2 2 2 2
1
= 1 ∗ 1 +
2

Find: ⟨Ψ +


⟩ = 0

Find: ⟨Ψ +
|ψ⟩

1 1 1 1
( ⟨0| ⊗ ⟨0| + ⟨1| ⊗ ⟨1|) ( |+⟩ ⊗ |+⟩ + |−⟩ ⊗ |−⟩)
√2 √2 √2 √2

1 1 1 1
= ( ⟨0|+⟩ ⊗ ⟨0|+⟩) + ⟨00| − −⟩ + ⟨11| + +⟩ + ⟨11| − −⟩
2 2 2 2

1 1 1 1 1 1 1 1 1 1 1 1
= ( ) + ( ) + ( ) + (− ∗ − ) = 1
2 √2 √2 2 √2 √2 2 √2 √2 2 √2 √2

Measurement
Measurement

What is a basis measurement?


When we want to know the probability of the quantum state being one of its
basis vectors
if |ψ⟩ is in the z-basis, then the measurement must along be in the z-
basis
Think of it as projecting the current state onto one of the basis vectors

|ψ⟩ = α|0⟩ + β|1⟩


P (0) = ⟨ψ|M M 0 |ψ⟩ = ⟨ψ|0⟩ ⟨0|0⟩ ⟨0|ψ⟩
0

Since ⟨0|0⟩ is 1,
⟨ψ|0⟩ ⟨0|ψ⟩

= ⟨ψ|0⟩⟨0|ψ⟩
2
=∣ ⟨ψ|0⟩ ∣

2
=∣ α ∣

So the probability of observing |0⟩ is the same as the α component squared. This
relates to the Pythagorean Theorem because the total probability must always be
1

Measuring q-dits
See Dirac Notation > ^b2b33e

You can measure a system in a particular ONB {|v 0⟩ … |v n ⟩} if you can


rewrite it
Sometimes
n
Mx = ∑ |v i ⟩⟨ i | ⊗ I B
i=0

1. Write |ψ⟩ = ∑
n
|v i ⟩ ⊗ |b i ⟩
i=0

You can measure in any basiswrite any vector in the basis you are measuring
If measuring in V basis, need v

ex: measure in x-basis

1
|0⟩ = (|+⟩ + |−⟩)
√2

( )
1 1 1 1 1 1
( |+⟩ + |−⟩)|0⟩ + ( |+⟩ − |−⟩)) =
√2 √2 √2 √2 √2 √2

1
(|+⟩)
2

1. P (′′v i ′′) = ⟨b i |b i ⟩

2. Post-measured state |v i ⟩|b i ⟩

What is the difference between a general, basis, partial


and projective measurement?
general measurement - is any kind of measurement but there are special cases
of it
basis measurement - is anything that measure directly on the basis of a state
(which is generally easier)
partial measurement - is only trying to measure if it is |ψ⟩ or I − |ψ⟩
projective measurement - it is complicated, related to SVD

Entangled Systems
Entangled systems

https://en.wikipedia.org/wiki/Quantum_foundations

Entaglement
Operations on one particle (a subspace of the tensor) affects the global state
Alice has access to left subspace, Bob to the right
1 1
|00⟩ + |11⟩
√2 √2

ABAB
|0⟩ ⊗ |0⟩; |1⟩ ⊗ |1⟩

Condition for entaglement: can we write it as a simple tensor product?


Tensored vectors do not necessarily mean they are entagled!

Acting on q-bits individually


Alice can act only on |00⟩, which is modeled by (use left on left, right on right)
+ 1 1 1 1
U ⊗ I B |Φ ⟩ = U ⊗ I ( |00⟩ + |11⟩) = (U |0⟩) ⊗ |0⟩ + (U |1⟩) ⊗ |1⟩
√2 √2 √2 √2

U is operation by Alice, I represents Bob not doing anything


B

example: Find H ⊗ H |Φ +
⟩ in the z basis
H is the haddamard operator

H |0⟩ = |+⟩; H |1⟩ = |−⟩


+ +
= H |Φ ⟩ ⊗ H |Φ ⟩

1
= (H ⊗ H |00⟩ + H ⊗ H |11⟩)
√2

1 1
= |++⟩ + |−−⟩
√2 √2

Change basis to Z. Sanity check, should be normalized

1 1 1 1 1 1 1 1
= ( |0⟩ + |1⟩) ⊗ ( |0⟩ + |1⟩) + ( |0⟩ − |1⟩) ⊗
√2 √2 √2 √2 √2 √2 √2 √2

1 1
= (|00⟩ + |10⟩ + |01⟩ + |11⟩) + (|00⟩ −
2√ 2 2√ 2

1
= |00
√2

Only for bell states U ⊗ I |Φ ⟩ = I ⊗ U |Φ ⟩, which basically says that if


+ ∗ +

Alice does something and bob does nothing, that is the same as alice does
nothing and bob does something
$$\begin{align}

\end{align}$$

Measuring multiple entangled q-bits


Measurement
n n n n
{M x } : C ⊗ C → C ⊗ C

If {M } is a valid 1 q-bit measurement, then {M


x x ⊗ IB } is a valid 2-quibit
measurement (only for Alice)
Proof: Show valid measurment
∗ ∗
= ∑N N x = ∑(M x ⊗ I ) (M x ⊗ I )
x

∗ ∗
= ∑(M x ⊗ I )(M x ⊗ I ) = ∑ M x M x ⊗ I


= (∑ M Mx ) ⊗ I
x

= I ⊗ I = I

What happens to the whole system when Alice measures?


M 0 = |0⟩⟨0|, M 1 = |1⟩⟨1| N 0 = |0⟩⟨0| ⊗ I , N 1 = |1⟩⟨1| ⊗ I

P(Alice seeing a "0") = ⟨Ψ + ∗


|N 0 N 0 |Ψ
+

+
1 1
N 0 |Ψ ⟩ = (|0⟩⟨0| ⊗ I )|00⟩ + (|0⟩⟨0| ⊗ I )|11⟩
√2 √2

1 1
= |0⟩ ⟨0|0⟩ ⊗ |0⟩ + |0⟩ ⟨0|1⟩ ⊗ |1⟩
√2 √2

1
= |00⟩
√2

1 1 1 1 1
⟨00| |00⟩ = ⟨00|00⟩ = ⟨0|0⟩ ⟨0|0⟩ =
√2 √2 2 2 2

The post measured state, when renormalized is |00⟩


Alice measuring ends up changing bobs state to also |00⟩ since it must be
entangled

Quantum Nonlocality
https://en.wikipedia.org/wiki/Quantum_nonlocality

Does not allow faster than light communication

Local Variable Realism


Imagine Charlie seals an envelope with |00⟩ or |11⟩ and decides 50/50
whether to send one or the other to Alice and Bob
This has the same probability distribution as the quantum experiment, so
quantum could be classical in theory
Bell violation w/ chsh game
Experiment is trying to show that you can "play better" by exchanging quantum
information instead of classical (λ), which would indicate something non-classical
is happening

A referee chooses an independent x and y randomly as either x=0 or 1 and


y=0 or 1
Alice and bob can communicate any classical information λ and must guess
a and b as their best guess of x and y
They win the game if a ⊕ b = xy
Classically, there is a 75% of winning but quantum has an 80-85%

x y xy a and b
0 0 0 a(0) xor b(0)

0 1 0 a(0) xor b(1)

Classical
Probability of winning is sum of all possibilities
P (win) = ∑ V (a, b, x, y)P (ab|xy)P (xy)
x,y,a,b

V (a, b, x, y) = 1 if a xor b = xy or 0
P (ab|xy) = (ab|x, y, λ)P (λ)

This shows quantum can't be modeled by classical methods using a hidden


variable (λ)

Quantum strategy
Instead of sharing classical lambda, share a bell state |Φ +
⟩ = |00⟩ + |11⟩

Alice:

1. Preshare a bell state


2. If x=0, measure z-basis output -> a
3. If x=1, apply R and then measure inz-basis (pi/8 is equivalent to a change
π

in basis) output -> a

Bob
1. If y=0, measure in Z basis and output b
2. If y=1, change of basis with R −
π

8
and then measure in the z-basis and output
b
3.

R θ |0⟩ = cos θ|0⟩ + sin θ|1⟩

R θ |1⟩ = − sin θ|0⟩ + cos θ|1⟩

Cases
x=0, y=0, win with probability 1
x=1, y=0 or x=0,y=1 win with probability approx 85%

Alice applies only R π

1 1
(R π
⊗ I) ( |00⟩ + |11⟩) =
8
√2 √2

1 1
= R π
⊗ I |00⟩ + R π
⊗ I |11⟩
8 AB 8 AB
√2 √2

1 π π π
= (cos |0⟩ )|0⟩ 1 (− sin + cos |1⟩)
A B+
√2 8 √2 8 8

1 π 1 π 1 π 1
= cos |00⟩ + sin |10⟩ − sin |01⟩ +
√2 8 √2 8 √2 8 √2

If they see a 00 or a 11, then they win because product of xy must equal a
xor b (add)
Square the coefficients to get the probability of winning in this strategy
2
1 π 1 2 π
P (W ) = cos + cos ≈ 85%
2 8 2 8

x=1,y=1 win with probability 0.5

Total probability of winning P (win) = 1

4
(1 + 0.85 + 0.85 + 0.5) ≈ 80%

Comparison
shared classical < entanglement < PR-box (something that is always right) < 1 bit
faster than light travel
Measuring along the basis |ψ +
⟩ for state |++⟩
+ +
P (ψ ) =∣ ⟨+ + |ψ ⟩ ∣

Measuring one of the subspaces


2 2
Nx : C → C

∑ N x∗ N x

Hadamard w/ entanglement
Bases > Hadamard Operator

Superposition of all bit strings


1 1
⊗n
H ⊗ H ⊗ ⋯ ⊗ H |0 … 0⟩ = H |0 … 0⟩ = |+ ⋯ +⟩ = (|0⟩ + |1⟩) ⊗ ⋯ ⊗ (|0
√2 √2

1
= (|0, 0, … , 0⟩ + |0 … 01⟩ + ⋯ + |
n
√2

1
= ∑
n
√2
x∈{

represents all possible bit strings

Find H ⊗n

1. Re-write H
Assume that |x ⟩ represents an input vector and |y
n n⟩ is the corresp. output
vector
Hadmard is defined as H = |+⟩⟨0| + |−⟩⟨1|

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

1
= (|0⟩⟨0| + |1⟩⟨0| + |0⟩⟨1| − |1⟩⟨1|)
√2

Notice only when |x n⟩ = |y n ⟩ = |1⟩ that there is negative phase on term


Therefore, H =
1

√2

x,y∈{0,1}
(−1)
xy
|y⟩⟨x|

^-when x=1 and y=1, term is −|1⟩⟨1|


x, y ∈ {0, 1} represents all combinations of 0 and 1, so {00, 01, 10, 11}
2. Apply repeatedly with tensor product
⊗n
1
H = H ⊗ ⋯ ⊗ H f actor out 1/sqrt(2) f rom each H
√2 n

⎛ ⎞ ⎛ ⎞
1
x1 y1 xn yn
= ∑ (−1) |y 1 ⟩⟨x 1 | ⊗ ⋯ ⊗ ∑ (−1) |y n ⟩⟨x n |
√2 n ⎝ ⎠ ⎝ ⎠
x 1 ,y 1 ∈{0,1} x n ,y n ∈{0,1}

Applying tensor distributive prop on a sum of elements really gives us all


combinations of elements.
(a 1 + a 2 ) ⊗ (b 1 + b 2 ) = |a 1 b 1 ⟩ + |a 1 b 2 ⟩ + |a 2 b 1 ⟩ + |a 2 b 2 ⟩

Sums are sort of building bit strings (# iterations quadruples w/ every


sum since sum is already double sum x,y)

1 x 1 y 1 +x 2 y 2 +⋯+x n y n
= ∑ ∑ … ∑ (−1) |y 1 … y n ⟩⟨x 1 … x n |
√2 n
x 1 ,y 1 ∈{0,1} x 2 ,y 2 ∈{0,1} x n ,y n ∈{0,1}

1
x⋅y
= ∑ ∑ (−1) |y⟩⟨x|
n
√2 n n
x∈{0,1} y∈{0,1}

1
x⋅y
= ∑ (−1) |y⟩⟨x|
n
√2 n
x,y∈{0,1}

Intuition
H |0⟩ = |+⟩ =
1

√2
(|0⟩ + |1⟩) which creates a balanced superposition between
0 and 1
H is an operator that creates a superposition of all possible bitstring inputs
⊗n

that maps to all possible bitstring outputs


Dimension is HUGE b/c maps all combinations of inputs to every
possible combination of output (n × n)
The phase of each term is determined by
When the dot product between input |x 1 … xn ⟩ and output bit string
|y … y ⟩ is an odd number
1 n

ex: H |11⟩ = |−−⟩ = |00⟩ − |01⟩ − |10⟩ + |11⟩


⟨11|01⟩ = (1 ⋅ 0) + (1 ⋅ 1) = 1 but ⟨11|11⟩ = 1 + 1 = 2 so it has no phase
Consequently, H ⊗n
|x 1 … x n ⟩ =
1

√2
n ∑
y 1 ..y n ∈{0,1}
n (−1)
x⋅y
|y 1 … y n ⟩
POVMs
POVMs (Positive Operator Valued Measures)

Definition: A collection of operators that are positive and the following are true

1. {E x } x∈X for every outcome there is one POVM


2. E is positive, semi-definite for all |z⟩ so ⟨z|E
x x |z⟩ ≥ 0

Positive because p(x) = ⟨ψ|M M |ψ⟩ = ⟨y|y⟩ and the inner product of same

x x

vectors is always positive and real.


3. ∑ E x = I - must be a probability distribution

Any valid measurement can construct a POVM with M ∗


x
Mx

Used when the post-measured state is unimportant

Create a measurement operator than can measure |0⟩ or |+⟩


and never be wrong
Create 3 states

Quantum circuit model


Quantum Circuit Model

Basic Gates
Circuit: acts on n-qubits and consists of multiple "gates" (simple unitary
operators)

https://en.wikipedia.org/wiki/Quantum_logic_gate
NOT gate: the X pauli matrices
Phase flip: the Z pauli matrixes

Pauli X-gate
Maps |0⟩ → |1⟩ and |1⟩ → |0⟩
Each wire = 1 qubit, unless notated otherwise
Each qubit wire is really tensored together

Oracle gate
{0, 1}represents an n-bit string. f (x) represents a classical function converted to
n

quantum gates
Let U be the oracle function {0, 1} → {0, 1}
f
n m

U f |x⟩ ⊗ |y⟩ = |x⟩|y ⊕ f (x)⟩

Ensure invertible
U f |x⟩ = |f (x)⟩ is not answer. Not invertible b/c n ≠ m (diff dimension size)
Solution: Def an n qubit input register |x⟩ ⊗n
and init output register w/ m
qubits |y⟩ ⊗m
so n + m → n + m
Input register is "pass through"
Output register is dummy input (initialized |y⟩ )
|m⟩ |m⟩
= |0⟩

Ensure inner product preserved


Option 1 (definition of XOR)

b ⊕ b = 0 b/c if same, output is always 0


a ⊕ 0 = a (see highlighted table)
Therefore, a ⊕ b ⊕ b = a

a b a ⊕ b

0 0 0
0 1 1
1 0 1

1 1 0

Uf is its own inverse. U f Uf = I

U f |x⟩|y ⊕ f (x)⟩ = |x⟩|(y ⊕ f (x)) ⊕ f (x)⟩ = |x⟩|y⟩

Option 2 (intuitively)

Let two different states be |x, y⟩ → |x, y ⊕ f (x)⟩ and |x , y ⟩ → |x , f (x ) ⊕ y ⟩


′ ′ ′ ′ ′

Inner product must be preserved, so ⟨x, y|x , y ⟩ must equal′ ′

′ ′ ′
⟨x, y ⊕ f (x) ∣ x , y ⊕ f (x )⟩

If x and x are different (0 and 1), then the inner products are both

⟨0|0⟩ ⊗ ⟨y|y ⟩ = 0 and same with ⟨x|x ⟩ ⟨y ⊕ f (x)|y ⊕ f (x )⟩ = 0


′ ′ ′ ′

If y and y' are the same, then ⟨x, y|x , y ⟩ = 1 and


′ ′


⟨x|x ⟩ ⊗ ⟨1 ⊕ f (x)|1 ⊕ f (x )⟩ = 1

b/c x and x' must be 1 or else it would cancel
etc

Controlled Operations
Any controlled operation c(U ) can be constructed from single qubit ops and a
CNOT
"If one thing is true, do U. Otherwise, do nothing"

Control-Not (CN OT )
If the control is in a state of |1⟩, then apply the NOT gate to the target
CN OT |a, b⟩ = |a, a ⊕ b⟩

CN OT |0, 0⟩ = |0, 0⟩

CN OT |0, 1⟩ = |0, 1⟩

CN OT |1, 0⟩ = |1, 1⟩

CN OT |1, 1⟩ = |1, 0⟩

Controlled Gate
A unitary operator that applies a gate depending on a control bit (when = 1)

c(U ) = |0⟩⟨0| ⊗ I B + |1⟩⟨1| ⊗ U


A A

Can replace I with another gate if you want to apply a diff operator when =
B

Check
Check c(U )|0⟩ ⊗ |ψ⟩ = |0⟩ should not use U b/c control is inactive

c(U )|0⟩ ⊗ |ψ⟩ = |0⟩⟨0| ⊗ I |0, ψ⟩ + |1⟩⟨1| ⊗ U |0, ψ⟩

= |0⟩|ψ⟩ + 0

CHeck c(U )|1⟩ ⊗ |ψ⟩ = U |ψ⟩

c(U )|1⟩ ⊗ |ψ⟩ = |0⟩⟨0| ⊗ I |1, ψ⟩ + |1⟩⟨1| ⊗ U |1, ψ⟩

= 0 + |1⟩U |ψ⟩

Exercise: show is unitary operation

How to make any U a controlled operation w/ basic gates


Only need CNOT gates
Any gate U can be written in the form U = e

AXBXC

- where X = N OT and ABC = I


- A,B,C are unitary operators. They are all rotation operators

If control=0

t2 = t1: |0⟩ ⊗ C|ψ⟩

Nothing changes at t2 b/c the controlled


t4 = t3: |0⟩ ⊗ BC|ψ⟩
t5 : |0⟩ ⊗ ABC|ψ⟩ ≡ |0⟩ ⊗ I |ψ⟩ = |0, ψ⟩
Doesn't apply

If control=1

Should map |1, ψ⟩ to |1⟩ ⊗ U |ψ⟩


t1: |1⟩ ⊗ XC|ψ⟩
t3: |1⟩ ⊗ BXC|ψ⟩
t4: |1⟩ ⊗ XBXC|ψ⟩
t5: |1⟩ ⊗ AXBXC|ψ⟩

Alpha gate
A unitary gate which applies a phase
|0⟩ → e

|0⟩ and |1⟩ → e iα
|1⟩

A controlled alpha gate


A controlled alpha gate that applies a phase if control=1
|0, ψ⟩ → |0, ψ⟩ and |1, ψ⟩ → |1⟩ ⊗ e iα
|ψ⟩

It is equivalent to a single gate on one qubit


- Applying a phase on a single qubit applies it globally
- Only the top wire is the control, which is why we don't put it on the bottom
wire

1 0
V = ( )$$![[P astedimage20230320153144.png]]

0 e

Toeffoli gate
A 3 qubit operation, |x, y, z⟩ → |x, y, z ⊕ xy⟩
Means if y AND z are both 1, then flip z
Like a double input controlled NOT, C 2
(X)

Can be built from CNOT (2-qubit op) and unitaries (1-qubit op). Can't do it
classically with the same number of inputs

Ex: If all 5 wires =1, then do U


Need to add 4 dummy wires (Need N-1 auxiliary wires in general)
Need to "deallocate" the dummy wires at the end because if you don't, the
entanglement may affect future results
5
C (U )
Quantum algorithms
Quantum Algorithms

Process
1. Prepare a state |ψ ⟩, which is |x x … x ⟩ and x ∈ {0, 1}
x 1 2 n n

-> this is actually 2 because the space is a tensor of x … x which doubles


n
1 n

every time (since 0 or 1)


2. Run a unitary algorithm U |ψ x⟩

3. Measure (usually in z-basis) then interpret the output


4. May need to repeat the algorithm since measurements are probabilistic

Practicality
It is not always practical to create U because it is 2 × 2 matrix. Use basic
n n

Quantum Circuit Model > Quantum circuit model to decompose U

Deutsch-Joza Algorithm
#game
A person gives the computer a function f (x) where f : {0, 1}
n
→ {0, 1} and are
promised either
balanced - half of input space outputs a 0, and half outputs a 1 (randomly
assigned)
constant - constant (0 or 1) for all values of x

The computer must answer in as few queries as possible to answer whether it is


balanced or constant.

Assuming f (x) can be converted into a quantum circuit (so inputs are a
superposition of possible inputs), this algorithm can give with 100% certainty
whether balanced or constant. Uses "quantum parallelism"

Summary
Classical needs 2 n−1
+ 1 queries worst case while quantum needs only 1
Need to test half input space + 1 to determine if balanced or constant (
n
2
+ 1
2

)
"Phase kickback" where by algebraic manipulation you can re-express the
current state differently so the classical output is in the phase

|t 1 ⟩

At, apply the hadamard to the inputs |t 1⟩ : H


⊗n+1
|0⟩
⊗n
|1⟩
⎛ ⎞
1 1 |0⟩ − |1⟩ 1
|t 1 ⟩ = ∑ |x⟩|−⟩ = ∑ |x⟩ ( ) = ∑ |x, 0⟩
⎝ √2 n n
⎠ √2 n n √2 √ 2 n+1 n
x∈{0,1} x∈{0,1} x∈{0,1}

|t 2 ⟩

At |t ⟩, apply the oracle gate in order to represent a classical function.


2

1
|t 2 ⟩ : U f |t 1 ⟩ = ∑ |x⟩|0 ⊕ f (x)⟩ − |x⟩|1 ⊕ f (x)⟩
√ 2 n+1 n
x∈{0,1}

Check what t evaluates to for cases f (x) = 0 and f (x) = 1


2

If f(x)=1:

1 1
∑ |x⟩ ⊗ (|0 ⊕ 1⟩ − |1 ⊕ 1⟩) = ∑ |x⟩(|1⟩ − |0⟩)
√ 2 n+1 n √ 2 n+1 n
x∈{0,1} x∈{0,1}

1
= ∑ −|x⟩|−⟩
√2 n n
x∈{0,1}

If f(x)=0:

1 1
∑ |x⟩ ⊗ (|0 ⊕ 0⟩ − |1 ⊕ 0⟩) = ∑ |x⟩(|0⟩ − |1⟩)
√ 2 n+1 √ 2 n+1
x∈{0,1} n x∈{0,1} n

1
= ∑ |x⟩|−⟩
√2 n n
x∈{0,1}

Notice the negative sign is the only difference. We can "kick back" the phase (the
sign) by making it depend on the value of f(x) only.

1
f (x)
|t 2 ⟩ = ∑ (−1) |x, −⟩
√2 n
n
x∈{0,1}

|t 3 ⟩
⎛ ⎞
1
⊗n f (x) ⊗n
|t 3 ⟩ : (H ⊗ I )|t 2 ⟩ = ∑ (−1) H |x⟩ ⊗ I |−⟩
⎝ √2 n n

x∈{0,1}

⎛ ⎞
1 f (x)
1 x⋅z
= ∑ (−1) ∑ (−1) |z⟩ ⟨x|x⟩ ⊗ |−⟩
√2 n n √2 n ⎝ n

x∈{0,1} z∈{0,1}

1 f (x)+x⋅z
= ∑ ∑ (−1) |z⟩ ⊗ |−⟩
n
2
n n
z∈{0,1} x∈{0,1}

The ⊗|−⟩ is known as a separable state. It can effectively be "factored" out of the
entire sum.


x∈{0,1}
n is the superposition of all input bit strings

z∈{0,1}
n is the sum of all possible outcomes, similar to
α|0 … 0⟩ + β|00 … 1⟩ + ⋯ + z|1 … 1⟩

The probability of observing a particular outcome z bitstring is the squared


magnitude of the outcome ∣ α ∣ 2

Coefficient in each case is 1

2n

x∈{0,1}
n (−1)
f (x)+x⋅z

Measure the probability of outcome z = 00 … 0


2

1 f (x)+x⋅z
P (z = 0 … 0) = ∑ (−1)
n
2
x∈{0,1} n

1
f (x)
because z=all zeroes, ∑ (−1)
n
2
n
x∈{0,1}

Interpreting the results


If f(x) is constant (all zeroes or all ones)

The probability is 1 if constant


f(x)=0
2
2
1 1
f (x) n
∑ (−1) = 2 = 1
n n
2 2
n
x∈{0,1}

f(x)=1
Example

period?


If f(x) is balanced (half 1s, half 0s)

The probability is 0 if balanced

2
1

n

x∈{0,1}

Quantum teleportation
n
(−1)
1

f(x)=f(y) iff y = xxors for some secret S

f (x) = f (x + r) = f (x + 2r)
n

f (x)

Classically best method is guess and check (2


that match

x∈{0,1}

Can't communicate faster than light. The bell pair


n

2
(−1)

n
f (x)

∈ {0, 1}
2

You have a punction with a hidden period s. In how many queries can you find the

Alice needs to send two classical bits to Bob so then he can apply the x and
z gate depending on what Bob's results are
1 entangled bit + 2 classical bits >= 1-qubit

Superdense coding
Density Operators

1. Person A and B share a bell pair |Φ


2. A encodes 2 bit message onto one half of entangled pair
3. A sends their particle to B so they have both particles
4. Bob does a bell measurement
| Probability | m | m | Operator |
2 1
+

=

n
1

2
n
(−2

(1 + 1 + ⋯ + 1) + (−1 − 1 ⋯ − 1)

n/2
n
)
2

= 1

= 0

) until you find two outputs


| ----------- | ------- | ------- | -------- |
| p(00) | 0 | 0 | I |
| p(01) | 0 | 1 | X |
| p(10) | 1 | 0 | Z |
| p(11) | 1 | 1 | XZ |

W/ prob p(00) Alice applies (I A ⊗ I B |Φ


+
⟩⟨Φ
+
|I

A
⊗ I

B
). Repeat w/ other
probabilities

+ + ∗
+p(01)(X A ⊗ I B |Φ ⟩⟨Φ |X ⊗ I)

X- not gate
+ + + + − − − −
ρ = p(00)|Φ ⟩⟨Φ | + p(01)|Ψ ⟩⟨Ψ | + p(10)|Φ ⟩⟨Φ | + p(11)|Ψ ⟩⟨Ψ |

Apply partial trace to see that no information is transfered


+ + −
ρ B = tr A (ρ AB ) = tr A (p(00)|Φ ⟩⟨Φ |) + … tr A (p(11)|Ψ ⟩⟨|)

If we ignore Alice's particle, we cannot distinguish between different states at


all (everything always ) I

- The reduced system is identical to the coinflip {( , |0⟩), ( , |1⟩)} 1

2
1

- Is 1 qubit b/c Bob's system is only one particle

1 I
+ +
tr A (|Φ ⟩⟨Φ |) = (|0⟩⟨0| + |1⟩⟨1|) =
2 2

What if two density operators are "close" to one


another?
They should act similarly if they have similar parameters

1 1
Δ(ρ, σ) = tr|ρ − σ| = ∑ |λ i |
2 2

ρ, σ are both two density operators


λi are eigenvalues of ρ − σ
1/2 comes from triangle inequality

Properties
Δ(ρ, σ) = Δ(σ, ρ)
Δ(ρ, ρ) = 0

Δ(ρ, τ ) ≤ Δ(p, σ) ≤ Δ(ρ, σ) + Δ(σ, τ )

let tau=rho

Δ(ρ, ρ) ≤ Δ(ρ, σ) ≤ 2Δ(ρ, σ)

0 ≤ 1 ≤ 2

1
0 ≤ ≤ 1
2

Distance between classical prob. distributions


Classical random variable/information can be modeled as quantum state
Lets say we have ensemble of states E x : {(P x (n), |n⟩)} and
E y : {(P Y (n), |n⟩)}

Density operator ρ = ∑ n

i=0
P x (i)|i⟩ ⟨i⟩ and ρ = ∑ n

i=0
P y (i)|i⟩⟨i|

n n

ρ − σ = ∑ P x (i)|i⟩ ⟨i⟩ − ∑ P y (i)|i⟩ ⟨i⟩

i=0 i=0

= ∑(P x (i) − P y (i))|i⟩⟨i|

This is a diagonal matrix b/c |i⟩⟨i|


Eigenvalues are the entries along the diagonal, P x (i) − P y (i)

The distance between two different probabiltiy distributions absolute diff.


between probabilities of each ∑ |P (i) − P (i)|
1

2
n

i=0 x y

Δ(ρ, σ) = max M tr((M [ρ − σ]))

= max P (tr(M [ρ]) − tr(M [σ]))

= max M (tr(M [ρ] − M [σ]))

= max M (tr(M [ρ]) − tr(M [σ]))

Trying to find the maximum distance between the probability distributions


P first element of a two outcome measurement
Where M is a projector/measurement onto a subspace and is being applied
to ρ − σ

Quantum Teleportation
Quantum Teleportation

Alice has a quantum state |ψ⟩ = α|0⟩ + β|1⟩she wants to the information send to
Bob. How does she do it?

You never are transmitting particles! Just information about the state

Doesn't violate Quantum Complexity > No cloning theorem b/c |ψ⟩ is


destroyed by measurement and there is only one particle with exactly |ψ⟩ s ′

state

Overview
1. Split a bell pair |Φ +
⟩ =
1

√2
(|00⟩ + |11⟩) particle and give one to Alice and one
to Bob
Alice has two particles, her quantum state and her bell pair
2. Alice applies a CN OT w/ Alice's particle (control) and Bob's particle target
3. Alice applies hadamard on the state she wants to send
4. She then measures the state of |ψ⟩ and her pair. She sends the classical
information to Bob who then applies an X gate or a Z gate based on
5. Alice measures her particle's state

Derivation
+ 1 1 1
t 0 = |ψ⟩ ⊗ |Φ ⟩ = (α|0⟩ + β|1⟩) ( |00⟩ + |11⟩) = (α|000⟩ + α|011⟩ + β|100⟩
√2 √2 √2

Apply CNOT and Hadamard to Alice


1
t1 = (α|000⟩ + α|011⟩ + β|110⟩ + β|101⟩)
√2

Apply the CNOT gate to |ψ⟩ (control) and to Alice's bell pair (target)
If |ψ⟩ = 1, then that flips the bell pair
Doesn't affect Bob's bell pair

2
t 2 = (H ⊗ I )|t 1 ⟩ =

1 1
(α(|0⟩ + |1⟩)|00⟩ + α(|0⟩ + |1⟩)|11⟩ + β(|0⟩ − |1⟩)|10⟩ + β(|0⟩ − |1⟩)|01⟩)
√2 √2

1
= (α|000⟩ + α|100⟩ + α|011⟩ + α|111⟩ + β|010⟩ − β|110⟩ + β|001⟩ − β|101⟩)
2

Measure Alice's qubits


Measure the first two qubits that alice has at at |t ⟩. 3

How would you measure something like


α|0⟩ + β|1⟩ + γ|0⟩ + λ|0⟩ = (α + γ + λ)|0⟩ + (β)|1⟩

Cluster together terms


P(0)= (α + γ + λ) 2

Let |e n⟩ be the nth term here

1 1
|00⟩ ⊗ ( α|0⟩ + β|1⟩)
2 2

1 1
+|01⟩ ⊗ ( α|1⟩ + β|0⟩)
2 2

1 1
+|10⟩ ⊗ ( α|0⟩ − β|1⟩)
2 2

1 1
+|11⟩ ⊗ ( α|1⟩ − β|0⟩)
2 2

Bob applies X or Z depending on Alice's results


1 ∗ 1 ∗ 1 1 1 2 1 1
P r(′′00′′) = ⟨e 0 |e 0 ⟩ = ( α |0⟩ + β ⟨1⟩) ( α|0⟩ + β|1⟩) = |α| + ∣ β ∣=
2 2 2 2 4 4 4

We know α 2
+ β
2
= 1 b/c is a normalized quantum state

If the state observed for Bob was...


"00" PM = |e 0 ⟩
=
|e 0 ⟩
= α|0⟩ + β|1⟩ = |ψ⟩ by default
√ P (′′00′′) 1

4
"01" α|1⟩ + β|0⟩ → apply X gate → α|0⟩ + β|1⟩ = |ψ⟩

If you have 01 you can do a bit flip and get |ψ⟩ back!
The X gate (bit flip) is controlled by the second bit

"10" α|0⟩ − β|1⟩ → apply Z gate → α|0⟩ + β|1⟩

The Z gate (phase flip) is controlled by the first bit

"11" α|1⟩ − β|0⟩ → apply Z and X basis

Density Operators
Density Operators

A quantum system can be prepared with predetermined propabilities (p i, |ψ i ⟩)

for i = 1 to i = n
The density operator is defined as ρ = ∑ i
p i |ψ i ⟩⟨ψ i |

Not typically used for algorithms, but communication

Probability and eigenvalues

This is an extension of the spectral decomp of an operator such that


∑ λ i |v i ⟩⟨v i |; λ i ≥ 0
i

pi are the eigenvalues of the density operator


Density operators unaffected by global phase

Requirements
1. Must be Hermitian ρ ∗
= ρ

2. Positive semidefinite ⟨x|ρ|x⟩ ≥ 0


3. Has unit trace tr(ρ) = 1 (sum of eigenvalues = 1)

At least one ensemble of states exists to create each density operator ρ

Partial trace
Is linear
Is equivalent to zooming in to a single party's particle to see what information
is available to them
Trace of outer product is same as inner product
tr A ignores A's information. Only gives the reality that B can observe

ρ B = tr A (|a 1 ⟩⟨a 2 | ⊗ |b 1 ⟩⟨b 2 |) = tr A (|a 1 ⟩⟨a 2 |) ⊗ |b 1 ⟩⟨b 2 |

= ⟨a 1 |a 2 ⟩|b 1 ⟩⟨b 2 |

**any operator can be written as ρ = ∑ |a 1,i ⟩⟨a 2,i | ⊗ |b 1,i ⟩⟨b 2,i |

Postulates
1. Open systems w/ incomplete information/uncertainty of state can be made
with the density operator
2. Given ρ and U , the evolved state is U ρU ∗

3. Given ρ and {M }, p(x) = tr(M


x x

M x ρ)

Examples
What is the prob of measuring |ψ⟩ with the ensembled (1, |ψ⟩⟨ψ|)?

Should be 1 since closed systems can still be created


M x = |0⟩⟨0| , ρ = |ψ⟩⟨ψ|

p(x) = tr(M M x ρ)
x

= tr(|0⟩ ⟨0|0⟩⟨0|(|ψ⟩⟨ψ|))

= tr(|0⟩⟨0|)

2
⟨ψ|(|0⟩ ⟨0|0⟩⟨0|)|ψ⟩ = ⟨ψ|0⟩ ⟨0|ψ⟩ = | ⟨ψ|0⟩|

Fourier Transform
Fourier transform

DFT is a change of basis (x 0 … x n ) → (y 0 … y n )

Classical discrete FT: y k ≡


1

√N

n−1

j=0
xj e
2πijk/N

Converts input vector to amplitude in frequency domain


N is # of frequencies
k is particular
ω = e
2πi/N
can be used as a shorthand

Quantum fourier transform


N −1 N −1

∑ x j |j⟩ → ∑ y k |k⟩

j=0 k−0

yk is FT of state amplitude x j

QFT only affects amplitudes. Basis states remain the same

Prep work
1. Write the state |j⟩ in binary form, j = j 12
n−1
+ ⋯ + jn 2
0
, or shorthand
j = j1 j2 … jn

Binary fraction notation: A fraction can be represented in binary fraction


notation with 0.j j … j =
0 1 + + ⋯ +
m
j0

2
j1

4
jm

2
m+1

Definition
(0.j n ) (0.j n−1 j n ) (0.j 1 j 2 …j n )
(|0⟩ + ω |1⟩) ⊗ (|0⟩ + ω |1⟩) ⊗ ⋯ ⊗ (|0⟩ + ω |1⟩)
|j 1 , … , j n ⟩ =
n/2
2

notice power of ω is a binary fraction


All we need to compute are the binary fractions to compute transform

Rk is the phase gate

1 0
Rk = [ k
]
2πi/2
0 e

Examples
QFT of |0⟩
1 n−1 jk
|j⟩ → QFT → ∑ ω |k⟩
√N k=0

Find the QFT of |0⟩ with N = 2 (across two states)


1
2 −1
1
0⋅k
∑ w |0⟩
√2
k=0

1 0⋅0 0⋅1
(ω |0⟩ + ω |1⟩)
√2

1
(|0⟩ + |1⟩)
2

|w⟩ = exp(

Fourier transform is invertible F


⋆ |0⟩ = F (F |1⟩) = |1⟩

If we can show F
† †

F = FF = I

We use 2 because we are using qdits now |1⟩, |2⟩ …


n

The fourier transform is just like any other linear operator


n
1 2 −1 jk
∑ ω |k⟩⟨j|
√2 n j,k=0

n n
2 −1 2 −1
† 1 ′ ′ † 1
j k ′ ′ jk
F F = ( ∑ (ω ) |j ⟩⟨k |) ( ∑ ω |k⟩⟨j|)
√2 n √2 n
j ′ ,k ′ =0 j,k=0

1 ′
−j k

′ ′
( ∑ ω |j ⟩ ⟨k |k⟩⟨j|)
n
2 ′ ′
k ,j ,k,j

Quantum complexity
Quantum Complexity

|ψ⟩ → U → M is really the same as |ψ⟩ → U other

Any intermediate measurements can be simulated as unitary operators


anyways
We simulate measurements by putting the "measured" state into a new
superposition. This doesn't collapse the state
~
|ψ⟩ → U → M

|ψ⟩ ⊗ |0⟩ → U ⊗ I → |ϕ⟩ ⊗ |0⟩ → V

If the measurement M is complicated to describe, then so will the algorithm


V
CN OT |ψ, 0⟩ =
1

√2
(|00⟩ + |11⟩) This is equivalent to copying the state

You can use CNOTs to "record" what you would have measured at that point
and copy into an auxiliary register
If |ψ⟩ = 1

√2
(|0⟩ + |1⟩) , we can save a copy of |ψ⟩ into another register

Measurements as Unitary Operators


Apply a unitary operation is really the same thing as a measurement, except
you don't observe it and destroy the state
You can save the effect of an operation/measurement into another register to
observe the progress of the algorithm later
doing so doesn't collapse the state
V is an operator that shoves the measurement outcome into the 2nd tensor
(auxiliary space) V |ϕ, 0⟩ = ∑ M |ϕ⟩ ⊗ |x⟩
x x

Auxiliary space keeps track of all the possible outcomes that could have
been
The complexity of an algorithm isn't solely on the unitary operations, but also
the measurements.

No cloning theorem
There does not exist an operator U such that U |ψ, 0⟩ = |ψ⟩ ⊗ |ψ⟩ for all |ψ⟩

Orthogonal things are the only things you can clone


Does not preserve inner norm
U |ψ, 0⟩ = |ψ⟩ ⊗ |ψ⟩ and U |ϕ, 0⟩ = |ϕ⟩ ⊗ |ϕ⟩
⟨ψ|ϕ⟩ ⟨0|0⟩ ≠ ⟨ψ|ϕ⟩ ⟨ψ|ϕ⟩

Correlary
If you can't clone something, then you can't erase a quantum state
U |ψ, ψ⟩ → |ψ, 0⟩ , which is really U ∗
|ψ, 0⟩ → |ψ, ψ⟩ which is the no cloning
theorem

Shor's Algorithm
Shor's Algorithm

Factoring can be converted into a period finding problem, which can be


solved with quantum phase estimation
Let N = pq where p, q are odd and of almost equal length

Factoring
Two prime factors of a number n can be determined by
2
n ≡ 1 (mod n)
2
n − 1 ≡ 0 (mod n)

(n + 1)(n − 1) ≡ 0 (mod n)

This says that (n+1)(n-1) are divisible by n


Therefore, n+1 has a number that divides it and n. Same w/ n-1
gcd(n + 1, n) and gcd(n − 1, n) are the factors

Can be extended to r roots so n r


≡ 1 (mod n)

Periodicity
f is periodic if f (a) = f (a + n) for period size n
f (r) = a
r
(mod n) are periodic
a must be co-prime with n (guess, if not, try again with a different guess)

Example: Want to find factors for n = 21 and a = 2

This function has a period of 6


f(0) = f(0+6)
| r | | f(r) |
| --- | -------- | ---- |
| 0 | 2^0 % 21 | 1 |
| 1 | 2^1 % 21 | 2 |
| 2 | 2^2 % 21 | 4 |
| 3 | 2^3 % 21 | 8 |
| 4 | 2^4 % 21 | 16 |
| 5 | 2^5 % 21 | 11 |
| 6 | 2^6 % 21 | 1 |
| 7 | 2^7 % 21 | 2 |

You might also like