w3resource

NumPy: Calculate inverse sine, cosine, and tangent for all elements in a given array

NumPy Mathematics: Exercise-22 with Solution

Write a NumPy program to calculate inverse sine, inverse cosine, and inverse tangent for all elements in a given array.

Sample Solution:-

Python Code:

import numpy as np
x = np.array([-1., 0, 1.])
print("Inverse sine:", np.arcsin(x))
print("Inverse cosine:", np.arccos(x))
print("Inverse tangent:", np.arctan(x))

Sample Output:

Inverse sine: [-1.57079633  0.          1.57079633]
Inverse cosine: [3.14159265 1.57079633 0.        ]
Inverse tangent: [-0.78539816  0.          0.78539816]

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a NumPy program to create a random array with 1000 elements and compute the average, variance, standard deviation of the array elements.

Next: Write a NumPy program to convert angles from radians to degrees for all elements in a given array.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz



Python: Tips of the Day

Getting rid of unwanted characters:

You can get rid of whitespaces or any specific character using strip methods in Python. You can use either plain strip for both sides, lstrip for the left side and rstrip for the right side only.

str="+++Welcome python+++"
str.strip()

print(str)

Output:

+++Welcome python+++