asin#
- ivy.asin(x, /, *, out=None)[source]#
Calculate an implementation-dependent approximation of the principal value of the inverse sine, having domain
[-1, +1]
and codomain[-π/2, +π/2]
for each elementx_i
of the input arrayx
. Each element- wise result is expressed in radians.Special cases
For floating-point operands,
If
x_i
isNaN
, the result isNaN
.If
x_i
is greater than1
, the result isNaN
.If
x_i
is less than-1
, the result isNaN
.If
x_i
is+0
, the result is+0
.If
x_i
is-0
, the result is-0
.
For complex floating-point operands, special cases must be handled as if the operation is implemented as
-1j * asinh(x * 1j)
.- Parameters:
- Return type:
- Returns:
ret – an array containing the inverse sine of each element in
x
. The returned array must have a floating-point data type determined by type-promotion.
This function conforms to the Array API Standard. This docstring is an extension of the docstring in the standard.
Both the description and the type hints above assumes an array input for simplicity, but this function is nestable, and therefore also accepts
ivy.Container
instances in place of any of the argumentsExamples
With
ivy.Array
input:>>> x = ivy.array([-2.4, -0, +0, 3.2, float('nan')]) >>> y = ivy.asin(x) >>> print(y) ivy.array([nan, 0., 0., nan, nan])
>>> x = ivy.array([-1, -0.5, 0.6, 1]) >>> y = ivy.zeros(4) >>> ivy.asin(x, out=y) >>> print(y) ivy.array([-1.57,-0.524,0.644,1.57])
>>> x = ivy.array([[0.1, 0.2, 0.3],[-0.4, -0.5, -0.6]]) >>> ivy.asin(x, out=x) >>> print(x) ivy.array([[0.1,0.201,0.305],[-0.412,-0.524,-0.644]])
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([0., 0.1, 0.2]), ... b=ivy.array([0.3, 0.4, 0.5])) >>> y = ivy.asin(x) >>> print(y) {a:ivy.array([0.,0.1,0.201]),b:ivy.array([0.305,0.412,0.524])}
- Array.asin(self, *, out=None)[source]#
ivy.Array instance method variant of ivy.asin. This method simply wraps the function, and so the docstring for ivy.asin also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array. Should have a real-valued floating-point data type.out (
Optional
[Array
], default:None
) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing the inverse sine of each element in
self
. The returned array must have the same data type asself
.
Examples
Using
ivy.Array
instance method:>>> x = ivy.array([-1., 1., 4., 0.8]) >>> y = x.asin() >>> print(y) ivy.array([-1.57, 1.57, nan, 0.927])
>>> x = ivy.array([-3., -0.9, 1.5, 2.8]) >>> y = ivy.zeros(4) >>> x.asin(out=y) >>> print(y) ivy.array([nan, -1.12, nan, nan])
- Container.asin(self, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
ivy.Container instance method variant of ivy.asin. This method simply wraps the function, and so the docstring for ivy.asin also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input container. Should have a real-valued floating-point data type.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.out (
Optional
[Container
], default:None
) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.
- Return type:
Container
- Returns:
ret – a container containing the inverse sine of each element in
self
. The returned container must have a floating-point data type determined by type-promotion.
Examples
>>> x = ivy.Container(a=ivy.array([0., 0.5, 1.]), ... b=ivy.array([-4., 0.8, 2.])) >>> y = x.asin() >>> print(y) { a: ivy.array([0., 0.524, 1.57]), b: ivy.array([nan, 0.927, nan]) }
>>> x = ivy.Container(a=ivy.array([12., 1.5, 0.]), ... b=ivy.array([-0.85, 0.6, 0.3])) >>> y = ivy.Container(a=ivy.zeros(3), b=ivy.zeros(3)) >>> x.asin(out=y) >>> print(y) { a: ivy.array([nan, nan, 0.]), b: ivy.array([-1.02, 0.644, 0.305]) }