Prerequisites: ch102 (Sine and Cosine), ch100 (Angle Measurement)
Outcomes: Use the unit circle to define trig functions for all angles; Connect to complex numbers via Euler’s formula; Understand rotation as multiplication by e^(iθ)
The Unit Circle¶
The unit circle is the set of all points (x, y) with x² + y² = 1.
Every point on it can be written as (cos θ, sin θ) for angle θ. This provides a clean definition of sin and cos for any angle — not just acute angles in triangles.
Euler’s formula: e^(iθ) = cos θ + i sin θ
This is perhaps the most beautiful equation in mathematics:
e^(iπ) + 1 = 0 — the five most important constants in one equation
It connects exponential functions to rotation
Rotation by angle θ = multiplication by e^(iθ) in the complex plane
Rotation using complex multiplication: To rotate point (x, y) by angle θ:
Represent as complex number z = x + iy
Multiply by e^(iθ) = cos θ + i sin θ
Result: (x cos θ - y sin θ) + i(x sin θ + y cos θ)
This is exactly the 2D rotation matrix operation (ch109).
# --- Unit circle and Euler's formula ---
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-v0_8-whitegrid')
fig, axes = plt.subplots(1, 2, figsize=(13, 5))
# Full unit circle with quadrant info
theta = np.linspace(0, 2*np.pi, 300)
ax = axes[0]
ax.plot(np.cos(theta), np.sin(theta), 'steelblue', lw=1.5)
key_angles = np.arange(0, 360, 30)
for deg in key_angles:
rad = np.radians(deg)
ax.plot(np.cos(rad), np.sin(rad), 'o', color='crimson', markersize=6)
label = f'({np.cos(rad):.2f},{np.sin(rad):.2f})'
ax.annotate(f'{deg}°', (np.cos(rad)*1.25, np.sin(rad)*1.25),
ha='center', va='center', fontsize=7)
ax.axhline(0, color='k', linewidth=0.4); ax.axvline(0, color='k', linewidth=0.4)
ax.set_aspect('equal'); ax.set_xlim(-1.6,1.6); ax.set_ylim(-1.6,1.6)
ax.set_title('Unit Circle with Key Angles')
# Euler's formula: e^(iθ) traces the unit circle
theta_vals = np.linspace(0, 4*np.pi, 300)
spiral = np.exp(1j * theta_vals) # e^(iθ) for varying θ
ax2 = axes[1]
ax2.plot(spiral.real, spiral.imag, 'steelblue', lw=1.5)
# Show e^(iθ) for specific θ values
for theta_demo in [0, np.pi/3, np.pi/2, np.pi, 3*np.pi/2]:
z = np.exp(1j * theta_demo)
ax2.plot(z.real, z.imag, 'ro', markersize=8)
ax2.plot([0, z.real], [0, z.imag], 'r-', lw=1, alpha=0.5)
ax2.annotate(f'e^(i·{theta_demo/np.pi:.1f}π)', (z.real, z.imag),
xytext=(5,5), textcoords='offset points', fontsize=8)
ax2.axhline(0, color='k', linewidth=0.4); ax2.axvline(0, color='k', linewidth=0.4)
ax2.set_aspect('equal'); ax2.set_xlim(-1.5,1.5); ax2.set_ylim(-1.5,1.5)
ax2.set_xlabel('Real'); ax2.set_ylabel('Imaginary')
ax2.set_title("Euler's Formula: e^(iθ) on the Complex Plane")
plt.suptitle("The Unit Circle and Euler's Formula", fontsize=12, fontweight='bold')
plt.tight_layout(); plt.show()
# Verify Euler's formula numerically
theta_test = np.pi/3
z = np.exp(1j * theta_test)
print(f"e^(i·π/3) = {z:.6f}")
print(f"cos(π/3) + i·sin(π/3) = {np.cos(theta_test):.6f} + {np.sin(theta_test):.6f}i")
print(f"Match: {np.isclose(z, np.cos(theta_test) + 1j*np.sin(theta_test))}")
e^(i·π/3) = 0.500000+0.866025j
cos(π/3) + i·sin(π/3) = 0.500000 + 0.866025i
Match: True
Summary¶
Unit circle: (cos θ, sin θ) for all angles — the geometric definition of trig functions
Euler’s formula: e^(iθ) = cos θ + i sin θ — the most compact rotation formula
Complex multiplication = rotation + scaling
2D rotation matrix (ch109) is the Cartesian form of complex multiplication
Forward: ch109 derives the rotation matrix from this; ch176 uses complex numbers in DFT/FFT.