Part II: Introducing quantum logic gates
Preface
Quantum Logic Gates and Computational Foundations
Role of Quantum Logic Gates
Quantum logic gates manipulate quantum information (qubit states), analogous to classical gates (AND, OR, NOT) in conventional computing.
They serve as the fundamental building blocks of quantum computation and enable tasks like quantum teleportation.
Quantum vs. Classical Gates
-
Similarity: Some quantum gates are inspired by classical logic gates.
-
Key Differences:
Quantum gates exploit superposition and entanglement to process information non-classically.
These "seemingly minor" differences enable exponential computational advantages (e.g., Shor’s algorithm, Grover’s search).
Key Insight
The unique capabilities of quantum gates underpin quantum computing’s potential to surpass classical limits.
While learning gates is foundational yet demanding, it unlocks insights into revolutionary applications like cryptography-breaking and large-scale optimization.
The quantum NOT gate
It has the same function like classical gate such as:
when does it apply to a general superposition state which is
it acts linearly on the quantum state
so:
The notation X is served as the quantum NOT gate
Quantum Circuit Representation.
In a quantum circuit we depict an X gate as follows:
The line from left to right is what’s called a quantum wire.
the left is the input,the right is the output,so we get something like:
Matrix Representation
in the matrix representation, can be considered as the vector.
Therefore:
In fact, all quantum gates can be thought of as matrices
Function
the X gate is a mathematical function,taking the input states to output states.
As mentioned earlier,the function is the matrix,exhibiting the linear properties
Quantum wires: why the simplest quantum circuit is often also the hardest to implement
It's a single quantum wire:
This circuit is just a single qubit being preserved in time
as we discussed before,the left is input,the right is the output.
if the qubit go through the wire,nothing will change
Mathematically, this circuit is trivial. But physically it's far from trivial. ln many physical systems, the quantum wire is actually one of the hardest quantum computations to implement!
(Reason:quantum states are Often incredibly fragile.)
The tension
-
Contradiction Between Quantum Wires and Quantum Gates
The Neutrino Case Study:
Advantage: Neutrinos barely interact with other matter, enabling long-term stable storage of quantum states (e.g., passing undisturbed through a lead block).
Disadvantage: Weak interactions make it impossible to manipulate their quantum states, thus hindering quantum gate implementation.-
Universal Conflict:
Quantum Storage Requirement: Qubits require weak environmental coupling to minimize decoherence (maintaining stability).
Quantum Gate Requirement: Quantum operations demand strong controllable coupling for precise state manipulation.
-
Core Conflict:
Systems acting as "perfect quantum wires" (weak coupling) struggle to support quantum gate construction (requiring strong coupling), and vice versa.
-
-
Quantum Computer Design Strategies
Dynamic Coupling Design:
Systems are designed to default to weak coupling (protecting quantum states) but trigger strong coupling on demand (executing gate operations).
Implementation Methods: Examples include external controls like lasers or microwave pulses to temporarily enhance inter-qubit interactions.
A multi-gate quantum circuit
simple example:
It's no pressure to know that there is no difference between the input and the output.
so:
From the matrix perspective
XX is the multi-gate quantum circuit
therefore:
The Hadamard gate
It clearly involves quantum effects
here's what is does for the quantum basis states:
It also contains the linear property
for the general states:
Like X gate,the circuit representation of H:
the matrix of H:
so if H act on the :
if H act on the ,you can write down by yourself
What makes the Hadamard gate interesting as a quantum gate? What can we use it to do?
What the Hadamard and similar gates do is expand the range of operations that it’s possible for a computer to perform. That expansion makes it possible for the computer to take shortcuts, as the computer “moves” in a way that’s not possible in a conventional classical computer. And, we hope, that may enable us to solve some computational problems faster.
Practice
let's analyze a simple circuit:
If we approach this from the matrix perspective,the HH will be:
therefore,the input and the out put is the same
if we use the definition to calculate it,the thing will be trouble but the outcome is also the same
Exercise
Key Analysis
J
- Non-Unitary Matrix:
Quantum gates must be unitary matrices to ensure probability conservation. Verifying the unitarity of
J:
proving that is not unitary
- Information Loss:
Applying
J to the input state results in the zero vector, implying complete loss of quantum information, which violates the reversibility requirement of quantum gates.
HX
it's about the order of the matrix muliplication
Measuring a qubit
for a quantum state ,there is no way to figure out and if they start out unknown.
To put the state a slightly different way, the quantum state of any system – whether it be a qubit or a some other system – is not directly observable.
what can we figure out from the quantum state?
measurement in the computational basis
is the way we typically extract information from our quantum computers
Suppose a qubit is in the state
When you measure this qubit in the computational basis it gives you a classical bit of information: it gives you the outcome 0 with probability
, and the outcome 1 with probability
if it exists the physical system,after the measurement interaction for the qubit,for instance,we may get the outcome 0-which we can use to do other things and to control other preocesses
(A fundamental fact about this measurement process is that it disturbs the state of the quantum system)
A key point to note is that after the measurement, no matter what the outcome,
α and β are gone. No matter whether the posterior state is ∣0⟩ or ∣1⟩, there is no trace of α or β. And so you can’t get any more information about them. In that sense, α and β are a kind of hidden information – the measurement doesn’t tell you what they were.
It's useful to have a way of denoting measurements in the quantum circuit model.
The m is a classical bit denoting the measurement result – either
0 or 1 – and we use the double wire to indicate the classical bit m going off and being used to do something else.
General single-qubit gates
In particular,a general single-qubit gate can be represented as a unitary matrix,U.
The unitary matrix U has to satisfy
among it, is called the complex
transpose of :
for example:
(Note that the † is also sometimes called the dagger operation, or Hermitian conjugation, or just the conjugation operation. We’ll use all three terms on occasion.
Exercise
Can you find an example of a 2×2 matrix that is unitary, and is not I, X, or H?
The Wolfgang Pauli introduced two matrices
,Y and Z, which are also useful quantum gates
it takes to and to
it leaves unchanged,and takes to
Rotation matrix:
It’s just the ordinary rotation of the 2-dimensional plane by an angle θ
What does it mean for a matrix to be unitary?
It turns out that unitary matrices preserve the length of their inputs
in other words,if we take any vector and compute the length it's always equal to the length of the original vector
In a sense, the unitary matrices are a complex generalization of real rotations and reflections.
Prove:
From the normalization perspective,both of them are equal to 1
First,compute
but computing is easier.
Expanding :
so:
(attention:the is a element ,not a matrix)
apply the unitarity of U:
then
final:
That completes the proof that unitary matrices are length-preserving.
Theorem:Let M be a matrix.Then for all vectors if and only if M is unitary.
this tells us why quantum gates must be unitary
Why are unitaries the only matrices which preserve length?
suppose we have a vector :
then in quantum mechanics:
it’s often called the Dirac bra-ket notation, or sometimes just the Dirac notation.
then the smart one have found that:
the we can express the length in another way with the DIirac notation:
We expand it into the matrix:
an other useful identity is that if M is a matrix and is ket, then:
Proof:
The way to prove the identity is to apply the definitions.
We're going to look at the th component of the left - hand side,, and we’ll show it’s equal to the th component of the right - hand side.
By definition, the th row component is equal to the complex conjugate of the th column component of , .
That column component is . We can move the terms to the left, and swap the indices on the term to convert the to a dagger, giving .
That’s just the th component of the row vector , as we set out to show.
unit vector
,means the vector with a 1 in the th component,and 0s everywhere else,for a qubit:
From the elementary linear algebra,if M is a matrix,then is just the th column of M
- is the th entry of M
proof:
is just the th row of M
then is just the th column of the th row of M
Proof:
we assume M is length_preserving,
first,to understand the diagonal elements
because of the length-preserving
moreover:
have a look at th off-diagonal elements
to relate to the length of some vector ,we can consider as ,since that involves both the th and th directions
because we only though j,k directions,which is belongs to [1,n],n is the maximum number of directions
From the length_preserving property we have:
we also have :
then we get:
if we used
through the computation:
up to now,we have the two equation:
so:
Conclusion:
The controlled-NOT gate
To compute,we can't only use one single qubits to interact with one another.
So we find the quantum gates which involve two qubits——controlled-NOT(or CNOT) gate:
- The wire with the small, filled dot on it (the top wire, in this example) is called the control qubit
- The wire with the larger,unfilled circle on it is called the target qubit
In a two-bit system,we have four computational basis states,corresponding to the four possible states:
And we can also have superposition of them:
Similar to the single-qubit,the probability amplitudes are complex numbers,obeying the normalization condition
The controlled-NOT (CNOT) gate, a quantum analog of the classical controlled-NOT logic gate, performs conditional state inversion. Its operation is defined over computational basis states as:
where the first qubit acts as the control and the second as the target. The gate applies the Pauli-X operator to the target qubit iff the control qubit is in the
state, preserving quantum coherence through unitary implementation.
Summing up all four of the equations above in a single equation:
(x,y is 0 or 1)
property:
- act linearly
- unitary
- length-preserving
just as the before
Exercise
- how does it work on three qubits?
answer:
- if we apply a Hadmard gate to the first qubit on the CNOT gate,such as:
finally,the output is:
This output state is a highly non-classical state-it's actually a typo of state called an entangled state
More generally, if we have single-qubit states and , then the combined state when the two qubits are put together is just:
- try to prove if we put ∣+−⟩ in CNOT gates, then ∣−−⟩ comes out
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现