Quantum Computing Master Course — 004. Complex Numbers and Amplitudes
Lesson 004: Complex Numbers and Amplitudes
Smartyfy Quantum Computing Master Course
Prerequisites and objectives
Lessons 002 and 003 introduced probability and vectors. This lesson adds complex coordinates. You will calculate with the imaginary unit, take a complex conjugate, find a magnitude, and distinguish a phase change from a probability change. No calculus or advanced physics is needed.
Extending ordinary numbers
The imaginary unit i is defined by i² = −1. The University of Waterloo’s mathematical introduction provides further practice with the number system used here. A complex number has the form z = a + bi, where a and b are real numbers. The real part is a; the imaginary part is b, a real coefficient multiplying i. The terminology is historical. Calling a number imaginary does not make its mathematical role vague or optional.
Examples include 2 + 3i, −4 + i, and 5 − 2i. Ordinary real numbers are also complex numbers with zero imaginary part: 7 = 7 + 0i. Purely imaginary numbers have zero real part, such as 3i. Two complex numbers are equal exactly when both their real parts and their imaginary parts match.
You may picture a + bi as the point with horizontal coordinate a and vertical coordinate b. This complex plane is a mathematical diagram. When a quantum amplitude is complex, its real and imaginary parts are not two separately observed measurement outcomes.
Addition and multiplication
Add corresponding parts: (2 + 3i) + (1 − 2i) = 3 + i. Subtracting works similarly. Multiplication uses the distributive rule and the identity i² = −1. Thus (2 + 3i)(1 − 2i) = 2 − 4i + 3i − 6i² = 8 − i. Write the intermediate products until the sign changes feel reliable.
Powers of i repeat in a four-step cycle: i, −1, −i, 1. Consequently i⁵ = i and i⁶ = −1. This cycle helps you simplify formulas without introducing decimals. A common error is treating i² as positive one or discarding imaginary terms before the complete expression has been evaluated.
Conjugation and magnitude
The complex conjugate of z = a + bi is z* = a − bi. It flips the imaginary part’s sign while preserving the real part. For z = 2 + 3i, the conjugate is 2 − 3i. In the complex plane, conjugation reflects the point across the real axis.
Multiplying a number by its conjugate gives zz* = a² + b². Check the example: (2 + 3i)(2 − 3i) = 4 − 6i + 6i − 9i² = 13. The imaginary terms cancel, leaving a nonnegative real number. The magnitude is |z| = square root of a² + b², so |2 + 3i| = square root of thirteen.
The squared magnitude |z|² is therefore thirteen. It is different from z², which equals −5 + 12i for this example. In quantum probability calculations we use squared magnitude, not an ordinary square of a complex amplitude. That distinction prevents impossible “probabilities” such as negative or imaginary numbers.

Worked example: a candidate amplitude
Let α = (2 + i)/3. Its real part is 2/3 and its imaginary part is 1/3. The squared magnitude is (2/3)² + (1/3)² = 5/9. If α is the coefficient of a specified outcome in a normalized state, that outcome’s probability is 5/9. The condition about normalization matters: an isolated number does not automatically describe a complete physical state.
The ordinary square is α² = (3 + 4i)/9, which would not be a probability. Conjugation supplies the correct calculation: αα* = (2 + i)(2 − i)/9 = 5/9. You can calculate this either by multiplication or by adding the squares of the real and imaginary parts.
Phase as direction in the complex plane
A nonzero complex number has a magnitude and an angle, called its phase. At unit magnitude, the numbers 1, i, −1, and −i lie at quarter-turn intervals. Multiplication by i rotates every complex number by a quarter turn without changing its magnitude. For example, i(2 + 3i) = −3 + 2i, whose squared magnitude remains thirteen.
For an angle θ, a unit-magnitude complex number can be written cos θ + i sin θ, also denoted e to the power iθ. Its squared magnitude is cos² θ + sin² θ = 1. You need not memorize angle formulas today; understand that phase can change while magnitude stays fixed.
Why retain phase if probabilities use only magnitude? Because amplitudes may be combined before a probability is calculated. Consider contributions a = 1/2 and b = 1/2. Their sum is one, with squared magnitude one. Replace b by −1/2, preserving its individual magnitude, and the sum becomes zero. The relative direction of contributions changes the result.
These two-contribution calculations illustrate interference algebra, not a complete specification of a quantum experiment. A full model must say how the contributions arise and ensure normalization across all outcomes. We will build such a model with gates rather than treating arbitrary sums as automatically physical.
Local complex arithmetic
Python uses j for the imaginary unit, so 3j means three times i in our mathematical notation. The built-in complex type supports conjugation, addition, and multiplication. The function abs returns magnitude. Floating-point calculations may need a tolerance when comparing results; rounding below only makes the printed value easier to read.
z = 2 + 3j
w = 1 - 2j
print("sum:", z + w)
print("product:", z * w)
print("conjugate:", z.conjugate())
print("magnitude squared:", round(abs(z) ** 2, 10))
assert z + w == 3 + 1j
assert z * w == 8 - 1j
assert z * z.conjugate() == 13 + 0j
assert abs((1j * z)) == abs(z)
Four exercises
- Calculate (3 − 2i) + (−1 + 5i) and (3 − 2i)(1 + i).
- Find the conjugate, squared magnitude, and magnitude of −3 + 4i.
- Calculate the squared magnitude of (1 − 2i)/3. Explain why squaring the number directly is the wrong probability calculation.
- Compare |a + b|² for a = 1/2 with b = 1/2, b = −1/2, and b = i/2.
Exercise solutions
- The sum is 2 + 3i. The product is 3 + 3i − 2i − 2i² = 5 + i.
- The conjugate is −3 − 4i. The squared magnitude is 9 + 16 = 25, and the magnitude is five.
- The squared magnitude is 1/9 + 4/9 = 5/9. Direct squaring yields (−3 − 4i)/9, a complex value rather than a valid probability.
- The three results are one, zero, and one half. In the last case, the sum is (1 + i)/2, giving 1/4 + 1/4. Individual magnitudes alone do not determine the combined result.
Five multiple-choice checks
-
What is i²? A. 1. B. −1. C. i. D. Zero.
Answer: B. This defining identity controls complex multiplication.
-
The conjugate of 4 − 3i is: A. −4 + 3i. B. −4 − 3i. C. 4 + 3i. D. 3 − 4i.
Answer: C. Only the imaginary part changes sign.
-
What is |1 + i|²? A. Zero. B. i. C. Square root of two. D. Two.
Answer: D. Add the squares of the real and imaginary parts: one plus one.
-
Multiplying by i changes a nonzero complex number’s: A. Phase but not magnitude. B. Magnitude only. C. Dimension. D. Probability normalization arbitrarily.
Answer: A. It performs a quarter-turn rotation in the complex plane.
-
Which operation converts an amplitude α into its probability contribution? A. α². B. |α|². C. Its imaginary part. D. Its phase angle.
Answer: B. Squared magnitude is nonnegative and real; a complete state must also be normalized.
Pitfalls and summary
Do not confuse magnitude with squared magnitude, conjugation with negation, or a complex coefficient with a probability. Phase is retained because later operations can combine amplitudes. Next, we put two complex amplitudes into a normalized vector and calculate the measurement statistics of one qubit.
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.