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:

NOT|0=|1NOT|1=|0

when does it apply to a general superposition state which is α|0+β|1

it acts linearly on the quantum state
so:

NOTα|0+β|1=α|1+β|0

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

X=[0110]

in the matrix representation,α|0+β|1 can be considered as the vector[αβ].
Therefore:

X(α|0+β|1)=[0 11 0](α|0+β|1)=[0 11 0][αβ]=[βα]=α|1+β|0

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

  1. 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.

  2. 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.

X(X(α|0+β|1))=X(α|1+β|0)=α|0+β|1

so:

From the matrix perspective

XX is the multi-gate quantum circuit
therefore:

XX=[0 11 0][0 11 0]=[1 00 1]

The Hadamard gate

It clearly involves quantum effects

here's what is does for the quantum basis states:

H|0=|0+|12H|1=|0|12

It also contains the linear property
for the general states:

H(α|0+β|1)=α(|0+|12)+β(|0|12)=α+β2|0+αβ2|1

Like X gate,the circuit representation of H:

the matrix of H:

H=12[1     11 1]

so if H act on the |1:

H|1=12[1111]|1=12[1111][01]=12[11]=|0|12

if H act on the |0,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:

HH=12[1111]12[1111]=[1001]=I

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

  1. Non-Unitary Matrix:
    Quantum gates must be unitary matrices UU=I to ensure probability conservation. Verifying the unitarity of
    J:

JJ=J2=12[2222]I

proving that J is not unitary

  1. Information Loss:
    Applying
    J to the input state |0|12 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 α|0+β|1,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
α0+β1When you measure this qubit in the computational basis it gives you a classical bit of information: it gives you the outcome 0 with probability
α2, and the outcome 1 with probability β2

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 2×2 unitary matrix,U.

The unitary matrix U has to satisfy UU=I

among it,U is called the complex
transpose of U:

U:=(UT)

for example:

[abcd]=[acbd]

(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

Y:=[0ii0]

it takes |0 to i|1 and |1 to i|0

Z:=[1001]

it leaves |0 unchanged,and takes |1 to |1

Rotation matrix:

[cosθsinθsinθcosθ]

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 ||U|ψ|| 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: ||U|ψ||=|||ψ||

From the normalization perspective,both of them are equal to 1

First,compute ||U|ψ||

but computing ||U|ψ||2 is easier.

||U|ψ||2=j|(Uψ)j(Uψ)j|=j(kUjkψk)(lUjlψl)=j,k,lUjkψkUjlψl

Expanding (Uψ)j:

(Uψ)j=kUjkψk

so:

j|(Uψ)j(Uψ)j|=j(kUjkψk)(lUjlψl)=j,k,lUjkψkUjlψl

(attention:the Ujl is a element ,not a matrix)
apply the unitarity of U:

Ujk=Ukj

then

UjkUjl=δkl

δkl={1k=l0kl

j,k,lUjkψkUjlψl=δklψkψl=|ψk|2=||ψ||2

final:

||U|ψ||2=|||ψ||2||U|ψ||=|||ψ||

That completes the proof that unitary matrices are length-preserving.

Theorem:Let M be a matrix.Then ||M|ψ||=|||ψ|| 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 |ψ:

|ψ=[abz]

then in quantum mechanics:

ψ|:=[a b c z]

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:

|||ψ||2=ψ|ψ

We expand it into the matrix:

[a b ][ab]=|a|2+|b|2+=|||ψ||2

an other useful identity is that if M is a matrix and |ψ is ket, then:

(M|ψ)=ψ|M

Proof:
The way to prove the identity is to apply the definitions.

We're going to look at the jth component of the left - hand side,(M|ψ)j, and we’ll show it’s equal to the jth component of the right - hand side.

By definition, the jth row component (M|ψ)j is equal to the complex conjugate of the jth column component of M|ψ, (M|ψ)j.

That column component is kMjkψk. We can move the ψ terms to the left, and swap the indices on the M term to convert the to a dagger, giving kψkMkj.

That’s just the jth component of the row vector ψ|M, as we set out to show.

unit vector

|ej,means the vector with a 1 in the jth component,and 0s everywhere else,for a qubit:

|e0=[10]|e1=[01]

From the elementary linear algebra,if M is a matrix,then M|ek is just the kth column of M

  • ej|M|ek is the jkth entry of M
    proof:
    ej|Mis just the jth row of M
    then ej|M|ekis just the kth column of the jth row of M

Proof:

||M|ψ||=ψ|MM|ψ

we assume M is length_preserving,

first,to understand the diagonal elements

(MM)jj=ej|M|ej=||M|ej||2

because of the length-preserving
||M|ej||2=|||ej||2=1

moreover:
have a look at th off-diagonal elements
(MM)jk,jk

to relate (MM)jk to the length of some vector M|ψ,we can consider |ψ as |ej+|ek,since that involves both the jth and kth 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:

||M|ψ||2=|||ψ||2=12+12=2

we also have :

||M|ψ||2=ψ|MM|ψ=ej|MM|ej+ej|MM|ek+ek|MM|ej+ek|MM|ek=1+ej|MM|ek+ek|MM|ej+1

then we get:

ej|MM|ek+ek|MM|ej=0

if we used |ψ=|ej+i|ek

through the computation:

i(ej|MM|ekek|MM|ej)=0

up to now,we have the two equation:

(MM)jk+(MM)kj=0(MM)jk(MM)kj=0

so:

(MM)jk=(MM)kj=0

Conclusion:

(MM)jk=δjkMM=I

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:|00,|01,|10,|11
And we can also have superposition of them:
α|00+β|01+γ|10+δ|11

Similar to the single-qubit,the probability amplitudes α,β,γ,δare complex numbers,obeying the normalization condition

|α|2+|β|2+|γ|2+|δ|2=1

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:

00,01,11,11

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
1 state, preserving quantum coherence through unitary implementation.

Summing up all four of the equations above in a single equation:

|x,y=|x,xy

(x,y is 0 or 1)

property:

  • act linearly
  • unitary
  • length-preserving
    just as the before

Exercise

  1. how does it work on three qubits?

answer:

x,y,z→∣x,y,zy(x,y,zisthe0or1)

  1. if we apply a Hadmard gate to the first qubit on the CNOT gate,such as:

finally,the output is:

|00+|112

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 α0+β1 and γ0+δ1, then the combined state when the two qubits are put together is just:

(α0+β1)(γ0+δ1=αγ0+αδ01+βγ10+βδ12

  1. try to prove if we put ∣+−⟩ in CNOT gates, then ∣−−⟩ comes out
posted @   归游  阅读(33)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 使用C#创建一个MCP客户端
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示