acos#
- ivy.acos(x, /, *, out=None)[source]#
Calculate an implementation-dependent approximation of the principal value of the inverse cosine, having domain [-1, +1] and codomain [+0, +π], for each element x_i of the input array x. Each element-wise result is expressed in radians.
Special cases
For floating-point operands,
If x_i is NaN, the result is NaN.
If x_i is greater than 1, the result is NaN.
If x_i is less than -1, the result is NaN.
If x_i is 1, the result is +0.
- Parameters:
- Return type:
- Returns:
ret – an array containing the inverse cosine 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 # noqa 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([0., 1., -1.]) >>> y = ivy.acos(x) >>> print(y) ivy.array([1.57, 0. , 3.14])
>>> x = ivy.array([1., 0., -1.]) >>> y = ivy.zeros(3) >>> ivy.acos(x, out=y) >>> print(y) ivy.array([0. , 1.57, 3.14])
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([0., -1, 1]), b=ivy.array([1., 0., -1])) >>> y = ivy.acos(x) >>> print(y) { a: ivy.array([1.57, 3.14, 0.]), b: ivy.array([0., 1.57, 3.14]) }
- Array.acos(self, *, out=None)#
ivy.Array instance method variant of ivy.acos. This method simply wraps the function, and so the docstring for ivy.acos 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
]) – optional output array, for writing the result to. It must have a shape that (default:None
) the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing the inverse cosine of each element in
self
. The returned array must have the same data type asself
.
Examples
>>> x = ivy.array([1.0, 0.0, -0.9]) >>> y = x.acos() >>> print(y) ivy.array([0. , 1.57, 2.69])
- Container.acos(self, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)#
ivy.Container instance method variant of ivy.acos. This method simply wraps the function, and so the docstring for ivy.acos 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
]]]) – The key-chains to apply or not apply the method to. Default isNone
. (default:None
)to_apply (
bool
) – If True, the method will be applied to key_chains, otherwise key_chains (default:True
) will be skipped. Default isTrue
.prune_unapplied (
bool
) – Whether to prune key_chains for which the function was not applied. (default:False
) Default isFalse
.map_sequences (
bool
) – Whether to also map method to sequences (lists, tuples). (default:False
) Default isFalse
.out (
Optional
[Container
]) – optional output container, for writing the result to. It must have a shape (default:None
) that the inputs broadcast to.
- Return type:
Container
- Returns:
ret – a container containing the inverse cosine 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., -1, 1]), b=ivy.array([1., 0., -1.])) >>> y = x.acos() >>> print(y) { a: ivy.array([1.57, 3.14, 0.]), b: ivy.array([0., 1.57, 3.14]) }