TExcelTAD
Home › Circuit Theory & Network Analysis › Complex Numbers for Circuit Analysis

Complex Numbers for Circuit Analysis

A 30 Ω30\ \Omega heater element in series with a coil whose reactance is 40 Ω40\ \Omega is fed from a 10 V10\ \text{V} AC source. Add the "ohms" and you get 70 Ω70\ \Omega and 0.143 A0.143\ \text{A}. Measure it and you get 0.200 A0.200\ \text{A}. 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 jj, with j2=−1j^2 = -1, because ii is taken by current. A complex number has two equivalent forms:

z=a+jb(rectangular)z=r∠θ=rejθ(polar)z = a + jb \quad\text{(rectangular)} \qquad z = r\angle\theta = r e^{j\theta} \quad\text{(polar)}

with r=∣z∣=a2+b2r = \lvert z \rvert = \sqrt{a^2 + b^2} and θ=atan2⁡(b,a)\theta = \operatorname{atan2}(b, a), and back again a=rcos⁡θa = r\cos\theta, b=rsin⁡θb = r\sin\theta. The bridge between the two is Euler's formula:

ejθ=cos⁡θ+jsin⁡θe^{j\theta} = \cos\theta + j\sin\theta

Use atan2, not arctan⁡(b/a)\arctan(b/a): the plain arctangent cannot tell 1+j1 + j (45∘45^\circ) from −1−j-1 - j (−135∘-135^\circ).

Re Im (j) Z = 30 + j40 ohm = 50 at 53.13 deg R = 30 X = 40 theta I = 0.2 A at -53.13 deg V = 10 V at 0 deg I = V / Z multiply: lengths multiply, angles add; divide: lengths divide, angles subtract

Which form for which operation

Operation Easiest form Rule
add, subtract rectangular add real parts and imaginary parts separately
multiply polar r1∠θ1⋅r2∠θ2=r1r2∠(θ1+θ2)r_1\angle\theta_1 \cdot r_2\angle\theta_2 = r_1 r_2 \angle(\theta_1 + \theta_2)
divide polar r1∠θ1r2∠θ2=r1r2∠(θ1−θ2)\dfrac{r_1\angle\theta_1}{r_2\angle\theta_2} = \dfrac{r_1}{r_2}\angle(\theta_1 - \theta_2)
conjugate either a+jb‾=a−jb\overline{a + jb} = a - jb, r∠θ‾=r∠−θ\overline{r\angle\theta} = r\angle{-\theta}
reciprocal polar 1/(r∠θ)=(1/r)∠−θ1/(r\angle\theta) = (1/r)\angle{-\theta}

Three facts show up constantly: multiplying by jj rotates by +90∘+90^\circ (j=1∠90∘j = 1\angle 90^\circ), dividing by jj rotates by −90∘-90^\circ (1/j=−j1/j = -j), and zzˉ=∣z∣2z\bar{z} = \lvert z \rvert^2, which is how you divide in rectangular form:

3+j41−j2=(3+j4)(1+j2)(1−j2)(1+j2)=3+j6+j4−81+4=−5+j105=−1+j2\frac{3 + j4}{1 - j2} = \frac{(3 + j4)(1 + j2)}{(1 - j2)(1 + j2)} = \frac{3 + j6 + j4 - 8}{1 + 4} = \frac{-5 + j10}{5} = -1 + j2

Why circuits need them

A sinusoid v(t)=Vmcos⁡(ωt+ϕ)v(t) = V_m\cos(\omega t + \phi) is the real part of VmejϕejωtV_m e^{j\phi} e^{j\omega t}. In a linear circuit driven at one frequency every voltage and current shares the factor ejωte^{j\omega t}, so only the complex amplitude Vmejϕ=Vm∠ϕV_m e^{j\phi} = V_m\angle\phi (the phasor) carries information. Derivatives become multiplication by jωj\omega, so an inductor's v=L di/dtv = L\,di/dt becomes V=jωL IV = j\omega L\,I, and Ohm's law survives in complex form, V=ZIV = ZI. 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 10cos⁡(ωt+30∘)10\cos(\omega t + 30^\circ) and 6cos⁡(ωt−60∘)6\cos(\omega t - 60^\circ) with trigonometric identities takes half a page; with phasors it is one rectangular addition.

Worked example: the heater and the coil

Given: series impedance Z=R+jX=30+j40 ΩZ = R + jX = 30 + j40\ \Omega, source phasor V=10∠0∘ VV = 10\angle 0^\circ\ \text{V} (amplitudes in rms).

Find: the current II, the resistor voltage VRV_R and the coil voltage VXV_X.

Solve: convert ZZ to polar, then divide.

∣Z∣=302+402 Ω=50 Ω,θ=atan2⁡(40,30)=53.13∘I=VZ=10∠0∘ V50∠53.13∘ Ω=0.2∠−53.13∘ AVR=RI=6∠−53.13∘ V,VX=jXI=(40∠90∘)(0.2∠−53.13∘)=8∠36.87∘ V\begin{aligned} \lvert Z \rvert &= \sqrt{30^2 + 40^2}\ \Omega = 50\ \Omega, \qquad \theta = \operatorname{atan2}(40, 30) = 53.13^\circ \\ I &= \frac{V}{Z} = \frac{10\angle 0^\circ\ \text{V}}{50\angle 53.13^\circ\ \Omega} = 0.2\angle{-53.13^\circ}\ \text{A} \\ V_R &= R I = 6\angle{-53.13^\circ}\ \text{V}, \qquad V_X = jX I = (40\angle 90^\circ)(0.2\angle{-53.13^\circ}) = 8\angle 36.87^\circ\ \text{V} \end{aligned}

Check: ∣VR∣+∣VX∣=14 V\lvert V_R \rvert + \lvert V_X \rvert = 14\ \text{V}, more than the source, which looks wrong until you add them as phasors: they are 90∘90^\circ apart, so 62+82=10 V\sqrt{6^2 + 8^2} = 10\ \text{V}. KVL holds for the phasors, not for the magnitudes. The current is 0.2 A0.2\ \text{A}, the measured value, not the 0.143 A0.143\ \text{A} 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 r∠θr\angle\theta style.

python · try it yourself
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)

VR+VXV_R + V_X lands back on the source phasor, 10∠0∘10\angle 0^\circ: 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 30 Ω30\ \Omega resistor in series with L=127 mHL = 127\ \text{mH} at 50 Hz50\ \text{Hz}: XL=2π⋅50⋅0.127=39.90 ΩX_L = 2\pi \cdot 50 \cdot 0.127 = 39.90\ \Omega, ∣Z∣=49.92 Ω\lvert Z \rvert = 49.92\ \Omega at 53.06∘53.06^\circ, and from 10 V10\ \text{V} rms the current is 0.2003 A0.2003\ \text{A}, with ∣VR∣=6.010 V\lvert V_R \rvert = 6.010\ \text{V} and ∣VL∣=7.993 V\lvert V_L \rvert = 7.993\ \text{V}.

Simulation. The phasor lab draws VRV_R and VLV_L tip to tail: they close the triangle on VV, which is KVL in the complex plane. Switch to "rotating" to see that the whole diagram turns at ω\omega and the time waveforms are the projections.

ReImVRVLVIphi = 53.1 deg, I lags(I drawn on its own scale)-pk0+pk0T/2T3T/22Tv(t), peak 14.1 Vi(t), peak 283 mAimpedance trianglepower triangleRX|Z|PQSR = 30.0 OhmP = 1.20 WX = 39.9 OhmQ = 1.60 var|Z| = 49.9 OhmS = 2.00 VApf = cos phi = 0.601 lagging

It reads XL=39.90 ΩX_L = 39.90\ \Omega, ∣Z∣=49.92 Ω\lvert Z \rvert = 49.92\ \Omega, φ=53.1∘\varphi = 53.1^\circ and ∣I∣=200.3 mA\lvert I \rvert = 200.3\ \text{mA}, the same numbers. Raise ff and the angle grows towards 90∘90^\circ; raise RR and it shrinks towards 0∘0^\circ.

What you would measure. On the bench, use a function generator at 1 kHz1\ \text{kHz}, 2 V2\ \text{V} rms, a 100 Ω100\ \Omega resistor and a 15 mH15\ \text{mH} inductor (XL=94.2 ΩX_L = 94.2\ \Omega, expect about 43∘43^\circ). 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 Δt\Delta t between zero crossings and convert, φ=360∘⋅f Δt\varphi = 360^\circ \cdot f\,\Delta t. 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 ±2∘\pm 2^\circ 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. cmath and NumPy work in radians; convert with math.radians/np.deg2rad and 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. 1/j=−j1/j = -j: dividing by an inductive impedance gives a lagging current.

Practice

  1. Convert −4+j3-4 + j3 to polar form and 20∠−120∘20\angle{-120^\circ} to rectangular form.
  2. Compute (2+j2)(5∠30∘)1−j\dfrac{(2 + j2)(5\angle 30^\circ)}{1 - j} in polar form.
  3. Add v1=5cos⁡(ωt)v_1 = 5\cos(\omega t) and v2=5cos⁡(ωt−90∘)v_2 = 5\cos(\omega t - 90^\circ) and give the result as a cosine.
Answer
  1. ∣z∣=5\lvert z \rvert = 5, angle =atan2⁡(3,−4)=143.13∘= \operatorname{atan2}(3, -4) = 143.13^\circ, so 5∠143.13∘5\angle 143.13^\circ. And 20∠−120∘=20(−0.5)+j20(−0.866)=−10−j17.3220\angle{-120^\circ} = 20(-0.5) + j20(-0.866) = -10 - j17.32.
  2. 2+j2=2.828∠45∘2 + j2 = 2.828\angle 45^\circ and 1−j=1.414∠−45∘1 - j = 1.414\angle{-45^\circ}, so the result is 2.828⋅51.414∠(45∘+30∘+45∘)=10∠120∘\dfrac{2.828 \cdot 5}{1.414}\angle(45^\circ + 30^\circ + 45^\circ) = 10\angle 120^\circ.
  3. 5+(−j5)=7.071∠−45∘5 + (-j5) = 7.071\angle{-45^\circ}, so v1+v2=7.07cos⁡(ωt−45∘)v_1 + v_2 = 7.07\cos(\omega t - 45^\circ).

Test yourself

What is (4∠30∘)⋅(2∠60∘)(4\angle 30^\circ) \cdot (2\angle 60^\circ)?

  1. 6∠90∘6\angle 90^\circ
  2. 8∠90∘8\angle 90^\circ
  3. 8∠1800∘8\angle 1800^\circ
  4. 2∠−30∘2\angle{-30^\circ}

Multiplying a phasor by jj…

  1. doubles its length
  2. rotates it by +90∘+90^\circ
  3. rotates it by −90∘-90^\circ
  4. takes its conjugate

A series impedance is 30+j40 Ω30 + j40\ \Omega. What is its magnitude?

  1. 70 Ω70\ \Omega
  2. 10 Ω10\ \Omega
  3. 50 Ω50\ \Omega
  4. 35 Ω35\ \Omega

Why should you use atan2(b, a) rather than arctan⁡(b/a)\arctan(b/a) to find the angle of a+jba + jb?

  1. it is faster
  2. it keeps the quadrant when aa is negative
  3. it returns degrees
  4. arctan⁡\arctan is undefined for complex numbers