Chuyển đến nội dung

Bài 5 · Qubits and Superposition

The Qubit and Its State Vector

Learn how a qubit is described by two complex amplitudes, the computational and other bases, normalization, and how to build and inspect qubit states in Python.

A classical bit is a switch: 0 or 1. A qubit is described by two complex numbers, called amplitudes, that say how much "0-ness" and how much "1-ness" the qubit has. This lesson turns that sentence into code: you will build qubit states, check that they are valid, and learn the standard states every quantum programmer recognizes on sight.

The state vector of one qubit

The state of a qubit is

|psi> = alpha |0> + beta |1>

where alpha and beta are complex numbers with |alpha|^2 + |beta|^2 = 1. As a vector this is [alpha, beta]. The states |0> and |1> are the computational basis: [1, 0] and [0, 1]. Any other state with both amplitudes non-zero is a superposition of them.

The amplitudes are not probabilities. They carry both a size and a phase. The squared sizes, |alpha|^2 and |beta|^2, will be the probabilities of reading 0 and 1 when you measure (see Measurement and the Born Rule).

Python Build qubit states and check them

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Famous states

A few states appear in almost every circuit. Learn their names and amplitudes:

State Vector Description
|0> [1, 0] Definitely 0
|1> [0, 1] Definitely 1
|+> [1, 1] / sqrt(2) Equal mix, same sign
|-> [1, -1] / sqrt(2) Equal mix, opposite sign
|i> [1, i] / sqrt(2) Equal mix, quarter-turn phase
|-i> [1, -i] / sqrt(2) Equal mix, opposite quarter turn

The pairs {|0>, |1>}, {|+>, |->} and {|i>, |-i>} are three different bases. Within each pair, the two states are orthogonal. Each basis answers a different "question" about the qubit: the first asks "is it 0 or 1?", the second asks "is the phase positive or negative?", the third asks about the quarter-turn phase. They are called the Z, X and Y bases after the Pauli matrices that have these states as eigenvectors.

Python The six standard states

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that |+>, |->, |i> and |-i> all give a fifty-fifty result when measured in the 0/1 basis, even though they are four different states. The differences live entirely in phases, which the 0/1 measurement cannot see directly. This is why interference experiments need extra gates before measuring.

Basis changes

A basis is a set of orthogonal, normalized vectors that can build any state. Writing a state in a different basis is like changing coordinates. For example,

|0> = (|+> + |->) / sqrt(2).

The state |0> is certain in the Z basis and a fifty-fifty mix in the X basis. To find the coefficient on a basis vector b, take the inner product <b|psi>. Quantum programs use this constantly: "rotate into a convenient basis, then measure".

Python Expanding a state in another basis

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Global phase again

The states [alpha, beta] and e^(i*t) * [alpha, beta] are physically identical. If you want a unique representation, you may choose the first amplitude to be real and non-negative. A general qubit then needs just two real numbers: one for how the weight splits between 0 and 1, and one for the relative phase. The next lesson, The Bloch Sphere, turns those two numbers into angles on a sphere, a picture that makes qubit behavior much easier to reason about.

Qubit versus bit versus probabilistic bit

A probabilistic bit (a coin) is also described by two numbers, but those are non-negative probabilities that add to 1. A qubit differs in two ways:

  • Its numbers are complex amplitudes and can be negative, so they can cancel (interference).
  • Its description has a phase, so many different qubit states give the same 0/1 probabilities.

A coin is flipped into a state [0.5, 0.5] and stays randomly 50/50 forever. A qubit in |+> is not "random": applying a gate can steer it deterministically to 0, which no coin allows.

Do not read "qubit is in a superposition" as "we do not know which value it has". A qubit in |+> has no hidden 0 or 1. Its state is perfectly known: it is |+>.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. Which pair of amplitudes is a valid qubit state?

    0.6^2 + 0.8^2 = 1. The others have squared sizes that sum to 2, 0.5 and 4.
  2. 2. What is the measurement probability of 0 for the state |-> = [1, -1]/sqrt(2) in the 0/1 basis?

    |1/sqrt(2)|^2 = 1/2. The minus sign is a phase and does not change the probability.
  3. 3. Which pair is orthogonal?

    <+|-> = (1 - 1)/2 = 0. The other pairs have non-zero overlap.
  4. 4. Why do |+> and |-> behave differently if they have the same measurement probabilities in the 0/1 basis?

    Relative phase is invisible to a 0/1 measurement but affects interference after other gates.

Summary

  • A qubit state is alpha|0> + beta|1> with |alpha|^2 + |beta|^2 = 1.
  • |+>, |->, |i>, |-i> are equal mixes that differ in phase.
  • A basis is a set of orthogonal states; the Z, X and Y bases are the standard three.
  • Coefficients in a new basis are inner products.
  • Global phase is irrelevant; relative phase is not.

Next: The Bloch Sphere

Theo dõi tiến độ của bạn

Tạo tài khoản miễn phí để đánh dấu bài đã học và tiếp tục từ chỗ bạn dừng lại trên mọi thiết bị.