5.5. Trigonometry#

In addition to arithmetical operators, NumPy provides lots of essential functions and constants to perform trigonometrical operations:

In all trigonometric functions, angles are in radians by default. You can either convert to/from degrees by multiplying or dividing by \(\pi/180\) manually, or use np.deg2rad and np.rad2deg.

import numpy as np
import matplotlib.pyplot as plt

angle = np.linspace(0, 2 * np.pi, 100)

plt.plot(angle, np.sin(angle));
_images/e1814792a2ab871c272cbd92c861ce1b1398c37b719b2659ab606b91159aab6a.png