Why This Matters
The equation x^2 = -1 has no solution among real numbers. But by introducing the imaginary unit i, where i^2 = -1, we gain access to a whole new number system: complex numbers. A complex number has the form a + bi, where a is the real part and b is the imaginary part.
Complex numbers are not just a mathematical curiosity. They are essential in electrical engineering (AC circuit analysis), signal processing (Fourier transforms), quantum mechanics, computer graphics (rotations and fractals), and control theory. The complex conjugate of a + bi is a - bi, and multiplying a complex number by its conjugate eliminates the imaginary part, a technique used constantly in engineering calculations.
Define Terms
Visual Model
The full process at a glance. Click Start tour to walk through each step.
Complex numbers combine real and imaginary parts. The conjugate flips the imaginary sign, and the magnitude gives the distance from the origin.
Code Example
// Represent complex numbers as [real, imaginary]
function complexAdd(z1, z2) {
return [z1[0] + z2[0], z1[1] + z2[1]];
}
function complexMultiply(z1, z2) {
// (a+bi)(c+di) = (ac-bd) + (ad+bc)i
const [a, b] = z1;
const [c, d] = z2;
return [a*c - b*d, a*d + b*c];
}
function complexConjugate(z) {
return [z[0], -z[1]];
}
function complexMagnitude(z) {
return Math.sqrt(z[0]*z[0] + z[1]*z[1]);
}
function complexToString(z) {
if (z[1] >= 0) return `${z[0]} + ${z[1]}i`;
return `${z[0]} - ${Math.abs(z[1])}i`;
}
const z1 = [3, 4]; // 3 + 4i
const z2 = [1, -2]; // 1 - 2i
console.log("z1 =", complexToString(z1));
console.log("z2 =", complexToString(z2));
console.log("z1 + z2 =", complexToString(complexAdd(z1, z2)));
console.log("z1 * z2 =", complexToString(complexMultiply(z1, z2)));
console.log("conjugate(z1) =", complexToString(complexConjugate(z1)));
console.log("|z1| =", complexMagnitude(z1));
// Verify: z * conjugate(z) = |z|^2
const product = complexMultiply(z1, complexConjugate(z1));
console.log("z1 * conj(z1) =", complexToString(product)); // 25 + 0i
// Solve x^2 + 1 = 0: roots are i and -i
console.log("i^2 =", complexToString(complexMultiply([0,1],[0,1]))); // -1 + 0iInteractive Experiment
Try these exercises:
- Compute (2 + 3i) + (4 - i) by hand and verify with code.
- Compute (2 + 3i) * (4 - i) using FOIL. Remember i^2 = -1.
- Find the magnitude of 5 + 12i. Does the answer remind you of a Pythagorean triple?
- Multiply (3 + 4i) by its conjugate (3 - 4i). Verify the result is a real number equal to |z|^2.
- Compute i^1, i^2, i^3, i^4, i^5. What pattern do you see? What is i^100?
Quick Quiz
Coding Challenge
Write three functions that operate on complex numbers represented as [real, imaginary] arrays: (1) `complexAdd(z1, z2)` returns the sum, (2) `complexMultiply(z1, z2)` returns the product using (ac-bd) + (ad+bc)i, and (3) `complexMagnitude(z)` returns the magnitude sqrt(a^2 + b^2) rounded to 2 decimal places.
Real-World Usage
Complex numbers are indispensable in many technical fields:
- Signal processing: The Fourier transform converts signals between time and frequency domains using complex exponentials e^(ix) = cos(x) + i*sin(x).
- Electrical engineering: AC circuits use complex impedance Z = R + jX (engineers use j instead of i). Voltage and current are complex-valued phasors.
- Computer graphics: Rotations in 2D can be performed by multiplying by a complex number. Fractals like the Mandelbrot set iterate z = z^2 + c in the complex plane.
- Quantum computing: Quantum states are represented as complex vectors. Probability amplitudes are complex numbers whose magnitudes squared give probabilities.
- Control systems: Transfer function poles and zeros in the complex plane determine system stability and response characteristics.