1---
2app_version: 0.7.0
3precision: 3
4---
5# AC Impedance & Phase
6// "What's the impedance of my circuit, and how far behind is the current?"
7// Complex numbers carry magnitude and phase together — no separate lookup.
8
9defunit("V")
10defunit("A")
11defunit("Ohm", "V/A")
12
13# Measured phasors
14// Mains voltage as the phase reference (0°), and the current you measured —
15// it lags behind the voltage because the load is inductive.
16U = 230 V
17I = 1.8 - 1.3i A
18
19# Impedance
20// Division of two unit-carrying quantities derives the unit automatically,
21// same as for real numbers: V / A → Ohm.
22Z = U / I
23
24"Impedance Z": Z
25"Magnitude |Z| (Ω)": abs(Z)
26"Phase angle": arg(Z) in deg
27"Resistive part R (Ω)": re(Z)
28"Reactive part X (Ω)": im(Z)
29
30# Add a series element
31// The feed cable and connector add a small stray impedance in series —
32// impedances in series just add, real and imaginary parts together.
33Z_cable = 2 + 1i Ohm
34Z_total = Z + Z_cable
35
36"Total impedance incl. cable": Z_total
37"Total magnitude (Ω)": abs(Z_total)
38
39# Power
40// S = U · I* splits cleanly into real (working) and reactive power.
41S = U * conj(I)
42
43"Apparent power |S| (VA)": abs(S)
44"Real power P (W)": re(S)
45"Reactive power Q (var)": im(S)
46"Power factor": cos(arg(Z))
47