Author @mujirin Verifier - Public
Back to 1 Verify Mark as read Debunk me Download PDF Locked

Chapter 2: Complex Numbers, Vectors, and Inner Products

Grover’s algorithm is a quantum algorithm, but before it is quantum, it is mathematical.

The algorithm works by changing a vector of complex numbers. Some entries of the vector become larger in magnitude, and others become smaller. At the end, measurement turns those magnitudes into probabilities. The famous “amplitude amplification” in Grover’s algorithm is, at the mathematical level, a carefully designed geometric motion in a vector space.

So in this chapter we build the language needed to say those words precisely.

We will study:

  • complex numbers,
  • vectors,
  • vector spaces,
  • basis states,
  • normalization,
  • inner products,
  • orthogonality,
  • and geometric intuition.

These ideas are standard parts of linear algebra, the mathematical language used throughout quantum computing (Strang, 2016; Nielsen and Chuang, 2010). We will introduce them slowly from first principles.


2.1 Why complex numbers appear in quantum computing

In ordinary probability, we often describe uncertainty using real numbers between \(0\) and \(1\).

For example, if a fair coin is tossed, we say

\[ P(\text{heads}) = \frac{1}{2}, \qquad P(\text{tails}) = \frac{1}{2}. \]

Quantum computing does something different. Instead of assigning probabilities directly to possible outcomes, it assigns amplitudes.

An amplitude is a number that can be positive, negative, or complex. Probabilities are later obtained from amplitudes by taking squared magnitudes. This use of complex amplitudes is part of the standard mathematical formulation of quantum mechanics and quantum computation (Nielsen and Chuang, 2010).

For now, the important idea is:

Quantum algorithms manipulate amplitudes before measurement turns them into probabilities.

This is one reason quantum algorithms can behave differently from classical randomized algorithms. Amplitudes can interfere. They can reinforce one another or cancel one another.

To understand this, we first need to understand complex numbers.


2.2 Complex numbers

A complex number is a number of the form

\[ z = a + bi, \]

where \(a\) and \(b\) are real numbers, and \(i\) is defined by

\[ i^2 = -1. \]

The number \(a\) is called the real part of \(z\). The number \(b\) is called the imaginary part of \(z\).

We write

\[ \operatorname{Re}(z) = a, \qquad \operatorname{Im}(z) = b. \]

For example,

\[ z = 3 + 2i \]

has real part \(3\) and imaginary part \(2\).

Another example is

\[ w = -5 - 7i. \]

Here,

\[ \operatorname{Re}(w) = -5, \qquad \operatorname{Im}(w) = -7. \]

A real number is also a complex number. For example,

\[ 4 = 4 + 0i. \]

So the complex numbers include the real numbers, but they also include numbers with an \(i\)-part.


2.3 Adding and multiplying complex numbers

Complex numbers add by adding their real parts and imaginary parts separately.

If

\[ z = a + bi \]

and

\[ w = c + di, \]

then

\[ z + w = (a+c) + (b+d)i. \]

For example,

\[ (3+2i) + (5-6i) = 8 - 4i. \]

Multiplication uses the rule \(i^2=-1\).

For example,

\[ (3+2i)(5-6i) \]

expands as

\[ 3\cdot 5 + 3(-6i) + 2i\cdot 5 + 2i(-6i). \]

So

\[ (3+2i)(5-6i) = 15 - 18i + 10i - 12i^2. \]

Because \(i^2=-1\),

\[ -12i^2 = -12(-1)=12. \]

Therefore,

\[ (3+2i)(5-6i) = 27 - 8i. \]

Complex arithmetic is ordinary algebra plus the special rule \(i^2=-1\).


2.4 Complex conjugates

The complex conjugate of

\[ z = a + bi \]

is

\[ \overline{z} = a - bi. \]

The conjugate keeps the real part the same and flips the sign of the imaginary part.

For example,

\[ \overline{3+2i} = 3-2i, \]

and

\[ \overline{-4-7i} = -4+7i. \]

Conjugates are important because multiplying a complex number by its conjugate gives a nonnegative real number:

\[ z\overline{z} = (a+bi)(a-bi). \]

Expanding,

\[ (a+bi)(a-bi) = a^2 - abi + abi - b^2 i^2. \]

The middle terms cancel:

\[ -abi + abi = 0. \]

Since \(i^2=-1\),

\[ -b^2i^2 = b^2. \]

So

\[ z\overline{z} = a^2 + b^2. \]

This number is always real and never negative.

For example, if

\[ z = 3 + 4i, \]

then

\[ z\overline{z} = (3+4i)(3-4i) = 3^2 + 4^2 = 25. \]

This leads to the idea of magnitude.


2.5 Magnitude and squared magnitude

The magnitude of a complex number \(z=a+bi\) is

\[ |z| = \sqrt{a^2+b^2}. \]

The squared magnitude is

\[ |z|^2 = a^2+b^2. \]

Because

\[ z\overline{z}=a^2+b^2, \]

we can also write

\[ |z|^2 = z\overline{z}. \]

For example, if

\[ z = 3+4i, \]

then

\[ |z| = \sqrt{3^2+4^2} = 5, \]

and

\[ |z|^2 = 25. \]

In quantum computing, squared magnitudes will become probabilities. If an outcome has amplitude \(\alpha\), then the probability of that outcome, when measured in the appropriate basis, is

\[ |\alpha|^2. \]

We will study measurement carefully in Chapter 4. For now, remember:

Amplitudes can be complex, but probabilities are real nonnegative numbers.

That is why squared magnitude matters.


2.6 Complex numbers as points in a plane

A complex number

\[ z = a + bi \]

can be drawn as a point in a plane.

The horizontal coordinate is \(a\), the real part.

The vertical coordinate is \(b\), the imaginary part.

So

\[ 3+2i \]

is drawn as the point \((3,2)\).

This plane is called the complex plane.

The magnitude \(|z|\) is the distance from the origin to the point \(z\). For example, \(3+4i\) is at point \((3,4)\), and its distance from the origin is \(5\).

This geometric picture will be useful later. Quantum states are not just lists of numbers; they can be understood as arrows, directions, and rotations in a complex vector space.

Grover’s algorithm is especially geometric: it repeatedly rotates a quantum state toward the direction representing correct answers.


2.7 Phase: the angle of a complex number

Besides magnitude, a nonzero complex number also has an angle in the complex plane.

For example,

\[ 1 \]

points along the positive real axis.

The number

\[ i \]

points straight upward.

The number

\[ -1 \]

points along the negative real axis.

The number

\[ -i \]

points downward.

This angle is called the phase.

A complex number can often be understood as having:

  1. a magnitude, meaning “how long,” and
  2. a phase, meaning “which direction in the complex plane.”

For example,

\[ -1 \]

has magnitude \(1\), but it has phase \(\pi\) radians relative to \(1\). Multiplying by \(-1\) flips the direction by \(180^\circ\).

This matters because Grover’s oracle will mark correct answers by changing their phase. In particular, a common version of Grover’s oracle multiplies the amplitude of each correct answer by \(-1\). That operation does not change the squared magnitude immediately, but it changes the phase, which later affects interference.

So phase is not a decorative detail. It is one of the main tools quantum algorithms use.


2.8 Vectors

A vector is an ordered list of numbers.

For example,

\[ \begin{bmatrix} 2 \\ 5 \end{bmatrix} \]

is a vector with two entries.

Another example is

\[ \begin{bmatrix} 1 \\ -3 \\ 4 \end{bmatrix}, \]

which has three entries.

In quantum computing, the entries of vectors are usually complex numbers. For example,

\[ \begin{bmatrix} 1+i \\ 2-i \end{bmatrix} \]

is a vector with complex entries.

The numbers inside a vector are called its components or coordinates. In quantum computing, when a vector represents a quantum state, its components are called amplitudes.

For example, in the vector

\[ \begin{bmatrix} \alpha \\ \beta \end{bmatrix}, \]

the numbers \(\alpha\) and \(\beta\) could be amplitudes.

At this stage, do not worry yet about what physical system the vector represents. First, learn the vector language.


2.9 Vector addition

Vectors of the same size can be added component by component.

For example,

\[ \begin{bmatrix} 2 \\ 5 \end{bmatrix} + \begin{bmatrix} 7 \\ -1 \end{bmatrix} = \begin{bmatrix} 9 \\ 4 \end{bmatrix}. \]

With complex entries,

\[ \begin{bmatrix} 1+i \\ 2 \end{bmatrix} + \begin{bmatrix} 3-i \\ 4i \end{bmatrix} = \begin{bmatrix} 4 \\ 2+4i \end{bmatrix}. \]

Vector addition is one of the basic operations that makes vectors useful. It lets us combine directions.


2.10 Scalar multiplication

A scalar is a single number used to multiply a vector.

For example, if

\[ v = \begin{bmatrix} 2 \\ 5 \end{bmatrix}, \]

then

\[ 3v = 3 \begin{bmatrix} 2 \\ 5 \end{bmatrix} = \begin{bmatrix} 6 \\ 15 \end{bmatrix}. \]

With a complex scalar,

\[ i \begin{bmatrix} 2 \\ 5 \end{bmatrix} = \begin{bmatrix} 2i \\ 5i \end{bmatrix}. \]

Scalar multiplication changes the length and possibly the phase of a vector.

For example,

\[ -1 \begin{bmatrix} 2 \\ 5 \end{bmatrix} = \begin{bmatrix} -2 \\ -5 \end{bmatrix}. \]

This points in the opposite direction.

Multiplication by \(i\) is different: it rotates each complex component by \(90^\circ\) in the complex plane.


2.11 Vector spaces

A vector space is a collection of vectors where vector addition and scalar multiplication behave in a consistent way.

For this book, the main vector spaces are:

\[ \mathbb{C}^2,\ \mathbb{C}^4,\ \mathbb{C}^8,\ \ldots,\ \mathbb{C}^{2^n}. \]

The symbol \(\mathbb{C}\) means the set of complex numbers.

So \(\mathbb{C}^2\) is the set of all two-component complex vectors:

\[ \begin{bmatrix} \alpha \\ \beta \end{bmatrix}, \]

where \(\alpha,\beta \in \mathbb{C}\).

Similarly, \(\mathbb{C}^4\) is the set of all four-component complex vectors:

\[ \begin{bmatrix} \alpha_0 \\ \alpha_1 \\ \alpha_2 \\ \alpha_3 \end{bmatrix}. \]

Quantum computing uses these spaces because a system of \(n\) qubits has \(2^n\) computational basis states, so its state vector lives in a \(2^n\)-dimensional complex vector space (Nielsen and Chuang, 2010).

For example:

  • \(1\) qubit uses \(\mathbb{C}^2\),
  • \(2\) qubits use \(\mathbb{C}^4\),
  • \(3\) qubits use \(\mathbb{C}^8\),
  • \(n\) qubits use \(\mathbb{C}^{2^n}\).

This exponential growth is one reason quantum systems are mathematically rich. But it also means we must be careful: a vector with \(2^n\) complex amplitudes is not the same thing as \(2^n\) freely readable classical pieces of information. Measurement limits what can be extracted, as we will see in Chapter 4.


2.12 Basis vectors

A basis is a set of basic vectors from which every vector in a space can be built uniquely.

Let us start with \(\mathbb{C}^2\).

The standard basis vectors are

\[ e_0 = \begin{bmatrix} 1 \\ 0 \end{bmatrix}, \qquad e_1 = \begin{bmatrix} 0 \\ 1 \end{bmatrix}. \]

Every vector in \(\mathbb{C}^2\) can be written as a combination of these two basis vectors.

For example,

\[ \begin{bmatrix} 3 \\ 5 \end{bmatrix} = 3 \begin{bmatrix} 1 \\ 0 \end{bmatrix} + 5 \begin{bmatrix} 0 \\ 1 \end{bmatrix}. \]

That is,

\[ \begin{bmatrix} 3 \\ 5 \end{bmatrix} = 3e_0 + 5e_1. \]

With complex entries,

\[ \begin{bmatrix} 1+i \\ 2-i \end{bmatrix} = (1+i)e_0 + (2-i)e_1. \]

The coefficients tell us how much of each basis vector is present.

In quantum computing, basis vectors often correspond to classical labels. For one qubit, the two standard basis states are written as

\[ |0\rangle \quad \text{and} \quad |1\rangle. \]

These correspond to

\[ |0\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix}, \qquad |1\rangle = \begin{bmatrix} 0 \\ 1 \end{bmatrix}. \]

The notation \(|0\rangle\) is called ket notation or Dirac notation. It is standard in quantum mechanics and quantum information (Nielsen and Chuang, 2010).

So instead of writing

\[ \begin{bmatrix} \alpha \\ \beta \end{bmatrix}, \]

we may write

\[ \alpha|0\rangle + \beta|1\rangle. \]

These mean the same vector, just in different notation.


2.13 Basis states for more than one qubit

For two qubits, there are four computational basis states:

\[ |00\rangle,\ |01\rangle,\ |10\rangle,\ |11\rangle. \]

These correspond to the four standard basis vectors in \(\mathbb{C}^4\):

\[ |00\rangle = \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix}, \quad |01\rangle = \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix}, \quad |10\rangle = \begin{bmatrix} 0 \\ 0 \\ 1 \\ 0 \end{bmatrix}, \quad |11\rangle = \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix}. \]

A general two-qubit vector can be written as

\[ \alpha_{00}|00\rangle + \alpha_{01}|01\rangle + \alpha_{10}|10\rangle + \alpha_{11}|11\rangle. \]

Equivalently, as a column vector,

\[ \begin{bmatrix} \alpha_{00} \\ \alpha_{01} \\ \alpha_{10} \\ \alpha_{11} \end{bmatrix}. \]

The amplitudes are indexed by the basis labels.

For three qubits, the basis states are

\[ |000\rangle,\ |001\rangle,\ |010\rangle,\ |011\rangle,\ |100\rangle,\ |101\rangle,\ |110\rangle,\ |111\rangle. \]

There are \(8 = 2^3\) of them.

In general, for \(n\) qubits, the computational basis states are labeled by all binary strings of length \(n\). There are

\[ 2^n \]

such strings.

This is why Grover’s algorithm naturally fits search spaces of size

\[ N = 2^n. \]

If there are \(n\) qubits, we can label \(N\) candidate answers by basis states.


2.14 Linear combinations and superposition

A linear combination is a sum of scalar multiples of vectors.

For example,

\[ 3|0\rangle + 5|1\rangle \]

is a linear combination of \(|0\rangle\) and \(|1\rangle\).

Another example is

\[ \frac{1}{2}|00\rangle + \frac{1}{2}|01\rangle + \frac{1}{2}|10\rangle + \frac{1}{2}|11\rangle. \]

This is a linear combination of four basis states.

In quantum computing, a linear combination of basis states is called a superposition.

For example,

\[ \frac{1}{\sqrt{2}}|0\rangle + \frac{1}{\sqrt{2}}|1\rangle \]

is a superposition of \(|0\rangle\) and \(|1\rangle\).

It is important not to misunderstand this. A superposition does not mean the computer secretly contains both classical answers in a directly readable way. It means the quantum state is represented by a vector with amplitudes on multiple basis states. What we can read out is governed by measurement probabilities.

Still, superposition is essential. Grover’s algorithm begins by placing amplitude evenly over all candidate answers.

For a search space of size \(N\), the uniform superposition is

\[ |s\rangle = \frac{1}{\sqrt{N}} \sum_{x=0}^{N-1}|x\rangle. \]

This means every candidate basis state \(|x\rangle\) has the same amplitude:

\[ \frac{1}{\sqrt{N}}. \]

For example, if \(N=4\), then

\[ |s\rangle = \frac{1}{2}|0\rangle + \frac{1}{2}|1\rangle + \frac{1}{2}|2\rangle + \frac{1}{2}|3\rangle. \]

If the labels are two-bit strings, this is

\[ |s\rangle = \frac{1}{2}|00\rangle + \frac{1}{2}|01\rangle + \frac{1}{2}|10\rangle + \frac{1}{2}|11\rangle. \]

Later, Grover’s algorithm will repeatedly modify this vector so that marked answers receive larger amplitudes.


2.15 Length of a vector

The length or norm of a vector measures how large the vector is.

For a real two-dimensional vector

\[ v = \begin{bmatrix} 3 \\ 4 \end{bmatrix}, \]

the length is

\[ \|v\| = \sqrt{3^2+4^2}=5. \]

For a complex vector

\[ v = \begin{bmatrix} \alpha_0 \\ \alpha_1 \\ \vdots \\ \alpha_{N-1} \end{bmatrix}, \]

the standard norm is

\[ \|v\| = \sqrt{ |\alpha_0|^2 + |\alpha_1|^2 + \cdots + |\alpha_{N-1}|^2 }. \]

The squared norm is

\[ \|v\|^2 = |\alpha_0|^2 + |\alpha_1|^2 + \cdots + |\alpha_{N-1}|^2. \]

For example, consider

\[ v = \begin{bmatrix} 1+i \\ 2 \end{bmatrix}. \]

The squared magnitude of \(1+i\) is

\[ |1+i|^2 = 1^2+1^2=2. \]

The squared magnitude of \(2\) is

\[ |2|^2=4. \]

So

\[ \|v\|^2=2+4=6, \]

and

\[ \|v\|=\sqrt{6}. \]


2.16 Normalization

A vector is normalized if its norm is \(1\).

That means

\[ \|v\|=1. \]

Quantum state vectors are normalized, because the total probability over all measurement outcomes must add to \(1\) (Nielsen and Chuang, 2010).

For example,

\[ \frac{1}{\sqrt{2}}|0\rangle + \frac{1}{\sqrt{2}}|1\rangle \]

is normalized because

\[ \left|\frac{1}{\sqrt{2}}\right|^2 + \left|\frac{1}{\sqrt{2}}\right|^2 = \frac{1}{2}+\frac{1}{2} = 1. \]

The vector

\[ |0\rangle + |1\rangle \]

is not normalized, because

\[ |1|^2+|1|^2=2. \]

Its norm is

\[ \sqrt{2}. \]

To normalize it, divide by its norm:

\[ \frac{|0\rangle+|1\rangle}{\sqrt{2}} = \frac{1}{\sqrt{2}}|0\rangle + \frac{1}{\sqrt{2}}|1\rangle. \]

This is one of the most common normalized quantum states.

Now check the uniform superposition:

\[ |s\rangle = \frac{1}{\sqrt{N}} \sum_{x=0}^{N-1}|x\rangle. \]

There are \(N\) amplitudes, each equal to \(1/\sqrt{N}\). Therefore,

\[ \|s\|^2 = N\left|\frac{1}{\sqrt{N}}\right|^2 = N\cdot \frac{1}{N} = 1. \]

So \(|s\rangle\) is normalized.

This is why the coefficient is \(1/\sqrt{N}\), not \(1/N\).

If we used \(1/N\), then the squared norm would be

\[ N\left(\frac{1}{N}\right)^2 = \frac{1}{N}, \]

which is not \(1\) unless \(N=1\).


2.17 Inner products

The inner product is a way to compare two vectors.

It tells us how much two vectors point in the same direction. It also gives us a way to define length and orthogonality.

For complex vectors, the standard inner product is

\[ \langle u, v\rangle = \overline{u_0}v_0 + \overline{u_1}v_1 + \cdots + \overline{u_{N-1}}v_{N-1}. \]

In Dirac notation, this is written as

\[ \langle u|v\rangle. \]

The conjugate appears on the components of the first vector. This is necessary so that

\[ \langle v|v\rangle \]

is always real and nonnegative.

Indeed,

\[ \langle v|v\rangle = |\alpha_0|^2 + |\alpha_1|^2 + \cdots + |\alpha_{N-1}|^2 = \|v\|^2. \]

So the norm can be defined from the inner product:

\[ \|v\| = \sqrt{\langle v|v\rangle}. \]

This is the standard inner product structure used in finite-dimensional quantum computation (Nielsen and Chuang, 2010).


2.18 Example: computing an inner product

Let

\[ u = \begin{bmatrix} 1 \\ i \end{bmatrix} \]

and

\[ v = \begin{bmatrix} 2 \\ 3i \end{bmatrix}. \]

Then

\[ \langle u|v\rangle = \overline{1}\cdot 2 + \overline{i}\cdot 3i. \]

Now,

\[ \overline{1}=1, \qquad \overline{i}=-i. \]

So

\[ \langle u|v\rangle = 1\cdot 2 + (-i)(3i). \]

That gives

\[ \langle u|v\rangle = 2 - 3i^2. \]

Since \(i^2=-1\),

\[ -3i^2=3. \]

Therefore,

\[ \langle u|v\rangle=5. \]

Now reverse the order:

\[ \langle v|u\rangle = \overline{2}\cdot 1 + \overline{3i}\cdot i. \]

Since

\[ \overline{2}=2, \qquad \overline{3i}=-3i, \]

we get

\[ \langle v|u\rangle = 2 + (-3i)i = 2 - 3i^2 = 5. \]

In this example the result is the same. But in general,

\[ \langle v|u\rangle = \overline{\langle u|v\rangle}. \]

That is, reversing the order gives the complex conjugate.


2.19 Orthogonality

Two vectors are orthogonal if their inner product is zero.

That is,

\[ \langle u|v\rangle=0. \]

Geometrically, for real vectors, orthogonal means perpendicular. In complex vector spaces, the geometry is more abstract, but the inner product still plays the same role: it tells us whether two directions are independent in the strongest possible angle-like sense.

For example,

\[ |0\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix}, \qquad |1\rangle = \begin{bmatrix} 0 \\ 1 \end{bmatrix}. \]

Their inner product is

\[ \langle 0|1\rangle = 1\cdot 0 + 0\cdot 1 = 0. \]

So \(|0\rangle\) and \(|1\rangle\) are orthogonal.

Now consider

\[ u= \begin{bmatrix} 1 \\ i \end{bmatrix}, \qquad v= \begin{bmatrix} 1 \\ -i \end{bmatrix}. \]

Then

\[ \langle u|v\rangle = \overline{1}\cdot 1 + \overline{i}\cdot (-i). \]

Since \(\overline{i}=-i\),

\[ \langle u|v\rangle = 1 + (-i)(-i). \]

Now

\[ (-i)(-i)=i^2=-1. \]

So

\[ \langle u|v\rangle=1-1=0. \]

Therefore, these two complex vectors are orthogonal.

Orthogonality is important in quantum computing because computational basis states are mutually orthogonal. Distinct classical labels such as \(|00\rangle\) and \(|11\rangle\) correspond to orthogonal directions.


2.20 Orthonormal bases

A set of vectors is orthonormal if:

  1. each vector has norm \(1\), and
  2. different vectors in the set are orthogonal.

The word combines:

  • ortho, meaning orthogonal,
  • normal, meaning normalized.

The computational basis is orthonormal.

For one qubit,

\[ |0\rangle,\ |1\rangle \]

are orthonormal because

\[ \langle 0|0\rangle=1, \qquad \langle 1|1\rangle=1, \]

and

\[ \langle 0|1\rangle=0. \]

For two qubits,

\[ |00\rangle,\ |01\rangle,\ |10\rangle,\ |11\rangle \]

form an orthonormal basis.

This means every two-qubit state can be written uniquely as

\[ \alpha_{00}|00\rangle + \alpha_{01}|01\rangle + \alpha_{10}|10\rangle + \alpha_{11}|11\rangle. \]

The amplitudes are exactly the coordinates of the vector in that basis.


2.21 The \(|+\rangle\) and \(|-\rangle\) states

There are many possible orthonormal bases.

For one qubit, another important pair of states is

\[ |+\rangle = \frac{1}{\sqrt{2}}(|0\rangle+|1\rangle), \]

and

\[ |-\rangle = \frac{1}{\sqrt{2}}(|0\rangle-|1\rangle). \]

Let us check that they are normalized.

For \(|+\rangle\), the amplitudes are

\[ \frac{1}{\sqrt{2}}, \qquad \frac{1}{\sqrt{2}}. \]

So

\[ \langle +|+\rangle = \frac{1}{2}+\frac{1}{2}=1. \]

For \(|-\rangle\), the amplitudes are

\[ \frac{1}{\sqrt{2}}, \qquad -\frac{1}{\sqrt{2}}. \]

So

\[ \langle -|-\rangle = \frac{1}{2}+\frac{1}{2}=1. \]

Now check orthogonality:

\[ \langle +|-\rangle = \frac{1}{\sqrt{2}}\frac{1}{\sqrt{2}} + \frac{1}{\sqrt{2}}\left(-\frac{1}{\sqrt{2}}\right). \]

Thus,

\[ \langle +|-\rangle = \frac{1}{2}-\frac{1}{2}=0. \]

So \(|+\rangle\) and \(|-\rangle\) form another orthonormal basis for \(\mathbb{C}^2\).

These states will return later when we study the Hadamard gate. The Hadamard gate creates equal superpositions, and it is one of the basic tools used to prepare Grover’s starting state.


2.22 Dirac notation: kets and bras

Quantum computing often uses Dirac notation because it makes long vector expressions easier to read.

A column vector is written as a ket:

\[ |v\rangle. \]

For example,

\[ |v\rangle = \begin{bmatrix} \alpha \\ \beta \end{bmatrix}. \]

The corresponding bra is the conjugate transpose:

\[ \langle v| = \begin{bmatrix} \overline{\alpha} & \overline{\beta} \end{bmatrix}. \]

The word “transpose” means turning a column into a row. The word “conjugate” means replacing each component by its complex conjugate.

So if

\[ |v\rangle = \begin{bmatrix} 1+i \\ 2-i \end{bmatrix}, \]

then

\[ \langle v| = \begin{bmatrix} 1-i & 2+i \end{bmatrix}. \]

The inner product of \(|u\rangle\) and \(|v\rangle\) is written as

\[ \langle u|v\rangle. \]

This means:

\[ \text{bra } u \quad \text{times} \quad \text{ket } v. \]

For example, if

\[ |u\rangle = \begin{bmatrix} 1 \\ i \end{bmatrix}, \qquad |v\rangle = \begin{bmatrix} 2 \\ 3i \end{bmatrix}, \]

then

\[ \langle u| = \begin{bmatrix} 1 & -i \end{bmatrix}, \]

so

\[ \langle u|v\rangle = \begin{bmatrix} 1 & -i \end{bmatrix} \begin{bmatrix} 2 \\ 3i \end{bmatrix} = 2 + (-i)(3i) = 5. \]

Dirac notation may look unusual at first, but it is compact and powerful. We will use it throughout the book.


2.23 Projection: “how much points in this direction?”

The inner product can measure how much one vector points in the direction of another.

Suppose \(|b\rangle\) is a normalized vector. Then the number

\[ \langle b|v\rangle \]

is the component of \(|v\rangle\) in the direction \(|b\rangle\).

For example, let

\[ |v\rangle = \frac{3}{5}|0\rangle + \frac{4}{5}|1\rangle. \]

Then

\[ \langle 0|v\rangle = \frac{3}{5}, \]

and

[ \l

τ TheoryTrace