Complex Numbers for Circuit Analysis
A heater element in series with a coil whose reactance is is fed from a AC source. Add the "ohms" and you get and . Measure it and you get . Resistance and reactance do not add like plain numbers: they are at right angles to each other, and the arithmetic of right angles is complex arithmetic. This lesson collects the complex-number tools that the rest of the course leans on, in the notation electrical engineers use. The theory is in Complex Numbers, Complex Geometry and Complex Exponentials; here we use it.
j, not i
Engineers write the imaginary unit as , with , because is taken by current. A complex number has two equivalent forms:
with and , and back again , . The bridge between the two is Euler's formula:
Use atan2, not : the plain arctangent cannot tell () from ().
Which form for which operation
| Operation | Easiest form | Rule |
|---|---|---|
| add, subtract | rectangular | add real parts and imaginary parts separately |
| multiply | polar | |
| divide | polar | |
| conjugate | either | , |
| reciprocal | polar |
Three facts show up constantly: multiplying by rotates by (), dividing by rotates by (), and , which is how you divide in rectangular form:
Why circuits need them
A sinusoid is the real part of . In a linear circuit driven at one frequency every voltage and current shares the factor , so only the complex amplitude (the phasor) carries information. Derivatives become multiplication by , so an inductor's becomes , and Ohm's law survives in complex form, . The full treatment is Sinusoids and Phasors and Impedance and Admittance; this lesson only needs the arithmetic.
Two sinusoids of the same frequency add by adding their phasors. Adding and with trigonometric identities takes half a page; with phasors it is one rectangular addition.
Worked example: the heater and the coil
Given: series impedance , source phasor (amplitudes in rms).
Find: the current , the resistor voltage and the coil voltage .
Solve: convert to polar, then divide.
Check: , more than the source, which looks wrong until you add them as phasors: they are apart, so . KVL holds for the phasors, not for the magnitudes. The current is , the measured value, not the of the naive sum.
In Python
Python has complex numbers built in (3+4j, again with j), and cmath gives polar conversion. A two-line helper prints phasors in the style.
import cmath, math
def polar(z, unit=""):
r, th = cmath.polar(z)
return f"{r:.4g}{unit} at {math.degrees(th):.2f} deg"
Z = 30 + 40j
V = 10 # 10 V at 0 deg
I = V / Z
print("Z =", polar(Z, " ohm"))
print("I =", polar(I, " A"))
print("VR =", polar(30 * I, " V"))
print("VX =", polar(40j * I, " V"))
print("VR + VX =", polar(30 * I + 40j * I, " V"))
# two sinusoids of the same frequency: add their phasors
v1 = cmath.rect(10, math.radians(30))
v2 = cmath.rect(6, math.radians(-60))
print("v1 + v2 =", polar(v1 + v2, " V"))
z1, z2 = 3 + 4j, 1 - 2j
print("product:", z1 * z2, " quotient:", z1 / z2, " conj(z1):", z1.conjugate())Z = 50 ohm at 53.13 deg
I = 0.2 A at -53.13 deg
VR = 6 V at -53.13 deg
VX = 8 V at 36.87 deg
VR + VX = 10 V at 0.00 deg
v1 + v2 = 11.66 V at -0.96 deg
product: (11-2j) quotient: (-1+2j) conj(z1): (3-4j)
lands back on the source phasor, : KVL in complex form. NumPy works the same way on whole arrays (np.abs, np.angle(z, deg=True)), which is what you use for a frequency sweep.
Guided lab: phasors you can see
Hand calculation. A resistor in series with at : , at , and from rms the current is , with and .
Simulation. The phasor lab draws and tip to tail: they close the triangle on , which is KVL in the complex plane. Switch to "rotating" to see that the whole diagram turns at and the time waveforms are the projections.
It reads , , and , the same numbers. Raise and the angle grows towards ; raise and it shrinks towards .
What you would measure. On the bench, use a function generator at , rms, a resistor and a inductor (, expect about ). A two-channel oscilloscope across the generator (CH1) and across the resistor (CH2, which is proportional to the current) shows the phase shift: measure the time offset between zero crossings and convert, . A real coil has a winding resistance of several ohms, so expect a few degrees less than the ideal value; quote the reading with the cursor resolution, typically at this frequency. Both probe grounds must sit on the same node (the generator's ground), so put the resistor at the ground end.
Hazards and safe setup: signal-generator levels only (a few volts, milliamps); never connect a mains-powered scope's probe ground to any other point than circuit ground.
Pitfalls
- Degrees and radians.
cmathand NumPy work in radians; convert withmath.radians/np.deg2radand back. - arctan instead of atan2. It loses the quadrant for negative real parts.
- Adding magnitudes. Voltages around a loop add as phasors; their magnitudes generally do not.
- Mixing peak and rms. A phasor's length may be peak or rms; pick one per problem and say which (power formulas assume rms).
- The sign of the angle. : dividing by an inductive impedance gives a lagging current.
Practice
- Convert to polar form and to rectangular form.
- Compute in polar form.
- Add and and give the result as a cosine.
Answer
- , angle , so . And .
- and , so the result is .
- , so .
Test yourself
What is ?
Multiplying a phasor by …
- doubles its length
- rotates it by
- rotates it by
- takes its conjugate
A series impedance is . What is its magnitude?
Why should you use atan2(b, a) rather than to find the angle of ?
- it is faster
- it keeps the quadrant when is negative
- it returns degrees
- is undefined for complex numbers