Time Domain (hard)
Differential equation:
Requires solving an ODE for every circuit.
“Imaginary” is a terrible name. It was coined in the 17th century as an insult, and we have been stuck with it ever since. There is nothing imaginary about these numbers. They describe rotation. Once you see that, the mystery evaporates and one of the most powerful tools in engineering opens up. #ComplexNumbers #Phasors #Engineering
The number
If you think of this as “the square root of negative one,” it sounds absurd. What number, multiplied by itself, gives a negative result? No real number does. That is why mathematicians called these numbers “imaginary” and moved on.
But here is a better way to think about it. Multiplying by
j (imaginary axis) | | j | -1 -----+------ 1 (real axis) | | -j |Multiplying by
A complex number
Im | b ...+.........* z = a + jb | /| | / | | r / | | / | | / θ | | / | -----+--/------+------ Re | aThe same point can be described in polar form:
where:
This should remind you of vectors. A complex number IS a 2D vector, just written in a notation that makes multiplication and rotation trivially easy.
The rectangular form
Addition (rectangular):
Just add the components, exactly like vector addition.
Multiplication (polar):
Multiply the magnitudes, add the angles. Multiplication in the complex plane is rotation and scaling. This is the key insight that makes phasors work.
The bridge between trigonometry and complex exponentials is Euler’s formula:
This single equation connects three seemingly different branches of mathematics: exponentials, trigonometry, and complex numbers. It is, arguably, the most important formula in engineering mathematics.
Consider the Taylor series for
If you substitute
Setting
Five fundamental constants (
Here is the payoff. Consider a sinusoidal voltage:
Using Euler’s formula, we can write this as the real part of a complex exponential:
The factor
This is the phasor representation of the voltage. It captures the amplitude
Im | | * V_m e^(jφ) | / | / V_m |/ φ -----+------------- Re |
The phasor is a snapshot of the rotating vector. At any time t, the actual voltage is the real part of this vector after it has rotated by ωt more.Without phasors, analyzing an AC circuit means solving differential equations. With phasors, the same analysis becomes algebra. Differentiation becomes multiplication by
Time Domain (hard)
Differential equation:
Requires solving an ODE for every circuit.
Phasor Domain (easy)
Algebraic equation:
Just multiply complex numbers.
In DC circuits, Ohm’s law is
where
The impedance of a resistor is just its resistance. It is purely real. Voltage and current are in phase (no phase shift).
The impedance of an inductor is purely imaginary and proportional to frequency. At high frequencies, an inductor acts like an open circuit. The
The impedance of a capacitor is purely imaginary and inversely proportional to frequency. At high frequencies, a capacitor acts like a short circuit. The
Impedances combine exactly like resistances:
Your phone charger converts AC from the wall outlet to DC for the battery. The efficiency of that conversion depends on impedance matching between the transformer windings, which is calculated using complex numbers. A mismatch means wasted power and heat.
Audio equalizers also rely on this math. When you boost the bass or cut the treble on your phone, the equalizer is adjusting the gain at different frequencies using complex transfer functions, exactly like the RC filter analysis below.
This is why phasors were invented. You can analyze any AC circuit using the same rules you learned for DC circuits, just with complex numbers instead of real ones.
Let us analyze the most common filter in electronics: the RC low-pass filter.
R Vin o---/\/\/---+--- o Vout | === C | GND o-----------+--- o GNDWe want to find the ratio
The resistor and capacitor are in series, forming a voltage divider. The output is taken across the capacitor.
Multiply numerator and denominator by
The magnitude of the transfer function (gain) is:
The phase is:
The cutoff frequency is defined as the frequency where the output power drops to half (or the voltage drops to
This happens when
For
Signals below 1592 Hz pass through mostly unchanged. Signals above 1592 Hz are attenuated. That is why it is called a low-pass filter.
Python has native support for complex numbers, and NumPy extends this to arrays.
import numpy as npimport matplotlib.pyplot as plt
# --- Complex number basics ---z1 = 3 + 4jz2 = 1 - 2j
print(f"z1 = {z1}")print(f"z2 = {z2}")print(f"z1 + z2 = {z1 + z2}")print(f"z1 * z2 = {z1 * z2}")print(f"|z1| = {abs(z1):.3f}")print(f"angle(z1) = {np.angle(z1, deg=True):.1f} degrees")print(f"Real part: {z1.real}, Imaginary part: {z1.imag}")
# --- Euler's formula verification ---theta = np.pi / 4 # 45 degreeseuler = np.exp(1j * theta)trig = np.cos(theta) + 1j * np.sin(theta)print(f"\ne^(j*pi/4) = {euler:.4f}")print(f"cos + j*sin = {trig:.4f}")print(f"Difference: {abs(euler - trig):.2e}")import numpy as npimport matplotlib.pyplot as plt
# Component valuesR = 10e3 # 10 kohmC = 10e-9 # 10 nF
# Cutoff frequencyf_c = 1 / (2 * np.pi * R * C)print(f"Cutoff frequency: {f_c:.1f} Hz")
# Frequency sweep (logarithmic)f = np.logspace(1, 6, 500) # 10 Hz to 1 MHzomega = 2 * np.pi * f
# Transfer function H(jw) = 1 / (1 + jwRC)H = 1 / (1 + 1j * omega * R * C)
# Magnitude in dB and phase in degreesmagnitude_dB = 20 * np.log10(np.abs(H))phase_deg = np.angle(H, deg=True)
# Bode plotfig, (ax1, ax2) = plt.subplots(2, 1, figsize=(9, 7), sharex=True)
ax1.semilogx(f, magnitude_dB, 'b-', linewidth=2)ax1.axhline(y=-3, color='r', linestyle='--', alpha=0.7, label='-3 dB')ax1.axvline(x=f_c, color='gray', linestyle=':', alpha=0.7, label=f'fc = {f_c:.0f} Hz')ax1.set_ylabel('Magnitude (dB)')ax1.set_title('RC Low-Pass Filter Bode Plot')ax1.legend()ax1.grid(True, which='both', alpha=0.3)ax1.set_ylim(-40, 5)
ax2.semilogx(f, phase_deg, 'b-', linewidth=2)ax2.axhline(y=-45, color='r', linestyle='--', alpha=0.7, label='-45 deg at fc')ax2.axvline(x=f_c, color='gray', linestyle=':', alpha=0.7)ax2.set_ylabel('Phase (degrees)')ax2.set_xlabel('Frequency (Hz)')ax2.legend()ax2.grid(True, which='both', alpha=0.3)ax2.set_ylim(-100, 10)
plt.tight_layout()plt.show()import numpy as npimport matplotlib.pyplot as plt
# Three phasors: voltage source, resistor voltage, capacitor voltage# At the cutoff frequency (wRC = 1)V_in = 1 + 0j # Reference: 1V at 0 degreesH_c = 1 / (1 + 1j) # Capacitor voltage / V_in at wRC=1V_C = V_in * H_c # Capacitor voltage phasorV_R = V_in - V_C # Resistor voltage phasor
phasors = {'V_in': V_in, 'V_R': V_R, 'V_C': V_C}colors = {'V_in': 'blue', 'V_R': 'red', 'V_C': 'green'}
fig, ax = plt.subplots(figsize=(7, 7))for name, z in phasors.items(): ax.annotate('', xy=(z.real, z.imag), xytext=(0, 0), arrowprops=dict(arrowstyle='->', color=colors[name], lw=2)) ax.text(z.real * 1.1, z.imag * 1.1 + 0.03, f'{name} = {abs(z):.3f} at {np.angle(z, deg=True):.1f} deg', color=colors[name], fontsize=10)
ax.set_xlim(-0.2, 1.2)ax.set_ylim(-0.8, 0.4)ax.set_aspect('equal')ax.grid(True, alpha=0.3)ax.axhline(y=0, color='k', linewidth=0.5)ax.axvline(x=0, color='k', linewidth=0.5)ax.set_xlabel('Real')ax.set_ylabel('Imaginary')ax.set_title('Phasor Diagram at Cutoff Frequency (wRC = 1)')plt.tight_layout()plt.show()j vs i
Electrical engineers use 1j. MATLAB uses both i and j. Be consistent in your notation and do not use
Degrees vs Radians
NumPy’s np.angle() returns radians by default. Use np.angle(z, deg=True) for degrees. Trigonometric functions (np.sin, np.cos) always expect radians. Mixing these up is one of the most common bugs in engineering code.
Conjugate Symmetry
For real-valued signals, the Fourier transform has conjugate symmetry:
Complex numbers are not abstract curiosities. They are the natural language for describing anything that rotates or oscillates. Here is the chain of ideas:
Complex numbers are 2D numbers. They have a real part and an imaginary part, forming a point (or arrow) in the complex plane.
Multiplication is rotation and scaling. Multiplying by
Euler’s formula connects exponentials and trigonometry.
Phasors strip away time. A phasor captures the amplitude and phase of a sinusoidal signal, letting you analyze AC circuits with algebra instead of differential equations.
Impedance generalizes resistance. Resistors, inductors, and capacitors each have a complex impedance. Circuit analysis proceeds with the same rules as DC, just with complex arithmetic.
The cutoff frequency falls out naturally. For an RC filter, setting
In the next lesson on differential equations, you will see complex numbers appear again: the solutions to second-order ODEs involve complex exponentials, and the imaginary part of the eigenvalue gives the oscillation frequency while the real part gives the decay rate.
Comments