3 Ω5 V4 Ω1import cmath2Z = 3 + 4j3abs(Z)4cmath.phase(Z)5I = 5 / Z
−4−4j44jrealimaginary3434553.13°10.6−0.8j34jZe^jθVI010203040-505t (ms)V · AVOLTAGE AND CURRENT OVER 40 msv = 5 cos ωt (V)i (A), 2.95 ms later
Circuit: 5 V AC source, 3 Ω resistor, coil with 4 Ω reactanceComplex plane: each number is an arrow from 0Coloured arrows: the numbers this step is aboutPython card: complex numbers with j and cmathEvery complex number is an arrow from 0: the real part across, the imaginary part up. Z = 3 + 4j is the impedance of a 3 Ω resistor in series with a coil with 4 Ω of reactance at 50 Hz. Multiplying by j turns an arrow a quarter; multiplying multiplies lengths and adds angles; dividing divides lengths and subtracts angles, so I = 5 / Z = 1∠−53.13° A = 0.6 − 0.8j A. Spinning arrows draw the waves: v(t) = 5 cos ωt and i(t) = cos(ωt − 53.13°), ω = 2π × 50 rad/s.

Arrows and j

  1. A complex number like 3 + 4j has two parts: a real part, 3, and an imaginary part, 4. Draw it on a plane: 3 steps right along the real axis, 4 steps up. The arrow from 0 to that point is the number.

Impedance as an arrow

Polar form and Ohm's law

Waves and code

Try it in the Python prompt

;; step 1/10 · Numbers with two parts
>>> z = 3 + 4j
>>> z.real, z.imag
(3.0, 4.0)
>>> type(z)
<class 'complex'>

Mathematicians write i for √−1; electrical engineers and Python write j, because i (or I) already stands for current. 3 + 4j and 3 + 4i are the same number. Use atan2(b, a) or cmath.phase, not atan(b / a): atan cannot tell 3 + 4j from −3 − 4j (both have b / a = 4/3), while atan2 looks at both signs and returns the angle in the right quarter, between −180° and 180°.