smartyfy.mrindigi.com

Quantum Computing Master Course — 007. Lengths and Normalization

Lesson 007: Lengths and Normalization

Smartyfy Quantum Computing Master Course

Prerequisites and objectives

You have encountered normalization when writing qubit states. This lesson makes the rule systematic for real and complex vectors. You will calculate norms, normalize nonzero vectors, understand scaling by a complex number, and diagnose several common normalization errors. You should know vector coordinates and complex conjugation from Lessons 003–006.

Length beyond a drawing

For a real vector [x, y], its Euclidean norm is √(x² + y²). We write this as ||v||, using double vertical bars to distinguish a vector norm from an individual number’s magnitude. The formula agrees with the length of a displacement in the ordinary plane, but it also applies when the coordinates represent abstract information rather than spatial position.

The squared norm is ||v||² = x² + y². Keeping the square root until the last step often makes arithmetic simpler. For v = [5, 12], the squared norm is 25 + 144 = 169, so the norm is thirteen. Reversing either sign leaves the length unchanged because squaring removes the sign.

For a complex vector [z0, z1], the appropriate rule is ||v||² = |z0|² + |z1|². Each term uses complex squared magnitude. For any finite number of coordinates, add the squared magnitudes of all entries and take the square root. This norm is real and nonnegative, and it is zero only for the zero vector.

Worked example with complex coordinates

Take v = [1 + i, 2i]. The first entry has squared magnitude 1² + 1² = 2. The second has squared magnitude four. Therefore ||v||² = 6 and ||v|| = √6. Squaring the entries without magnitudes would instead give (1 + i)² + (2i)² = 2i − 4, which cannot serve as a vector length.

To normalize v, divide every coordinate by √6. The result is w = [(1 + i)/√6, 2i/√6]. Its squared norm is 2/6 + 4/6 = 1. If interpreted as a pure qubit in the computational basis, its probabilities are one third and two thirds. Normalization has preserved the ratio of the amplitudes, while choosing a representative with unit norm.

The general recipe is v divided by ||v||, provided v is nonzero. It is worth checking the answer independently: calculate the squared norm of the resulting vector. A small numerical rounding error is expected in floating-point arithmetic; a large discrepancy usually signals a wrong denominator or an omitted coordinate.

The complex vector[1+i,2i] has squared coordinate magnitudes2 and4, giving squared norm6 and norm square root6. Both coordinates are divided by square root6. The resulting vector has squared norm2/6+4/6=1; dividing by6 instead would give squared norm1/6.
Sum squared magnitudes, take the square root, then divide every coordinate by that norm. In the computational basis, this normalized example gives probabilities 1/3 and 2/3. Open full-size diagram

Scaling and phase

For a complex scalar c, the norm satisfies ||cv|| = |c| ||v||. This follows because every squared magnitude is multiplied by |c|². Multiplying all entries by three triples the norm. Multiplying by negative three also triples the norm, because length cannot become negative.

Multiplying by i preserves the norm because |i| = 1. More generally, any common unit-magnitude phase factor preserves it. The quantum-state framework identifies normalized vectors differing only by such a global phase as the same pure physical state. Normalization alone does not choose a unique global phase.

For instance, [1, i]/√2 and [i, −1]/√2 both have unit norm and differ by multiplication by i. Their ordinary coordinate lists are different, but their physical pure-state predictions agree. By contrast, multiplying only the second coordinate by i can change relative phase. The norm remains one, yet the physical state need not remain the same.

Probability normalization is a different rule

A classical probability vector is normalized by adding its entries, not their squares. For p = [1/4, 3/4], the entries sum to one, while its squared Euclidean norm is 1/16 + 9/16 = 5/8. This is a valid probability vector even though its Euclidean length is not one.

A quantum amplitude vector uses squared magnitudes because those quantities become probabilities. The vector [1/2, 1/2] has entries summing to one but squared norm one half. As an amplitude vector it needs normalization, giving [1/√2, 1/√2]. Its probability vector is then [1/2, 1/2]. The same printed numbers can therefore play different roles in different models.

When debugging a calculation, label each list as amplitudes, probabilities, or unnormalized intermediate values. Avoid a generic variable name such as values if it encourages these interpretations to blur together. A normalization function should also make its intended input explicit.

What normalization cannot repair

The zero vector cannot be rescaled to unit length: every scalar multiple is still zero. A program should reject it clearly. Nearly zero inputs also deserve numerical care because division by a tiny norm can magnify errors already present in the data. The small exact examples in this lesson avoid that difficulty.

Renormalization can correct a small accumulated numerical drift in a simulation, but it should not conceal a substantial error in a supposedly norm-preserving gate. Record the norm before any repair. If a transformation repeatedly changes it by a large amount, inspect the mathematics or implementation instead of automatically dividing the problem away.

Finally, normalizing arbitrary vectors is a nonlinear map in general. A physical preparation or conditional measurement may involve normalized states, but this arithmetic step does not by itself describe a deterministic operation that can be applied to every unknown quantum state. Keep the mathematical representation separate from its implementation.

Local norm check

This standard-library calculation reproduces the complex worked example and checks a scaling identity. It computes model values only; it neither samples measurement outcomes nor estimates hardware noise. The tolerance is for rounding, not an allowance to change the physical normalization rule.

from math import sqrt, isclose

def norm(vector):
    return sqrt(sum(abs(z) ** 2 for z in vector))

def normalized(vector):
    length = norm(vector)
    if length == 0:
        raise ValueError("Cannot normalize the zero vector")
    return [z / length for z in vector]

v = [1+1j, 2j]
w = normalized(v)
print("squared norm:", round(norm(v) ** 2, 10))
print("probabilities:", [round(abs(z) ** 2, 10) for z in w])
print("normalized length:", round(norm(w), 10))
assert isclose(norm(v) ** 2, 6.0, abs_tol=1e-12)
assert isclose(abs(w[0]) ** 2, 1/3, abs_tol=1e-12)
assert isclose(norm([3*z for z in v]), 3*norm(v), abs_tol=1e-12)

Four exercises

  1. Find the squared norm, norm, and normalized form of [−8, 6].
  2. Normalize [2, 1 − i] and report its computational-basis probabilities.
  3. A vector has norm five. What are the norms after multiplying it by −2, i, and 1 + i?
  4. Explain why dividing [1, 2] by the sum of its entries does not create a unit-norm amplitude vector. Give the correct denominator.

Exercise solutions

  1. The squared norm is 64 + 36 = 100. The norm is ten, and the normalized vector is [−4/5, 3/5]. Its squared entries total one.
  2. The squared norm is four plus two, or six. Divide by √6. The probabilities become 4/6 = 2/3 and 2/6 = 1/3.
  3. The magnitudes of the scalars are two, one, and √2. Multiply five by each: ten, five, and 5√2.
  4. Dividing by three gives [1/3, 2/3], whose squared norm is 5/9. The correct norm is √5, giving [1/√5, 2/√5].

Five multiple-choice checks

  1. For complex coordinates, squared norm means: A. Sum of ordinary squares. B. Sum of squared magnitudes. C. Sum of phases. D. Largest entry.

    Answer: B. Squared magnitudes guarantee nonnegative real contributions.

  2. The norm of [−3, 4i] is: A. One. B. Seven. C. Five. D. Twenty-five.

    Answer: C. Its squared norm is nine plus sixteen; the norm is the square root.

  3. Which scalar preserves every vector’s norm? A. Two. B. Zero. C. 1 + i. D. −i.

    Answer: D. Its magnitude equals one.

  4. A probability vector’s entries must sum to: A. Its Euclidean norm. B. One. C. Zero. D. The number of outcomes.

    Answer: B. This differs from the squared-magnitude normalization of amplitudes.

  5. A large norm error after a supposedly ideal gate should prompt: A. Silent correction every time. B. Ignoring the state. C. Investigation of the gate or code. D. Changing the measurement labels.

    Answer: C. Renormalization alone can conceal a broken model or implementation.

Pitfalls and summary

Use complex magnitudes, include every coordinate, and divide by the norm rather than its square. A unit norm makes amplitude probabilities sum to one, but does not establish correct physics by itself. Next, inner products extend this length calculation into a way to compare vectors.

Primary sources and further study

These sources support the definitions and context. The numerical examples, exercises, and explanations here were prepared for this lesson. Research papers are optional advanced reading.