Single Qubit Gates
Posted 安徽思远
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Single Qubit Gates相关的知识,希望对你有一定的参考价值。
Logic gates:
We saw that qubits could be represented by
2
D
2 \\mathrm{D}
2D vectors, and that their states are limited to the form:
∣
q
⟩
=
cos
θ
2
∣
0
⟩
+
e
i
ϕ
sin
θ
2
∣
1
⟩
|q\\rangle=\\cos \\frac{\\theta}{2}|0\\rangle+e^{i \\phi} \\sin \\frac{\\theta}{2}|1\\rangle
∣q⟩=cos2θ∣0⟩+eiϕsin2θ∣1⟩
Where
θ
\\theta
θ and
ϕ
\\phi
ϕ are real numbers. In this section we will cover gates, the operations that change a qubit between these states. Due to the number of gates and the similarities between them, this chapter is at risk of becoming a list. To counter this, we have included a few digressions to introduce important ideas at appropriate places throughout the chapter.
The Pauli Gates
You should be familiar with the Pauli matrices from the linear algebra section. If any of the maths here is new to you, you should use the linear algebra section to bring yourself up to speed. We will see here that the Pauli matrices can represent some very commonly used quantum gates.
1. The X X X -Gate
The X-gate is represented by the Pauli-X matrix:
X
=
[
0
1
1
0
]
=
∣
0
⟩
⟨
1
∣
+
∣
1
⟩
⟨
0
∣
X=\\left[\\begin{array}{ll} 0 & 1 \\\\ 1 & 0 \\end{array}\\right]=|0\\rangle\\langle 1|+| 1\\rangle\\langle 0|
X=[0110]=∣0⟩⟨1∣+∣1⟩⟨0∣
To see the effect a gate has on a qubit, we simply multiply the qubit’s statevector by the gate. We can see that the X-gate switches the amplitudes of the states
∣
0
⟩
|0\\rangle
∣0⟩ and
∣
1
⟩
|1\\rangle
∣1⟩ :
X
∣
0
⟩
=
[
0
1
1
0
]
[
1
0
]
=
[
0
1
]
=
∣
1
⟩
X|0\\rangle=\\left[\\begin{array}{ll} 0 & 1 \\\\ 1 & 0 \\end{array}\\right]\\left[\\begin{array}{l} 1 \\\\ 0 \\end{array}\\right]=\\left[\\begin{array}{l} 0 \\\\ 1 \\end{array}\\right]=|1\\rangle
X∣0⟩=[0110][10]=[01]=∣1⟩
X Gate can also be regarded as Not Gate…
# Let's do an X-gate on a |0> qubit
qc = QuantumCircuit(1)
qc.x(0)
qc.draw()
2. The Y & Z-gates
Similarly to the X-gate, the Y & Z Pauli matrices also act as the Y & Z-gates in our quantum circuits:
Y
=
[
0
−
i
i
0
]
Z
=
[
1
0
0
−
1
]
Y
=
−
i
∣
0
⟩
⟨
1
∣
+
i
∣
1
⟩
⟨
0
∣
Z
=
∣
0
⟩
⟨
0
∣
−
∣
1
⟩
⟨
1
∣
\\begin{array}{c} Y=\\left[\\begin{array}{cc} 0 & -i \\\\ i & 0 \\end{array}\\right] \\quad Z=\\left[\\begin{array}{cc} 1 & 0 \\\\ 0 & -1 \\end{array}\\right] \\\\ Y=-i|0\\rangle\\langle 1|+i| 1\\rangle\\langle 0|\\quad Z=| 0\\rangle\\langle 0|-| 1\\rangle\\langle 1| \\end{array}
Y=[0i−i0]Z=[100−1]Y=−i∣0⟩⟨1∣+i∣1⟩⟨0∣Z=∣0⟩⟨0∣−∣1⟩⟨1∣
And, unsurprisingly, they also respectively perform rotations by
π
\\pi
π around the
y
y
y and
z
z
z -axis of the Bloch sphere.
3. Digression: The X, Y & Z-Bases
Eigensates:
We have seen that multiplying a vector by a matrix results in a vector:
M
∣
v
⟩
=
∣
v
′
⟩
←
new vector
M|v\\rangle=\\left|v^{\\prime}\\right\\rangle \\leftarrow \\text { new vector }
M∣v⟩=∣v′⟩← new vector
If we chose the right vectors and matrices, we can find a case in which this matrix multiplication is the
same as doing a multiplication by a scalar:
M
∣
v
⟩
=
λ
∣
v
⟩
M|v\\rangle=\\lambda|v\\rangle
M∣v⟩=λ∣v⟩
(Above,
M
M
M is a matrix, and
λ
\\lambda
λ is a scalar). For a matrix
M
M
M, any vector that has this property is called an eigenvector of
M
M
M. For example, the eigenvectors of the Z-matrix are the states
∣
0
⟩
|0\\rangle
∣0⟩ and
∣
1
⟩
|1\\rangle
∣1⟩ :
Z
∣
0
⟩
=
∣
0
⟩
Z
∣
1
⟩
=
−
∣
1
⟩
\\begin{array}{l} Z|0\\rangle=|0\\rangle \\\\ Z|1\\rangle=-|1\\rangle \\end{array}
Z∣0⟩=∣0⟩Z∣1⟩=−∣1⟩
You may also notice that the Z-gate appears to have no effect on our qubit when it is in either of these two states. This is because the states
∣
0
⟩
|0\\rangle
∣0⟩ and
∣
1
⟩
|1\\rangle
∣1⟩ are the two eigenstates of the Z-gate. In fact, the computational basis (the basis formed by the states
∣
0
⟩
|0\\rangle
∣0⟩ and
∣
1
⟩
|1\\rangle
∣1⟩ ) is often called the Z-basis. This is not the only basis we can use, a popular basis is the X-basis, formed by the eigenstates of the X-gate. We call these two vectors
∣
+
⟩
|+\\rangle
∣+⟩ and
∣
−
⟩
|-\\rangle
∣−⟩ :
∣
+
⟩
=
1
2
(
∣
0
⟩
+
∣
1
⟩
)
=
1
2
[
1
1
]
∣
−
⟩
=
1
2
(
∣
0
⟩
−
∣
1
⟩
)
=
1
2
[
1
−
1
]
\\begin{array}{l} |+\\rangle=\\frac{1}{\\sqrt{2}}(|0\\rangle+|1\\rangle)=\\frac{1}{\\sqrt{2}}\\left[\\begin{array}{l} 1 \\\\ 1 \\end{array}\\right] \\\\ |-\\rangle=\\frac{1}{\\sqrt{2}}(|0\\rangle-|1\\rangle)=\\frac{1}{\\sqrt{2}}\\left[\\begin{array}{c} 1 \\\\ -1 \\end{array}\\right] \\end{array}
∣+⟩=21(∣0⟩+∣1⟩)=21[11]∣−⟩=21(∣0⟩−∣1⟩)=21[1−1]
Another less commonly used basis is that formed by the eigenstates of the Y-gate. These are called:
∣
↺
⟩
,
∣
↻
⟩
|\\circlearrowleft\\rangle, \\quad|\\circlearrowright\\rangle
∣↺⟩,∣↻⟩
4. The Hadamard Gate
The Hadamard gate (H-gate) is a fundamental quantum gate. It allows us to move away from the poles of the Bloch sphere and create a superposition of
∣
0
⟩
|0\\rangle
∣0⟩ and
∣
1
⟩
|1\\rangle
∣1⟩. It has the matrix:
H
=
1
2
[
1
1
1
−
1
]
H=\\frac{1}{\\sqrt{2}}\\left[\\begin{array}{cc} 1 & 1 \\\\ 1 & -1 \\end{array}\\right]
我为Bill Gates熬夜加班的那个晚上