Trusted answers to developer questions

Rukhshan Haroon

In mathematics, the inverse of the trigonometric ratio sine is known as **arcsin**.

In NumPy, a library of the high-level programming language Python, we can use the ** arcsin** function to calculate the

`arcsin`

of a given value.The `numpy`

library must be imported to use the `arcsin`

function:

```
import numpy as np
```

```
np.arcsin(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])= <ufunc 'arcsin'>
```

A universal function (

`ufunc`

) is a function that operates on ndarrays in an element-by-element fashion. The`arcsin`

method is a universal function.

The `arcsin`

function only accepts the following arguments:

: An array-like structure on the contents of which the`x`

`arcsin`

function will be applied.(optional): The function’s output is stored at this location.`out`

(optional): If set`where`

`True`

, a universal function is calculated at this position.(optional): This enables the user to decide how the data will be cast. If set as`casting`

*same_kind*, safe casting will take place.(optional): This determines the memory layout of the output. For example, if set as K, the function reads data in the order they are written in memory.`order`

(optional): This is the data type of the array.`dtype`

(optional): To pass subclasses,`subok`

`subok`

must be set as`True`

.

For real valued inputs, the `arcsin`

function returns an angle in the range `[-pi/2, pi/2]`

. For complex numbers, the range is `[-inf, -1]`

and `[1, inf]`

.

If a number can not be represented as a real number or infinity, it returns `nan`

, and the invalid floating point error flag is set.

Note that the range of the

`sine`

function is −1 ≤ sin x ≤ 1. Hence, any input out of this range will be treated as invalid by the`arcsin`

function. Since`arcsin`

is the inverse of sine, the range of sine is the domain of`arcsin`

!

The following example demonstrates how the `arcsin`

function responds to complex, real, or invalid inputs.

To use the `arcsin`

function, we first import the `numpy`

library, which contains it.

import numpy as np print("Complex input:", np.arcsin(3+2j)) print("Invalid input:", np.arcsin(5)) print("Real input:", np.arcsin(.5))

RELATED TAGS

python

numpy

CONTRIBUTOR

Rukhshan Haroon

Copyright ©2022 Educative, Inc. All rights reserved

RELATED COURSES

View all Courses

Keep Exploring

Related Courses