Skip to content

Complex Numbers

Complex numbers are fundamental to signal processing. They provide an elegant way to represent and manipulate sinusoidal signals, analyze frequency content, and describe system behavior.

The Imaginary Unit

Definition

The imaginary unit j (often denoted i in mathematics) is defined as:

j=1,thusj2=1

Properties

Powers of j cycle with period 4:

j0=1,j1=j,j2=1,j3=j,j4=1,

Python Implementation

python
import numpy as np

# In Python/NumPy, the imaginary unit is 1j
j = 1j

print(f"j = {j}")
print(f"j² = {j**2}")
print(f"j³ = {j**3}")
print(f"j⁴ = {j**4}")

Rectangular Form

Definition

A complex number z in rectangular (Cartesian) form is:

z=x+jy

where:

  • x=Re(z) is the real part
  • y=Im(z) is the imaginary part

The Complex Plane

Complex numbers are visualized on the complex plane (Argand diagram), where the horizontal axis represents the real part and the vertical axis represents the imaginary part.

Complex plane

Properties

Equality: Two complex numbers are equal if and only if their real and imaginary parts are equal:

z1=z2Re(z1)=Re(z2) and Im(z1)=Im(z2)

Complex Conjugate: The complex conjugate of z=x+jy is:

z=z¯=xjy

Python Implementation

python
import numpy as np

# Define a complex number
z = 3 + 4j

# Extract real and imaginary parts
print(f"z = {z}")
print(f"Real part: Re(z) = {z.real}")
print(f"Imaginary part: Im(z) = {z.imag}")
print(f"Complex conjugate: z* = {np.conj(z)}")

# Verify: z * z* = |z|²
print(f"z × z* = {z * np.conj(z)} = |z|² = {abs(z)**2}")

Polar Form

Definition

A complex number can also be expressed in polar form:

z=r(cosθ+jsinθ)

where:

  • r=|z|=x2+y2 is the magnitude (or modulus)
  • θ=z=arctan(y/x) is the phase (or argument)

Properties

Conversion from Rectangular:

r=x2+y2,θ=arctan(yx)

(Note: Use atan2(y, x) in code to handle all quadrants correctly)

Conversion to Rectangular:

x=rcosθ,y=rsinθ

Python Implementation

python
import numpy as np

z = 3 + 4j

# Magnitude and phase
r = np.abs(z)
theta = np.angle(z)  # in radians

print(f"z = {z}")
print(f"Magnitude: |z| = {r}")
print(f"Phase: θ = {theta:.4f} rad = {np.degrees(theta):.2f}°")

# Convert back to rectangular
x = r * np.cos(theta)
y = r * np.sin(theta)
z_reconstructed = x + 1j * y
print(f"Reconstructed: z = {z_reconstructed}")

Exponential Form and Euler's Formula

Euler's Formula

Euler's formula is one of the most important results in mathematics:

ejθ=cosθ+jsinθ

Euler's formula visualization

Properties

From Euler's formula, we can derive:

Cosine and Sine as Exponentials:

cosθ=ejθ+ejθ2sinθ=ejθejθ2j

Exponential Form of Complex Numbers:

z=rejθ

This combines magnitude and phase into a compact notation.

Python Implementation

python
import numpy as np
import matplotlib.pyplot as plt

# Verify Euler's formula
theta = np.pi / 4  # 45 degrees

euler_lhs = np.exp(1j * theta)
euler_rhs = np.cos(theta) + 1j * np.sin(theta)

print(f"e^(jθ) = {euler_lhs}")
print(f"cos(θ) + j·sin(θ) = {euler_rhs}")
print(f"Difference: {abs(euler_lhs - euler_rhs):.2e}")

# Express z = 3 + 4j in exponential form
z = 3 + 4j
r = np.abs(z)
theta = np.angle(z)
z_exp = r * np.exp(1j * theta)

print(f"\nz = {z}")
print(f"z = {r:.4f} × e^(j × {theta:.4f})")
print(f"Verification: {z_exp}")

Complex Arithmetic

Addition and Subtraction

Add/subtract real and imaginary parts separately:

(a+jb)+(c+jd)=(a+c)+j(b+d)(a+jb)(c+jd)=(ac)+j(bd)

Multiplication

In rectangular form:

(a+jb)(c+jd)=(acbd)+j(ad+bc)

In polar/exponential form (more elegant):

r1ejθ1r2ejθ2=r1r2ej(θ1+θ2)

Magnitudes multiply, phases add.

Division

In rectangular form:

a+jbc+jd=(a+jb)(cjd)(c+jd)(cjd)=(ac+bd)+j(bcad)c2+d2

In polar/exponential form:

r1ejθ1r2ejθ2=r1r2ej(θ1θ2)

Magnitudes divide, phases subtract.

Python Implementation

python
import numpy as np

z1 = 3 + 4j
z2 = 1 + 2j

# Basic operations
print(f"z1 = {z1}")
print(f"z2 = {z2}")
print(f"z1 + z2 = {z1 + z2}")
print(f"z1 - z2 = {z1 - z2}")
print(f"z1 × z2 = {z1 * z2}")
print(f"z1 / z2 = {z1 / z2}")

# Verify multiplication rule: |z1 × z2| = |z1| × |z2|
print(f"\n|z1 × z2| = {np.abs(z1 * z2):.4f}")
print(f"|z1| × |z2| = {np.abs(z1) * np.abs(z2):.4f}")

# Verify: angle(z1 × z2) = angle(z1) + angle(z2)
print(f"\nangle(z1 × z2) = {np.angle(z1 * z2):.4f}")
print(f"angle(z1) + angle(z2) = {np.angle(z1) + np.angle(z2):.4f}")

Complex Exponentials and Rotation

The Unit Circle

The complex exponential ejθ traces the unit circle as θ varies:

|ejθ|=1for all θ

Complex exponential rotation

Properties

Rotating Phasor: ejωt represents a point rotating counterclockwise on the unit circle with angular velocity ω.

Periodicity:

ej(θ+2π)=ejθ

De Moivre's Theorem:

(ejθ)n=ejnθ=cos(nθ)+jsin(nθ)

Python Implementation

python
import numpy as np
import matplotlib.pyplot as plt

# e^(jωt) traces the unit circle
t = np.linspace(0, 2*np.pi, 100)
omega = 1
z = np.exp(1j * omega * t)

plt.figure(figsize=(10, 5))

# Left: trajectory in complex plane
plt.subplot(1, 2, 1)
plt.plot(np.real(z), np.imag(z), 'b-', linewidth=2)
plt.plot(1, 0, 'ro', markersize=10, label='Start (t=0)')
plt.xlabel('Real')
plt.ylabel('Imaginary')
plt.title(r'$e^{j\omega t}$ on Complex Plane')
plt.axis('equal')
plt.grid(True)
plt.legend()

# Right: real and imaginary parts vs time
plt.subplot(1, 2, 2)
plt.plot(t, np.real(z), 'b-', linewidth=2, label=r'$\cos(\omega t)$')
plt.plot(t, np.imag(z), 'r--', linewidth=2, label=r'$\sin(\omega t)$')
plt.xlabel('t')
plt.ylabel('Amplitude')
plt.title(r'Components of $e^{j\omega t}$')
plt.legend()
plt.grid(True)

plt.tight_layout()
plt.show()

Key Formulas

FormulaExpression
Euler's formulaejθ=cosθ+jsinθ
Magnitude|z|=x2+y2=zz
Phasez=arctan(y/x)
Conjugate(x+jy)=xjy
Cosinecosθ=ejθ+ejθ2
Sinesinθ=ejθejθ2j