Note
Go to the end to download the full example code or to run this example in your browser via JupyterLite.
Euler’s formula: e^{i theta} = cos theta + i sin theta#
Euler’s 1748 formula wraps the real line around the unit circle: \(e^{i\theta}\) is the point at angle \(\theta\), and \(e^{i\pi} + 1 = 0\). The domain coloring of \(e^z\) shows the consequence for the whole plane: the hue (phase) depends only on \(\operatorname{Im} z\), so \(e^z\) repeats every \(2\pi i\).
import matplotlib.pyplot as plt
import numpy as np
from mathematicskit.complex_analysis import circle_contour, domain_coloring
from mathematicskit.complex_analysis.visualizers import plot_domain_coloring
e^{i theta} traces the unit circle#
theta = np.linspace(0, 2 * np.pi, 9)
unit_circle = circle_contour(0.0, 1.0)
print("max |e^{i theta} - (cos theta + i sin theta)| =", np.max(np.abs(np.exp(1j * theta) - (np.cos(theta) + 1j * np.sin(theta)))))
print("e^{i pi} + 1 =", np.exp(1j * np.pi) + 1)
fig, ax = plt.subplots()
circle = unit_circle.points()
ax.plot(circle.real, circle.imag, "C0")
for t in theta[:-1]:
w = np.exp(1j * t)
ax.plot([0, w.real], [0, w.imag], "C1", lw=0.8)
ax.annotate(rf"$\theta={t / np.pi:.2g}\pi$", (w.real, w.imag), textcoords="offset points", xytext=(5, 5), fontsize=8)
ax.set_aspect("equal")
ax.set_title(r"$e^{i\theta} = \cos\theta + i\sin\theta$")

max |e^{i theta} - (cos theta + i sin theta)| = 0.0
e^{i pi} + 1 = 1.2246467991473532e-16j
Text(0.5, 1.0, '$e^{i\\theta} = \\cos\\theta + i\\sin\\theta$')
e^z is periodic with period 2 pi i#

e^{z + 2 pi i} == e^z: True
Total running time of the script: (0 minutes 0.250 seconds)