Skip to content
Tutorials Center
My learning

Topics

Lesson 43 of 68 ยท Series, Transforms and PDEs

Complex Numbers and Phasors

Rectangular and polar form, Euler's formula, roots of unity and phasors for AC circuit analysis, with cmath and NumPy examples you can run in the browser.

There is no real number whose square is -1, so mathematicians invented one: i, defined by i**2 = -1. A complex number is z = a + b*i with real a and b. It looks like a trick, but for engineers it is one of the most practical ideas in the course. Rotations, oscillations, AC circuits, control systems, signal processing and the Fourier transform all become simpler once you describe them with complex numbers.

In Python the imaginary unit is written 1j, and a complex number is 3 + 4j. The cmath module and NumPy handle the rest.

Rectangular form and the complex plane

Write z = a + b*i. The number a is the real part, b the imaginary part. Plot z as the point (a, b) on the complex plane, with the real axis horizontal and the imaginary axis vertical.

Basic arithmetic follows ordinary algebra with i**2 = -1:

  • Add: (1 + 2i) + (3 - i) = 4 + i
  • Multiply: (1 + 2i)(3 - i) = 3 - i + 6i - 2i**2 = 5 + 5i
  • The conjugate of a + b*i is a - b*i; the product z * conj(z) = a**2 + b**2 is real.
  • Divide by multiplying top and bottom by the conjugate of the denominator.

The modulus (length) is |z| = sqrt(a**2 + b**2) and the argument (angle) is theta = atan2(b, a).

Python Complex arithmetic with Python

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A quadratic with a negative discriminant has two roots that are complex conjugates of one another. In engineering, such roots mean oscillation: the roots of a second-order ODE's characteristic equation decide whether a system rings.

Polar form and Euler's formula

Using the modulus r and angle theta, the same number is z = r*(cos(theta) + i*sin(theta)). Euler's formula packages this neatly:

e**(i*theta) = cos(theta) + i*sin(theta)

so z = r * e**(i*theta). You can see why the formula is true from the Taylor series: substitute x = i*theta into the series for e**x, group the real terms and the imaginary terms, and out come the series for cos(theta) and sin(theta).

Special case theta = pi gives e**(i*pi) = -1, the famous identity e**(i*pi) + 1 = 0.

Polar form makes multiplication geometric: multiply the moduli, add the angles. Division divides moduli and subtracts angles. Raising to a power n gives r**n * e**(i*n*theta) (de Moivre's theorem). Multiplying by e**(i*phi) rotates a point by phi without changing its length, which is why complex numbers are the natural language of rotation.

flowchart LR
    A["z = a + bi<br/>rectangular"] -->|"r = sqrt(a^2 + b^2)<br/>theta = atan2(b, a)"| B["z = r e^(i theta)<br/>polar"]
    B -->|"a = r cos(theta)<br/>b = r sin(theta)"| A

Converting between rectangular and polar form is just right-triangle trigonometry.

Python Polar form, rotation and Euler's identity

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The product has modulus 6 and angle 75 degrees, as the rule predicts. Tiny leftover imaginary parts such as 1.2e-16 in e**(i*pi) are round-off error; see Floating-Point Error and Conditioning.

Roots of unity

How many solutions does z**n = 1 have? Exactly n, equally spaced around the unit circle:

z_k = e**(2*pi*i*k/n) for k = 0, 1, ..., n-1

These are the n-th roots of unity. They appear in the discrete Fourier transform (the matrix entries in The Fourier Transform and the FFT are exactly these numbers), in polynomial algebra and in the design of digital filters. The same method finds roots of any number: the n-th roots of w = R * e**(i*phi) are R**(1/n) * e**(i*(phi + 2*pi*k)/n).

Python Roots of unity on the unit circle

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The roots add to zero, a fact that makes sums of equally spaced phases cancel; this is why three-phase power balances.

Phasors in AC analysis

A steady AC voltage is v(t) = V * cos(w*t + phi): amplitude V, angular frequency w, phase phi. In a linear circuit every voltage and current oscillates at the same w, so only amplitude and phase differ. A phasor captures exactly those two numbers as one complex value:

V_phasor = V * e**(i*phi)

The real signal is recovered as v(t) = Re( V_phasor * e**(i*w*t) ). Here e**(i*w*t) is a pointer spinning at w radians per second, and the actual voltage is its horizontal shadow.

The pay-off is that differentiation, which turns circuit laws into differential equations, becomes multiplication by i*w. That gives each component an impedance Z, a complex number that plays the role of resistance:

  • resistor: Z = R
  • inductor: Z = i*w*L
  • capacitor: Z = 1 / (i*w*C)

Ohm's law then holds in phasor form, V = Z * I, and series and parallel combinations use the usual resistor rules. Differential equations disappear; you solve algebra with complex numbers. The same trick underlies the Laplace transform, where i*w is generalised to s.

Python Series RLC impedance and phase

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Below resonance the capacitor dominates and the current leads the voltage (positive phase). Above it the inductor dominates and the current lags (negative phase). At resonance i*w*L and 1/(i*w*C) cancel, the impedance drops to just R, the current peaks at V/R = 0.5 A, and the phase is zero. You will sweep this response in the RLC circuit project.

Rule of thumb. Use phasors only for steady-state sinusoids at a single frequency. Transients, switching and non-sinusoidal inputs need the time-domain ODE, the Laplace transform, or a Fourier decomposition into many phasors.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is (2 + 3i)(2 - 3i)?

    z times its conjugate is a2 + b2 = 4 + 9 = 13, a real number.
  2. 2. By Euler's formula, what is e**(i*pi/2)?

    cos(pi/2) + i*sin(pi/2) = 0 + i = i.
  3. 3. How many distinct solutions does z**5 = 1 have in the complex numbers?

    There are exactly 5 fifth roots of unity, equally spaced around the unit circle at angles 2pik/5.
  4. 4. In phasor analysis, what is the impedance of an ideal inductor L at angular frequency w?

    Differentiating a phasor multiplies it by iw, so v = L di/dt becomes V = (iw*L) I.
  5. 5. When multiplying two complex numbers in polar form, what happens to their angles?

    Moduli multiply and angles add, because e**(ia) * e**(ib) = e**(i*(a+b)).

Summary

  • A complex number a + bi lives on a plane; its modulus is sqrt(a**2 + b**2) and its angle is atan2(b, a).
  • Euler's formula e**(i*theta) = cos(theta) + i*sin(theta) gives polar form r*e**(i*theta), where multiplication adds angles.
  • The n-th roots of unity are e**(2*pi*i*k/n), evenly spaced on the unit circle.
  • Phasors turn steady-state AC problems into complex algebra with impedances R, i*w*L and 1/(i*w*C).
  • Python: 1j, cmath for scalars, NumPy for arrays (np.angle, np.abs).

Next: Partial Differential Equations: Heat and Wave.