Professional Documents
Culture Documents
大一新生也能懂的量子计算
大一新生也能懂的量子计算
大一新生也能懂的量子计算
and
Quantum Physics
Learn Basic Quantum Physics in the point of
view of Linear Algebra
不正经讲师:理科宅Hunt
Abstract vector space
• A set is called vector space (矢量空间) if it satisfies the following axioms. The
elements in the set are called vectors (矢量).
Example – All complex functions
• A set of all wave functions (波函数) is vector space. We can treat wave functions as
vectors!
Example – Electron spins(电子自旋)
• ⋅ are called bra-vector and ⋅ are called ket-vector. Together ⋅ ⋅ , it’s called bracket :D
Physical interpretation of inner product
• Suppose |𝜓⟩ is the initial state of a particle, then the probability of finding it in
|𝜑⟩ state is given by
𝜑𝜓 2
Properties of qubits
Solution:
Tensor product (张量积)
Suppose |𝜓1 ⟩, |𝜑1 ⟩ ∈ 𝐻1 and |𝜓2 ⟩, |𝜑2 ⟩ ∈ 𝐻2 where 𝐻1 and 𝐻2 are two Hilbert
spaces. Then
𝜑1 𝜑2 𝜓1 𝜓2 = 𝜑1 𝜓1 1 𝜑2 𝜓2 2
Where ⋅ ⋅ 1 and ⋅ ⋅ 2 are inner product defined on 𝐻1 and 𝐻2 , respectively.
Example:
01 01 = 0 0 1 1 = 1 ⋅ 1 = 1
011 010 = 0 0 1 1 1 0 = 1 ⋅ 1 ⋅ 0 = 0
• Two quantum states are orthogonal if qubits are different.
Example
• The outer product of two vectors |𝜓⟩ and |𝜑⟩ are defined as
|𝜓⟩⟨𝜑| = 𝜓 ⊗ ⟨𝜑|
• Outer product is used to produce operators (算符).
1 1
Example: Let 𝜓 = 0 + |1⟩. Then 𝑃0 ≡ |0⟩⟨0| is a projection
2 2
operator (投影算符) and it projects the wave function onto |0⟩ state.
1 1 1
𝑃0 𝜓 = 0 00 + 0 01 = 0
2 2 2
Eigenvalues and Eigenvectors
• Let 𝐴መ be an operator. If
𝐴መ 𝜓 = 𝜆|𝜓⟩
Then 𝜆 is an eigenvalue (特征值) of 𝐴መ and |𝜓⟩ is an eigenvector (特征向量)
associated with 𝜆.
𝐴መ = 𝜆𝑖 |𝜓𝑖 ⟩⟨𝜓𝑖 |
𝑖=1
Moreover, 𝜓1 , 𝜓2 , ⋯ , 𝜓𝑛 form a complete basis for the Hilbert space 𝐴መ
living in.
መ
Sometimes, this is called spectral decomposition of operator 𝐴.
Completeness relation (完备性关系)
From spectral theorem, we can easily get the so-called completeness relation:
𝜓1 , 𝜓2 , ⋯ , 𝜓𝑛 is a complete basis if and only if
𝐼 = |𝜓𝑖 ⟩⟨𝜓𝑖 |
𝑖=1
Where 𝐼 is an identity matrix.
Summary
𝑟=1
Global and relative phase
• Global phase DOES NOT affect anything (we can ignore it).
• Relative phase IS important, DO NOT forget it.
Example
Unitary operators
• Definition: An operator, 𝑈, is unitary if 𝑈 † 𝑈 = 𝑈𝑈 † = 𝐼.
• Unitary operator PRESERVES the norm.
𝑈 𝜓 2 = 𝜓 𝑈 † 𝑈 𝜓 = 𝜓 𝜓 = ‖ 𝜓 ‖2
• In other words, unitary operators keep quantum states on the Bloch sphere.
𝑛ො
• Pauli-Euler relation:
exp 𝑖𝛼𝑛ො ⋅ 𝜎Ԧ = cos 𝛼 𝐼 + 𝑖 sin 𝛼 𝑛ො ⋅ 𝜎Ԧ
• 𝑛ො is a unit vector in ℝ3 .
• 𝜎Ԧ = 𝑋𝑥ො + 𝑌𝑦ො + 𝑍𝑧Ƹ is a vector of Pauli matrices.
0 1
• For example: 𝑥ො ⋅ 𝜎Ԧ = 𝑋 =
1 0
• To rotate a state |𝜓⟩ along unit vector 𝑛ො with angle 𝛼, multiply the rotation
matrix 𝑅𝑛ො (𝛼),
𝛼
𝑅𝑛ො 𝛼 𝜓 = exp −𝑖 𝑛ො ⋅ 𝜎Ԧ 𝜓
2
Example
𝜋
Rotate |0⟩ along 𝑥ො by .
2
𝜋 𝜋/2 𝜋/2
Rotation matrix 𝑅𝑥ො = cos 𝐼 − 𝑖 sin 𝑥ො ⋅ 𝜎Ԧ
2 2 2
Pure state and mixed state
• Suppose 𝑟Ԧ1 and 𝑟Ԧ2 are the Bloch vectors of two pure states |𝜓1 ⟩ and |𝜓2 ⟩, then
2
1
𝜓1 𝜓2 = 𝑇𝑟 𝜌1 𝜌2 = (1 + 𝑟Ԧ1 ⋅ 𝑟Ԧ2 )
2
• This formula relates the inner product in 𝐻 and the inner product in ℝ3 .
Example – Bloch sphere geometry
0 −|1⟩
Let 𝜓 = , calculate its purity.
2
This is obvious, since |𝜓⟩ can be drawn on Bloch sphere, so it is a pure state.
Summary
0 1 1 0
𝑋0 = = = |1⟩
1 0 0 1
0 1 0 1
𝑋1 = = = |0⟩
1 0 1 0
• Sometimes, Pauli X matrix is called NOT gate.
Example – Hadamard gate
1 1 1 1 1 1 0 + |1⟩
𝐻0 = = =
2 1 −1 0 2 1 2
1 1 1 0 1 1 0 − |1⟩
𝐻1 = = =
2 1 −1 1 2 −1 2
• If the first bit is 0, do nothing; If the first bit is 1, flip the second
bit.
• You will only know the state of Schrödinger's cat if you open the
box (measure).
• Qubit’s wave function will collapse to a certain state (|0⟩ or |1⟩)
when you measure it.
• To get the final results, you need to measure qubits!
Example
0 − |1⟩
𝐻1 =
2
By reading the coefficients, we know there is 50% chance we get
|0⟩ and 50% change to get |1⟩.
Summary
不正经讲师:理科宅Hunt
Reversible function
• Since quantum gates are reversible, so it’s the same as the classical
reversible AND gate
• To get AND gate, set 𝑐 = |0⟩.
• To get NAND gate, set 𝑐 = |1⟩.
𝑎 𝑎
This is a AND
gate if c=0;
𝑏 This is a NAND 𝑏
gate if c=1.
𝑐 𝑎𝑏 ⊕ 𝑐
Example – Quantum OR gate
𝑎 𝑎
This is a OR gate
if c=0;
𝑏 This is a NOR 𝑏
gate if c=1.
𝑐 𝑎∨𝑏 ⊕𝑐
Universal gate sets
For example:
1. {𝐻𝑎𝑑𝑎𝑚𝑎𝑟𝑑, 𝑃ℎ𝑎𝑠𝑒, 𝜋/8, 𝐶𝑁𝑂𝑇}
2. {𝐻𝑎𝑑𝑎𝑚𝑎𝑟𝑑, 𝑃ℎ𝑎𝑠𝑒, 𝑇𝑜𝑓𝑓𝑜𝑙𝑖, 𝐶𝑁𝑂𝑇}
Decomposition of unitary matrix
𝑈𝑓 : 𝑥 𝑦 ↦ 𝑥 |𝑦 ⊕ 𝑓(𝑥)⟩
Quantum Circuit
If 𝑓 is constant
If 𝑓 is balanced
Quantum Circuit
If 𝑓 is constant If 𝑓 is balanced
𝑓 0 2 𝑓 0 2
𝑃(1𝑠𝑡 𝑏𝑖𝑡 0) = −1 =1 𝑃 1𝑠𝑡 𝑏𝑖𝑡 1 = −1 = 1.
Thus, 𝑃 1𝑠𝑡 𝑏𝑖𝑡 0 = 0
Deutsch-Jozsa Algorithm – Problem Description
𝒙 𝟎
𝒙 half 0s half 1s
or
𝒙 1
Quantum Circuit
𝑈𝑓 : 𝒙 𝑦 ↦ 𝒙 |𝑦 ⊕ 𝑓(𝒙)⟩
Quantum Circuit
Hadamard gate on bit string
Derive formula:
A useful formula:
If 𝑓 is constant If 𝑓 is balanced
Quantum Circuit
If 𝑓 is constant If 𝑓 is balanced
Summary
• You can get rid of the second register, this makes the calculation
easier. This is what the optional in the algo step does.
So, in some textbook, they will ignore the second register 𝐻|1⟩, just
like the Fig.8.2 earlier.
Grover’s Algorithm
Example – Step 1 and 2 (Prepare states)
𝜓 𝜓1 𝜓2 𝜓𝑘
1
𝜓 =𝐻0 = |𝑥⟩
𝑁 𝑥
Example – Step 3 (first iteration)
• For simplicity, there is only one 𝑤 such that 𝑓 𝑤 = 1. Let the collection of the other bit-
strings be 𝜓𝑏𝑎𝑑 . Then we can write
1 𝑁−1
𝜓 = 𝑤 + |𝜓𝑏𝑎𝑑 ⟩
𝑁 𝑁
1 𝑁−1
• Let sin(𝜃) = and cos 𝜃 = . Then after applying 𝐺, we have
𝑁 𝑁
𝜓1 = 𝐺 𝜓 = sin(3𝜃) 𝑤 + cos(3𝜃) |𝜓𝑏𝑎𝑑 ⟩
𝜓 𝜓1 𝜓2 𝜓𝑘
Example – Step 3 (k-th iteration)
𝜓 𝜓1 𝜓2 𝜓𝑘
Summary
1
• Encode: 𝐻 𝑥 = σ1𝑦=0 −1 𝑥𝑦 |𝑦⟩
2
1
• Decode: 𝐻 σ1𝑦=0 −1 𝑥𝑦 |𝑦⟩ = 𝑥
2
2𝑛 −1
1 𝒙
2𝜋𝑖 𝑛 ⋅𝒚
𝑄𝐹𝑇2𝑛 𝒙 = 𝑒 2 |𝒚⟩
2𝑛 𝑦=0
What is 𝑅𝑘 ??
𝑅𝑘 is a rotation matrix,
1 0 1 0
𝑅𝑘 = 2𝜋𝑖/2𝑘 = 2𝜋𝑖(0.0⋯01)
0 𝑒 0 𝑒 𝑘
The action of it is
2𝜋𝑖(0.0⋯01)
0 + 1 1 1 0 1 0 +𝑒 𝑘 1
𝑅𝑘 = 2𝜋𝑖(0.0⋯01) =
2 2 0 𝑒 𝑘 1 2
That means 𝑅𝑘 puts 1 into k-th “decimal” place (keep in mind these
numbers are binary).
Inverse Quantum Fourier Transform
2𝑛 −1
1 𝒙
−2𝜋𝑖 𝑛 ⋅𝒚
𝑄𝐹𝑇2−1
𝑛 𝒙 = 𝑒 2 |𝒚⟩
2𝑛 𝑦=0
Summary
Public key(公钥): 𝑁, 𝑒
Private key(密钥): 𝑁, 𝑑
factors of 𝑁.
Shor’s algorithm (Quantum subroutine)
• We assume at most 1 bit-flip can occur within each bit (In fact, it is
not correctable if more than 1 bit-flip occurs at the same time).
• The way to correct bit-flip error is by copying the bit to extra
bits(ancilla).
• We can determine what operations to perform according to the
ancilla bits.
Encode b to ancilla by using 2 CNOT gates. Abstract this action by 𝐺𝑒𝑛𝑐 gate.
Classical bit-flip correction – Three-bit code
Suppose bit-flip occurs on 1st bit, then the corrupted data is 𝑏ത𝑒𝑛𝑐 = 100
Fault Tolerance circuit
Let 𝜓 = 𝛼0 0 + 𝛼1 |1⟩, and assume the 2nd bit is flipped, recover it.
Summary