Toolbox

T1: Basics on Quantum Computing

Reminder: This post contains 3905 words · 12 min read · by Xianbin

If you know matrix theory, it is easy to master quantum computing.

After reading this post, you will know the basic of quantum computing.

0. Why is so?

You will see some strange notations like 0\vert 0\rangle, and not that math operations. The reason is that quantum computing is from physics. Those physicists like to express their ideas easily without showing off their math.

1. Qubit

Quantum particle is in two states simultaneously.

A Qubit is in superposition if it is both in 0\vert 0\rangle and 1\vert 1\rangle where

0=(1;0)\vert 0\rangle = (1; 0) 1=(0;1)\vert 1\rangle = (0;1) ϕ=α0+β1\vert \phi\rangle = \alpha \vert 0 \rangle + \beta \vert 1 \rangle

2. Quantum Collapsing

When we measure a quantum system, it will collapse from superposition (many possibilities) into one measured state.

Just recall the famous thought experiment: Schrödinger’s cat.

3. Probability of measuring

ϕ=α0+β1|\phi\rangle = \alpha \vert 0 \rangle + \beta \vert 1 \rangle

The probability of measuring 0\vert 0\rangle is α2\lvert \alpha \rvert ^2. Note that α\alpha can be a complex number.

4. The Strange Notation

ϕ=α0+β1\vert\phi\rangle = \alpha \vert 0 \rangle + \beta \vert 1 \rangle

We call the RHS Dirac Notation. This is so called ket vectors that represent a quantum state.

Bloch Sphere

ϕ=cosθ2+sinθ2eiϕ1\vert \phi \rangle = cos \frac{\theta}{2} + sin \frac{\theta}{2} e^{i\phi} \vert 1 \rangle

where θ\theta is the angle between the vector and z-axis and ϕ\phi is the angle between the vector and x-axis.

5. Quantum Circuits

X, Y, Z Gates:

X(Y,Z)X (Y, Z) flip the qubit π\pi radians around x(y, z)-axis.

X=(1,0;0,1),Y=(0,i;i,0),Z=(1,0;0,1)X = (1, 0; 0,1), Y = (0 , -i; i , 0), Z = (1, 0; 0, -1)

Hadamard Gates

H=12(1,1;1,1)H = \frac{1}{\sqrt{2}}(1, 1;1, -1)

Apply HH, we have

0+0\vert 0 \rangle \to \vert + \rangle \to \vert 0 \rangle 11\vert 1 \rangle \to \vert -\rangle \to \vert 1\rangle

where +=12(0+1)\vert + \rangle = \frac{1}{\sqrt{2}} (\vert 0 \rangle + \vert 1 \rangle)

=12(01)\vert -\rangle = \frac{1}{\sqrt{2}} (\vert 0 \rangle - \vert 1 \rangle)

CNOT/ Controlled X Gate

CNOT Quantum Circuit:

q0 ───●──── (Control qubit)

q1 ───⊕──── (Target qubit: flips if q0 = 1)

Look at the following relationship:

0000\vert 0 0 \rangle \to \vert 0 0\rangle 0101\vert 0 1 \rangle \to \vert 0 1\rangle 1011\vert 1 0 \rangle \to \vert 1 1\rangle 1110\vert 1 1 \rangle \to \vert 1 0\rangle

6. No-Cloning Theorem

This theorem says that we cannot an exact quantum state.

7. Tensor Product (by ChatGPT)

Tensor product is one of the most important tools in quantum computing. We use tensor product to assemble different quantum systems into one system.

(a;b)(c;d)=(ac;ad;bc;bd).\left( a; b \right) \otimes (c; d) = (ac; ad; bc; bd).

1. Linearity

For vectors (v1,v2,w1,w2) and scalars (a,b)( \mathbf{v}_1, \mathbf{v}_2, \mathbf{w}_1, \mathbf{w}_2 ) \text { and scalars } ( a, b ):

(av1+bv2)w=a(v1w)+b(v2w)(a\mathbf{v}_1 + b\mathbf{v}_2) \otimes \mathbf{w} = a (\mathbf{v}_1 \otimes \mathbf{w}) + b (\mathbf{v}_2 \otimes \mathbf{w}) v(aw1+bw2)=a(vw1)+b(vw2)\mathbf{v} \otimes (a\mathbf{w}_1 + b\mathbf{w}_2) = a (\mathbf{v} \otimes \mathbf{w}_1) + b (\mathbf{v} \otimes \mathbf{w}_2)

2. Associativity

For three vectors (u,v,w)( \mathbf{u}, \mathbf{v}, \mathbf{w} ):

(uv)w=u(vw)(\mathbf{u} \otimes \mathbf{v}) \otimes \mathbf{w} = \mathbf{u} \otimes (\mathbf{v} \otimes \mathbf{w})

This allows us to write the tensor product without parentheses.

3. Distributivity with Kronecker Products

For matrices ( A, B, C, D ):

(AB)(CD)=(AC)(BD)(A \otimes B) (C \otimes D) = (AC) \otimes (BD)

This is useful for composing quantum gates that act on multi-qubit systems.

4. Outer Product and Basis Expansion

If (v=iαiei) and (w=jβjfj)( \mathbf{v} = \sum_i \alpha_i \mathbf{e}_i ) \text{ and } ( \mathbf{w} = \sum_j \beta_j \mathbf{f}_j ), then:

vw=i,jαiβj(eifj)\mathbf{v} \otimes \mathbf{w} = \sum_{i,j} \alpha_i \beta_j (\mathbf{e}_i \otimes \mathbf{f}_j)

This shows how tensor products expand in terms of basis states.

5. Tensor Product of Operators

For two linear operators (A)(A ) and (B)( B ):

(AB)(vw)=(Av)(Bw)(A \otimes B)(\mathbf{v} \otimes \mathbf{w}) = (A\mathbf{v}) \otimes (B\mathbf{w})

which describes how multi-qubit gates act on quantum states.

6. Identity and Swap Property

For the identity matrix II:

IA=AII \otimes A = A \otimes I

Swapping the order of qubits can be expressed as a swap matrix (S)( S ) such that:

S(vw)=(wv)S (\mathbf{v} \otimes \mathbf{w}) = (\mathbf{w} \otimes \mathbf{v})

7. Tensor Product and Entanglement

A state (ψCmCn)( \vert \psi\rangle \in \mathbb{C}^m \otimes \mathbb{C}^n ) is separable if it can be written as

ψ=ψ1ψ2|\psi\rangle = |\psi_1\rangle \otimes |\psi_2\rangle

Otherwise, it is entangled.

References

[1]. Yanofsky, N.S. and Mannucci, M.A., 2008. Quantum computing for computer scientists. Cambridge University Press.