Curriculum
Course: NumPy
Login

Curriculum

NumPy

Text lesson

Finding Angles

Finding angles from sine, cosine, or tangent values involves using inverse functions like arcsin, arccos, and arctan. NumPy provides the ufuncs arcsin(), arccos(), and arctan() to return angle values in radians for the given sine, cosine, or tangent values.

Example

Determine the angle corresponding to 1.0.

import numpy as np

x = np.arcsin(1.0)

print(x)

Angles of Each Value in Arrays

Example

Calculate the angle for all sine values in the array.

import numpy as np

arr = np.array([1, –10.1])

x = np.arcsin(arr)

print(x)

Hypotenues

Finding the hypotenuse using the Pythagorean theorem in NumPy can be done with the hypot() function, which takes the base and height values to calculate the hypotenuse.

Example

Calculate the hypotenuse for a base of 4 and a perpendicular of 3.

import numpy as np

base = 3
perp = 4

x = np.hypot(base, perp)

print(x)