tan#
- ivy.tan(x, /, *, out=None)[source]#
Calculate an implementation-dependent approximation to the tangent, having domain
(-infinity, +infinity)
and codomain(-infinity, +infinity)
, for each elementx_i
of the input arrayx
. Each elementx_i
is assumed to be expressed in radians.Special cases
For floating-point operands,
If
x_i
isNaN
, the result isNaN
.If
x_i
is+0
, the result is+0
.If
x_i
is-0
, the result is-0
.If
x_i
is either+infinity
or-infinity
, the result isNaN
.
- Parameters:
- Return type:
- Returns:
ret – an array containing the tangent of each element in
x
. The return 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 arguments.Examples
With
ivy.Array
input:>>> x = ivy.array([0., 1., 2.]) >>> y = ivy.tan(x) >>> print(y) ivy.array([0., 1.56, -2.19])
>>> x = ivy.array([0.5, -0.7, 2.4]) >>> y = ivy.zeros(3) >>> ivy.tan(x, out=y) >>> print(y) ivy.array([0.546, -0.842, -0.916])
>>> x = ivy.array([[1.1, 2.2, 3.3], ... [-4.4, -5.5, -6.6]]) >>> ivy.tan(x, out=x) >>> print(x) ivy.array([[1.96, -1.37, 0.16], [-3.1, 0.996, -0.328]])
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([3., 4., 5.])) >>> y = ivy.tan(x) >>> print(y) { a: ivy.array([0., 1.56, -2.19]), b: ivy.array([-0.143, 1.16, -3.38]) }
- Array.tan(self, *, out=None)#
ivy.Array instance method variant of ivy.tan. This method simply wraps the function, and so the docstring for ivy.tan also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array whose elements are expressed in radians. Should have a floating-point data type.out (
Optional
[Array
]) – optional output, for writing the result to. It must have a shape that the (default:None
) inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing the tangent of each element in
self
. The return must have a floating-point data type determined by type-promotion.
Examples
>>> x = ivy.array([0., 1., 2.]) >>> y = x.tan() >>> print(y) ivy.array([0., 1.56, -2.19])
- Container.tan(self, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)#
ivy.Container instance method variant of ivy.tan. This method simply wraps the function, and so the docstring for ivy.tan also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input array whose elements are expressed in radians. Should have a 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, for writing the result to. It must have a shape that the (default:None
) inputs broadcast to.
- Return type:
Container
- Returns:
ret – a container containing the tangent of each element in
self
. The return must have a floating-point data type determined by type-promotion.
Examples
>>> x = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([3., 4., 5.])) >>> y = x.tan() >>> print(y) { a:ivy.array([0., 1.56, -2.19]), b:ivy.array([-0.143, 1.16, -3.38]) }