NumPy ufuncLesson 42Free preview
ufunc Trigonometric
This lesson is part of NumPy · All levels
Summary
NumPy provides trigonometric functions such as np.sin, np.cos, and np.tan that work element-wise on an array. The input must be in units of radian; use np.degrees() to convert radian to degrees and np.radians() to the contrary. The function np.hypot is also available to calculate the length of the hypotenuse.
Key points
- Sin, cos, tan accept angles in radians, not degrees.
- Np.degrees() converts radians to degrees, np.radians() the reverse.
- Np.hypot count sqrt(x^2 + y^2) for the elbow triangle.
- All of them are element-wise so fast for many angles.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.