Convert between degrees and radians in code and compute sine, cosine and tangent for any angle. Then draw the unit circle, plot the graphs of the trigonometric functions, and test identities on thousands of angles at once.
3 lessons, about 1 h 40 min3 simulations11 problems3 practice questionsPython in every lesson
Python measures angles in radians, so degrees must be converted with math.radians. The unit circle shows that the point at an angle is (cos, sin), which fixes the signs in every quadrant. A loop builds the table of the six ratios, and a tolerance, not ==, compares the answers, since sin(pi) is not exactly zero.
A table lists a few angles, and a graph shows all of them. np.linspace makes the angles, np.sin works on the whole array, and plt.plot draws the curve. The wave has amplitude , period and phase shift . Tangent has asymptotes, so its huge values are replaced by nan before plotting.
An identity is an equation that is true for every angle. A program cannot try every angle, but it can try thousands at once. np.allclose tests whole arrays within a tolerance, np.max of the absolute difference shows the worst miss, and np.argmax finds a counterexample. One failure proves an identity false, and many passes make it very likely true.
Log in to join the discussion.
Loading…