Why sinusoids?
Almost all the electricity you use arrives as a sinusoid. The voltage at a wall socket swings smoothly up and down 50 times a second in most of the world and 60 times a second in most of the Americas. Radio, Wi-Fi and mobile phones send their information on sinusoidal carriers at millions or billions of cycles a second. And through Fourier analysis (Fourier analysis), any repeating signal, a square clock wave or a musical note, can be written as a sum of sinusoids.
Sinusoids have one property that makes them the natural language of circuit analysis. In a linear circuit (resistors, capacitors, inductors and sources, with nothing that switches or saturates), a sinusoidal source produces, once the transients have died away, voltages and currents that are all sinusoids of the same frequency. Only two things change from place to place: how big each sinusoid is, and how far it is shifted in time. You saw this at the end of RLC circuits and resonance, where a complex exponential turned the RLC differential equation into one line of algebra.
This lesson turns that trick into a method. Each sinusoid becomes a complex number, a phasor, that records its size and shift. Each component becomes a complex impedance. And then every technique you already know for resistive circuits, from Ohm's law to nodal analysis, works unchanged, with complex numbers in place of real ones.
Describing a sinusoid
Definition— Sinusoid, amplitude, frequency, phase
A sinusoid is a signal of the form
is its amplitude (peak value). is its angular frequency in radians per second; its frequency is in hertz (cycles per second) and its period is . is its phase, in radians or degrees. Of two sinusoids at the same frequency, the one with the larger phase leads: it reaches each peak earlier, by . The other lags.
A sine is a cosine that lags by 90°, , so we write everything as cosines and lose nothing.
RMS values, and why mains is quoted in RMS
A sinusoid averages to zero over a cycle, so its average says nothing about how much it can heat a kettle. What matters for heating is power, and the power in a resistor is , which is never negative. The root-mean-square (RMS) value is defined so that it gives the same average power in a resistor as a steady DC value would:
For a sinusoid, the average of over a cycle is , so . A 2 kW kettle heats exactly as fast on 230 V RMS AC as it would on 230 V DC.
That is why mains voltages are quoted as RMS values. The "230 V" (or 220 V) supply of most of Europe, Africa, Asia and Oceania, the "120 V" of North America and the "100 V" of Japan are all RMS. Their peaks are times higher: 325 V, 170 V and 141 V. Insulation, and the safety rules you will meet throughout this course, are designed around those peaks. (This is also one of many reasons to leave mains wiring to qualified electricians and to do your own experiments with small batteries, signal generators and simulation.)
The factor belongs to sinusoids alone. Many cheap meters measure the average of and multiply by 1.111, the ratio that makes a sinusoid read correctly; a true-RMS meter computes the real thing. The program below compares them on four waveforms, including the current that a simple rectifier power supply draws, which flows only in short pulses near each peak of the mains voltage.
import numpy as np
f = 50.0
t = np.linspace(0, 1 / f, 200000, endpoint=False) # one cycle, finely sampled
phase = f * t # runs from 0 to 1 over the cycle
s = np.sin(2 * np.pi * phase)
waves = {
"sine": s,
"square": np.where(phase < 0.5, 1.0, -1.0),
"triangle": 2 * np.abs(2 * phase - 1) - 1,
# current drawn by a rectifier feeding a capacitor: short pulses near each voltage peak
"rectifier pulses": np.sign(s) * np.clip((np.abs(s) - 0.9) / 0.1, 0, None),
}
print(f"{'waveform':17} {'peak':>5} {'true RMS':>9} {'average-responding':>19} {'crest factor':>13}")
for name, x in waves.items():
peak = np.abs(x).max()
rms = np.sqrt(np.mean(x**2)) # root of the mean of the square
avg_meter = np.mean(np.abs(x)) * np.pi / (2 * np.sqrt(2)) # calibrated so a sine reads right
print(f"{name:17} {peak:5.2f} {rms:9.4f} {avg_meter:19.4f} {peak / rms:13.2f}")
print()
for volts in (230, 120, 100):
print(f"{volts} V RMS mains: peak {volts * np.sqrt(2):.0f} V, peak to peak {2 * volts * np.sqrt(2):.0f} V")For the sine both meters agree at 0.7071 of the peak. For the square wave the average-responding meter reads 11% high (1.1107 instead of 1); for the triangle, 4% low. For the rectifier pulses it reads 0.2119 where the true RMS is 0.3904, almost 46% low, because the pulses are tall and narrow: their crest factor (peak divided by RMS) is 2.56 against a sine's 1.41. Since so much modern equipment draws pulsed current like this, power engineers measure with true-RMS instruments.
Phasors: sinusoids as complex numbers
As in the previous lesson, we write for , because means current. Euler's formula, (see Lumenary Math's Complex numbers), lets us write any sinusoid as the real part of a rotating complex number:
The factor is the same for every voltage and current in the circuit, so we can leave it out and keep only the complex number in front of it.
Definition— Phasor
The phasor of the sinusoid is the complex number , often written in polar form as . Its magnitude is the amplitude and its angle is the phase. To return to the time domain, multiply by and take the real part. We write phasors as capital letters and time functions as lower-case ones.
Picture the phasor as an arrow in the complex plane, spinning anticlockwise at radians per second; the signal is its shadow on the real axis. Two sinusoids at the same frequency spin together, so the angle between their arrows, their phase difference, never changes. That frozen picture is the phasor diagram.
Theorem— Circuit laws for phasors
In a linear circuit whose sources all have angular frequency , in sinusoidal steady state:
- Kirchhoff's current and voltage laws hold for phasors: the phasor currents into a node sum to zero, and the phasor voltages round a loop sum to zero.
- Each component obeys , where and are the phasors of its voltage and current, and is its impedance: , and .
Proof
(1) If for all , then for all , where . At this says ; at it says . So . (2) Differentiating, : differentiation in time is multiplication of the phasor by . So the inductor law becomes , and the capacitor law becomes , that is, . The resistor law is unchanged.
∎
Example— Adding two voltages
In a series circuit, the voltage across a resistor is V and the voltage across an inductor is V. What is the total? In phasors, , whose magnitude is and whose angle is . So the total is V: 5 V, not 7 V, because the two peaks happen at different times. Adding the cosines directly with trigonometric identities gives the same answer, with far more work.
Impedance
Definition— Impedance, reactance, admittance
The impedance of a two-terminal element is , the ratio of the phasors of its voltage and current, in ohms. It is complex: , where is the resistance and the reactance. Its reciprocal is the admittance, in siemens, made of conductance and susceptance .
| Element | Impedance | Magnitude | Current compared with voltage | At DC () | At very high |
|---|---|---|---|---|---|
| Resistor | in phase | ||||
| Inductor | lags by 90° | short circuit | open circuit | ||
| Capacitor | leads by 90° | open circuit | short circuit |
Impedances combine exactly like resistances: in series they add, ; in parallel the admittances add, . Voltage dividers, Thévenin equivalents (Network theorems) and nodal analysis all carry over.
Example— A motor's impedance at 50 Hz
At one operating point, a small single-phase motor can be modelled as a 20 Ω resistance (which stands for both the real work done and the losses) in series with a 50 mH inductance (its windings). At 50 Hz, rad/s, so
On a 230 V RMS supply the current has RMS value A, and it lags the voltage by 38.1°. A pure resistor of 25.43 Ω would draw the same current in step with the voltage; we will see in a moment that the two are very different loads for the power company.
The series RLC circuit of the previous lesson is now one line: . The reactance vanishes at , where , and the current amplitude is the resonance formula we derived there.
AC nodal analysis with NumPy
Nodal analysis writes Kirchhoff's current law at every node as a linear system , where is the nodal admittance matrix. Nothing changes for AC circuits except that , and are complex, and Gaussian elimination (Lumenary Math's Linear algebra) works over the complex numbers exactly as over the reals, so NumPy solves complex systems as happily as real ones.
Here is a small filter driven at 1 kHz: a 10 V source with 100 Ω of internal resistance, a capacitor to ground, an inductor in series, and a load of 50 Ω in parallel with another capacitor.
The program uses a source transformation: a voltage source in series with behaves, as far as the rest of the circuit can tell, like a current source in parallel with . Then it builds the way SPICE does, by "stamping" each branch's admittance into the matrix, and solves.
import numpy as np
f = 1000.0 # every source in the circuit runs at 1 kHz
w = 2 * np.pi * f
Vs = 10.0 + 0j # source phasor: amplitude 10 V, phase 0
def Z_R(R): return complex(R)
def Z_L(L): return 1j * w * L
def Z_C(C): return 1 / (1j * w * C)
# (name, node a, node b, impedance); node 0 is ground. The source and its 100-ohm
# resistor become a current source Vs/R1 into node 1, with R1 from node 1 to ground.
branches = [
("R1", 1, 0, Z_R(100)),
("C1", 1, 0, Z_C(1e-6)),
("L1", 1, 2, Z_L(10e-3)),
("R2", 2, 0, Z_R(50)),
("C2", 2, 0, Z_C(2.2e-6)),
]
n = 2
Y = np.zeros((n, n), dtype=complex) # the nodal admittance matrix
for name, a, b, Z in branches:
y = 1 / Z
if a: Y[a - 1, a - 1] += y
if b: Y[b - 1, b - 1] += y
if a and b:
Y[a - 1, b - 1] -= y
Y[b - 1, a - 1] -= y
I = np.array([Vs / 100, 0]) # current injected into each node
V = np.linalg.solve(Y, I)
def polar(z, unit):
return f"{abs(z):7.4f} {unit} at {np.degrees(np.angle(z)):7.2f} deg"
for name, a, b, Z in branches:
print(f"Z_{name} = {Z.real:6.2f} {Z.imag:+8.2f}j ohm")
print()
for k, v in enumerate(V, start=1):
print(f"V{k} = {v.real:7.4f} {v.imag:+7.4f}j V = {polar(v, 'V')}")
# Branch currents, and Kirchhoff's current law checked at both nodes.
i_src = (Vs - V[0]) / 100 # out of the real source, through R1
i_C1, i_L1 = V[0] / Z_C(1e-6), (V[0] - V[1]) / Z_L(10e-3)
i_R2, i_C2 = V[1] / Z_R(50), V[1] / Z_C(2.2e-6)
print(f"\nsource current = {polar(i_src * 1000, 'mA')}")
print(f"KCL residuals: node 1 {abs(i_src - i_C1 - i_L1):.1e} A, node 2 {abs(i_L1 - i_R2 - i_C2):.1e} A")
t = 0.1e-3 # back to the time domain, at t = 0.1 ms
print(f"v2(0.1 ms) = Re(V2 e^(j w t)) = {(V[1] * np.exp(1j * w * t)).real:.4f} V")The output voltage is V: at 1 kHz this network passes about a third of the source amplitude and delays it by almost a fifth of a cycle. Node n1 sits at V, which leads the source, something no resistive circuit could do. Kirchhoff's current law holds at both nodes up to floating-point rounding: the residuals are of the order of A or zero.
Checking with SPICE
SPICE's .ac analysis does exactly this calculation: it linearises the circuit, gives each source a phasor (here an amplitude of 10 V at phase 0), and solves the complex nodal equations at each requested frequency. vm and vp are a node's magnitude and phase (in radians, which the script converts to degrees).
* AC nodal analysis check: 10 V at 1 kHz into a C-L-C network
V1 s 0 DC 0 AC 10
R1 s n1 100
C1 n1 0 1u
L1 n1 n2 10m
R2 n2 0 50
C2 n2 0 2.2u
.control
ac lin 1 1k 1k
let ph1 = 180/pi*vp(n1)
let ph2 = 180/pi*vp(n2)
print vm(n1) ph1 vm(n2) ph2
.endc
.endngspice prints:
vm(n1) = 4.163921e+00
ph1 = 2.027362e+01
vm(n2) = 3.295555e+00
ph2 = -6.37536e+01These are the NumPy values, 4.1639 V at 20.27° and 3.2956 V at −63.75°, to every digit shown.
Power in AC circuits
In AC circuits, power has more than one meaning, and the differences matter to anyone who pays for electricity or designs the cables that carry it. Let a load have RMS voltage and RMS current , with the current lagging the voltage by the angle , which is the angle of the load's impedance.
Theorem— Average power in sinusoidal steady state
If and , the instantaneous power is
and its average over a cycle is .
Proof
Use with and : . The second term oscillates at and averages to zero over a cycle, leaving .
∎
So the power flowing into a load has a steady part and a part that surges back and forth at twice the supply frequency. That splits naturally into named quantities.
Definition— Real, reactive and apparent power; power factor
With RMS phasors and , the complex power is , where is the complex conjugate. Its parts are:
- Real (active) power , in watts (W): the average rate at which energy is delivered and turned into heat, light or work.
- Reactive power , in volt-amperes reactive (var): the amplitude of the energy that flows into the load's inductances and capacitances and back again each cycle, doing no net work. By convention for inductive loads (current lagging) and for capacitive ones.
- Apparent power , in volt-amperes (VA): the product of the RMS voltage and current that the supply must actually provide.
- Power factor , equal to for sinusoids, described as lagging or leading according to the current.
The program computes all of this for the motor example, then checks it against the time domain by multiplying and sample by sample.
import numpy as np
f, V_rms = 50.0, 230.0
w = 2 * np.pi * f
R, L = 20.0, 50e-3 # a motor at one operating point: R in series with L
Z = R + 1j * w * L
V = complex(V_rms) # an RMS phasor, as power engineers write them
I = V / Z
S = V * np.conj(I) # complex power in volt-amperes
P, Q = S.real, S.imag
print(f"Z = {Z.real:.2f} + {Z.imag:.2f}j ohm = {abs(Z):.2f} ohm at {np.degrees(np.angle(Z)):.1f} deg")
print(f"I = {abs(I):.3f} A RMS, lagging the voltage by {-np.degrees(np.angle(I)):.1f} deg")
print(f"P = {P:.0f} W Q = {Q:.0f} var |S| = {abs(S):.0f} VA power factor = {P / abs(S):.3f}")
# The same numbers from the time domain: average v(t) i(t) over one cycle.
t = np.linspace(0, 1 / f, 100000, endpoint=False)
def wave(phasor): # an RMS phasor back to a waveform
return np.sqrt(2) * abs(phasor) * np.cos(w * t + np.angle(phasor))
v, i = wave(V), wave(I)
v_R, v_L = wave(R * I), wave(1j * w * L * I)
p = v * i
print(f"\nmean of v*i over a cycle = {p.mean():.1f} W")
print(f"p(t) swings between {p.min():.0f} W and {p.max():.0f} W")
print(f"mean power into R = {np.mean(v_R * i):.1f} W")
print(f"mean power into L = {abs(np.mean(v_L * i)):.3f} W (it swings by +/- {np.abs(v_L * i).max():.0f} W)")The phasor calculation and the brute-force average agree: 1636 W. The instantaneous power swings between −444 W and 3716 W, which is : for a short part of every cycle the motor pushes energy back into the supply. All the real power goes into the resistance. The inductance takes in and returns 1285 W at the peak of each surge, exactly , and on average absorbs nothing.
Why the power factor matters
The supply must deliver 9.04 A for this motor's 1636 W. A load with power factor 1 would need only A for the same power. Every cable, transformer and generator between the power station and the motor must carry the full 9.04 A and heats in proportion to the square of the current, so the losses in the wiring are times larger: 62% more, for the same useful power. That is why transformers and supplies are rated in VA rather than watts, and why many utilities require large industrial customers to keep their power factor above a minimum or pay extra.
The remedy, power-factor correction, is to supply the reactive power locally. A capacitor connected across an inductive load draws a leading current that cancels much of the load's lagging current, so the line carries less. Modern power supplies go further and shape their input current electronically. Both are subjects of the Power level, beginning with Three-phase power and Power electronics.
The professional view
Measuring impedance. Engineers measure impedance with an LCR meter, which drives a component with a small sinusoid at a chosen frequency (100 Hz, 1 kHz and 100 kHz are common choices) and computes from the measured phasors; an impedance analyser or vector network analyser does the same across a wide band of frequencies. Real components are not ideal. A capacitor has a little series resistance and a little series inductance, so above its self-resonant frequency it behaves like an inductor; manufacturers such as Murata, TDK, KEMET and Samsung Electro-Mechanics publish measured impedance-versus-frequency curves for their parts, and designers choose decoupling capacitors from those curves rather than from the nominal capacitance alone.
Phasors on the grid. Power engineers think in phasors all day: load-flow studies of national grids are AC nodal analysis with thousands of nodes, solved with sparse complex matrices. Since the 1990s, phasor measurement units (PMUs) have measured the voltage and current phasors at substations many times a second, time-stamped to within about a microsecond by satellite timing, so that phase angles across a whole continent can be compared directly. The measurement is standardised jointly by the IEEE and the IEC, and grid operators in North America, Europe, China, India, Brazil and elsewhere use it to watch for the oscillations and angle separations that precede blackouts (more in The power grid).
Beyond one sinusoid. Phasors describe a single frequency in steady state. Waveforms that are not sinusoidal, like the rectifier pulses above, are analysed by splitting them into harmonics (Fourier analysis) and handling each frequency with its own phasors; then the power factor has two parts, one from the phase shift and one from the distortion. Transients after switching need the differential equations of the previous lesson or the Laplace transform. And SPICE's .ac analysis of a circuit with transistors is a small-signal analysis: SPICE linearises each device around its operating point first, so the results hold only for small signals.
A short history. In 1886 Oliver Heaviside coined the word impedance. The late 1880s brought the contest between Thomas Edison's direct current and the alternating current of George Westinghouse and Nikola Tesla, which AC won largely because transformers, which work only with AC, can step voltages up for efficient long-distance transmission (Transformers and electric machines). But analysing AC circuits with trigonometry was laborious, and in 1893 the German-American engineer Charles Proteus Steinmetz and the British-American engineer Arthur Kennelly independently showed how complex numbers turn it into algebra. Within a generation, was standard engineering practice.
Common misconceptions
Misconception
"A 230 V supply never exceeds 230 V." 230 V is the RMS value. The voltage peaks at V twice every cycle, and swings 651 V from peak to peak.
Misconception
"Voltages in series add up." Their phasors add up. A resistor with 3 V across it in series with an inductor with 4 V across it has 5 V across the pair, not 7 V, because the two voltages peak at different moments. In a series RLC circuit near resonance, the inductor and capacitor voltages can each be far larger than the supply, because they nearly cancel.
Misconception
"Impedance is just resistance that depends on frequency." Resistance dissipates energy; reactance stores it and gives it back. A load with a large impedance but a small resistive part takes plenty of current from the supply while absorbing very little power.
Misconception
"Reactive power is wasted power." Reactive power is not consumed: it flows back and forth, averaging to zero. What it costs is current, and that current causes real losses in the wires and occupies the capacity of cables and transformers.
Misconception
"Power factor is the same thing as efficiency." An electric heater has power factor 1 and turns every watt into heat; an efficient motor may still have a power factor of 0.8. Efficiency compares useful output with real power in; power factor compares real power with apparent power.
Exercises
1. AC circuits, phasors and impedance
Warm-upHumanA mains supply is rated 230 V RMS and is a pure sinusoid. What is its peak-to-peak voltage, the difference between its highest and lowest values, to the nearest volt?
2. AC circuits, phasors and impedance
Warm-upHumanIn a circuit in sinusoidal steady state, the current through one element leads the voltage across it by exactly 90°. Which element is it?
3. AC circuits, phasors and impedance
CoreHumanA 60 Ω resistor is in series with an inductor whose reactance at the operating frequency is 80 Ω. The pair is driven by a sinusoidal source of amplitude 10 V. What is the amplitude of the current, in milliamperes?
4. AC circuits, phasors and impedance
CoreHumanA motor on a 230 V RMS supply draws 5 A RMS with a power factor of 0.8 lagging. What reactive power does it draw, in var?
5. AC circuits, phasors and impedance
CoreHumanA factory's load draws 100 kW of real power at a power factor of 0.6 lagging from a 400 V supply. Select all the true statements.
6. AC circuits, phasors and impedance
CoreComputationalSeveral loads share one supply in parallel. Each is described as (P, pf, kind): its real power in watts, its power factor, and "lagging" (inductive) or "leading" (capacitive).
Write total_load(loads, v_rms) returning the tuple (P, Q, S, pf, I): the total real power, the total reactive power (positive when the net load is lagging), the apparent power , the overall power factor, and the RMS supply current.
7. AC circuits, phasors and impedance
StretchComputationalWrite a general AC nodal solver. solve_ac(n, branches, injections) takes the number n of non-ground nodes (numbered 1 to n; node 0 is ground), a list of branches (a, b, Z), each a complex impedance between nodes a and b, and a list of current injections (node, I), each a current phasor driven into a node from ground. Return a complex NumPy array of the n node-voltage phasors.
The tests include the lesson's circuit (with its source already turned into a current source of 0.1 A), a resonant tank, and a check that injections superpose and that an injection into ground is ignored.
Further reading and resources
- The Feynman Lectures on Physics, Volume II, chapter 22: AC Circuits · Richard P. Feynman, Robert B. Leighton and Matthew SandsImpedance and AC circuit analysis, explained from the physics up.
- MIT OpenCourseWare 6.002: Circuits and Electronics · Anant Agarwal · 2007Free lectures and notes, including sinusoidal steady state and impedance.
- IEC: World plugs · International Electrotechnical CommissionThe mains voltage, frequency and plug type in every country.
- North American SynchroPhasor Initiative (NASPI)Utilities and researchers who use time-stamped phasor measurements to monitor the power grid.
- ngspice documentationThe manual of the open-source simulator used for the SPICE check in this lesson, including the .ac analysis.
- Complex quantities and their use in electrical engineering · Charles Proteus Steinmetz · 1893The paper, read at the International Electrical Congress in Chicago, that brought complex numbers into everyday engineering.