|q⟩ Bad Qubits

beginner · Physics · Math Foundations: Complex Numbers

Complex Arithmetic

A complex number is a pair of real numbers written z=a+biz = a + bi, where aa is the real part Re(z)\operatorname{Re}(z) and bb is the imaginary part Im(z)\operatorname{Im}(z). All three arithmetic operations — addition, subtraction, and multiplication — follow directly from ordinary algebra together with the single rule i2=1i^2 = -1.

Addition and subtraction

Add or subtract componentwise: real parts with real parts, imaginary parts with imaginary parts.

(a+bi)+(c+di)=(a+c)+(b+d)i.(a + bi) + (c + di) = (a + c) + (b + d)i. (a+bi)(c+di)=(ac)+(bd)i.(a + bi) - (c + di) = (a - c) + (b - d)i.

Example. (3+2i)+(15i)=(3+1)+(25)i=43i(3 + 2i) + (1 - 5i) = (3+1) + (2-5)i = 4 - 3i.

Multiplication

Multiply as if expanding a polynomial, then replace every i2i^2 with 1-1:

(a+bi)(c+di)=ac+adi+bci+bdi2=(acbd)+(ad+bc)i.(a + bi)(c + di) = ac + adi + bci + bdi^2 = (ac - bd) + (ad + bc)i.

The key step is i2=1i^2 = -1: the term bdi2bdi^2 becomes bd-bd, which shifts into the real part.

Example. (1+2i)(3i)(1 + 2i)(3 - i):

(1)(3)+(1)(i)+(2i)(3)+(2i)(i)=3i+6i2i2=3+5i+2=5+5i.(1)(3) + (1)(-i) + (2i)(3) + (2i)(-i) = 3 - i + 6i - 2i^2 = 3 + 5i + 2 = 5 + 5i.

Why this matters for quantum mechanics

In quantum mechanics a system's state is described by complex amplitudes. When two quantum paths lead to the same outcome, their amplitudes are added (interference). When a gate acts on a state, the amplitude for each output is a sum of products of matrix entries and input amplitudes. Both operations reduce to complex addition and multiplication, so mastering them is the entry point to every quantum calculation that follows.

Try it

This is a numerical exercise — return a number. Let z1=2+3iz_1 = 2 + 3i and z2=12iz_2 = 1 - 2i. Compute the real part of their product z1z2z_1 z_2.

Expand (2+3i)(12i)(2 + 3i)(1 - 2i) by hand, replace i2=1i^2 = -1, collect the real terms, and return that number.

Run your code to see the quantum state.

Sign in on the full site to ask questions and join the discussion.