Complex Numbers for AI
The square root of -1 is not imaginary. It is the key to rotations, frequencies, and half of signal processing. Language: Python Perform complex arithmetic (add, multiply, divide, conjugate) in both rectangular and polar form. Apply Euler's formula to convert between complex exponentials and trigonometric functions. Implement the Discrete Fourier Transform using complex roots of unity. Explain how complex rotations underlie RoPE and sinusoidal positional encodings in transformers. You open a paper on Fourier transforms and there is i everywhere. You look at transformer positional encodings and see sin and cos at different frequencies -- the real and imaginary parts of complex exponentials. You read about quantum computing and find everything expressed in complex vector spaces. Complex numbers seem abstract. A number system built on the square root of -1 feels like a mathematical trick. But it is not a trick. It is the natural language of rotations and oscillations. Every time something spins, vibrates, or oscillates, complex numbers are the right tool. Without understanding complex numbers, you cannot understand the Discrete Fourier Transform. You cannot understand FFT. You cannot understand how RoPE (Rotary Position Embedding) works in modern language models. You cannot understand why sinusoidal positional encodings in the original Transformer paper use the frequencies they do. This lesson builds complex arithmetic from scratch, connects it to geometry, and…
Complex Numbers for AI: The square root of -1 is not imaginary. It is the key to rotations, frequencies, and half of signal processing.
This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.
Browse the complete course catalog or open this lesson on GitHub.