Thanks to unicode, we may use Greek letters directly in our code.

In this Jupyter Notebook, lets use θ (theta), π (pi) and τ (tau) with τ = 2 * π.

Then we'll plot the graph of Euler's Formula, e to the i θ over the range 0 to τ.

In Python we signify i, the root of -1, as 1j for readability, so lets bind i to 1j as well.


In [69]:
from math import e, pi as π
τ = 2 * π
i = 1j
result = e ** (i * τ)
print ("{:1.5f}".format(result.real))


1.00000

Below we import some industrial grade tools used for plotting with Python. The same greek letter names remain active and guide the construction of a domain t and range s. Then we label the graph and generate a picture. plt.show(), if used, produces a plot in its own window.


In [71]:
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0.0, τ, 0.01)
s = np.array([(np.e ** (i * θ)).real for θ in t])
plt.plot(t, s)
plt.xlabel('radians')
plt.ylabel('real part')
plt.title('Euler\'s Formula from 0 to tau')
plt.grid(True)
plt.savefig("euler_test.png") # uploaded to Flickr for display below