cosh#
- ivy.cosh(x, /, *, out=None)[source]#
Calculate an implementation-dependent approximation to the hyperbolic cosine, having domain
[-infinity, +infinity]
and codomain[-infinity, +infinity]
, for each elementx_i
in the input arrayx
.Special cases
For floating-point operands,
If
x_i
isNaN
, the result isNaN
.If
x_i
is+0
, the result is1
.If
x_i
is-0
, the result is1
.If
x_i
is+infinity
, the result is+infinity
.If
x_i
is-infinity
, the result is+infinity
.
For complex floating-point operands, let
a = real(x_i)
,b = imag(x_i)
, andNote
For complex floating-point operands,
cosh(conj(x))
must equalconj(cosh(x))
.If
a
is+0
andb
is+0
, the result is1 + 0j
.If
a
is+0
andb
is+infinity
, the result isNaN + 0j
(sign of the imaginary component is unspecified).If
a
is+0
andb
isNaN
, the result isNaN + 0j
(sign of the imaginary component is unspecified).If
a
is a nonzero finite number andb
is+infinity
, the result isNaN + NaN j
.If
a
is a nonzero finite number andb
isNaN
, the result isNaN + NaN j
.If
a
is+infinity
andb
is+0
, the result is+infinity + 0j
.If
a
is+infinity
andb
is a nonzero finite number, the result is+infinity * cis(b)
.If
a
is+infinity
andb
is+infinity
, the result is ``+infinity + NaN j``(sign of the real component is unspecified).If
a
is+infinity
andb
isNaN
, the result is+infinity + NaN j
.If
a
isNaN
andb
is either+0
or-0
, the result isNaN + 0j
(sign of the imaginary component is unspecified).If
a
isNaN
andb
is a nonzero finite number, the result isNaN + NaN j
.If
a
isNaN
andb
isNaN
, the result isNaN + NaN j
.
where
cis(v)
iscos(v) + sin(v)*1j
.- Parameters:
- Return type:
- Returns:
ret – an array containing the hyperbolic cosine of each element in
x
. The returned array must have a floating-point data type determined by type-promotion.
This method 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 arguments.Examples
With
ivy.Array
input:>>> x = ivy.array([1., 2., 3., 4.]) >>> y = ivy.cosh(x) >>> print(y) ivy.array([1.54,3.76,10.1,27.3])
>>> x = ivy.array([0.2, -1.7, -5.4, 1.1]) >>> y = ivy.zeros(4) >>> ivy.cosh(x, out=y) ivy.array([[1.67,4.57,13.6,12.3],[40.7,122.,368.,670.]])
>>> x = ivy.array([[1.1, 2.2, 3.3, 3.2], ... [-4.4, -5.5, -6.6, -7.2]]) >>> y = ivy.cosh(x) >>> print(y) ivy.array([[1.67,4.57,13.6,12.3],[40.7,122.,368.,670.]])
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([1., 2., 3.]), b=ivy.array([6., 7., 8.])) >>> y = ivy.cosh(x) >>> print(y) { a:ivy.array([1.54,3.76,10.1]), b:ivy.array([202.,548.,1490.]) }
- Array.cosh(self, *, out=None)[source]#
ivy.Array instance method variant of ivy.cosh. This method simply wraps the function, and so the docstring for ivy.cosh also applies to this method with minimal changes.
- Parameters:
self (
Array
) – input array whose elements each represent a hyperbolic angle. Should have a 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 hyperbolic cosine of each element in
self
. The returned array must have a floating-point data type determined by type-promotion.
Examples
>>> x = ivy.array([1., 2., 3.]) >>> print(x.cosh()) ivy.array([1.54, 3.76, 10.1])
>>> x = ivy.array([0.23, 3., -1.2]) >>> y = ivy.zeros(3) >>> print(x.cosh(out=y)) ivy.array([1.03, 10.1, 1.81])
- Container.cosh(self, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
ivy.Container instance method variant of ivy.cosh. This method simply wraps the function, and so the docstring for ivy.cosh also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input container whose elements each represent a hyperbolic angle. Should have a 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 – an container containing the hyperbolic cosine of each element in
self
. The returned container must have a floating-point data type determined by type-promotion.
Examples
With
ivy.Container
input:>>> x = ivy.Container(a=ivy.array([-1, 0.23, 1.12]), b=ivy.array([1, -2, 0.76])) >>> y = x.cosh() >>> print(y) { a: ivy.array([1.54, 1.03, 1.7]), b: ivy.array([1.54, 3.76, 1.3]) }
>>> x = ivy.Container(a=ivy.array([-3, 0.34, 2.]), ... b=ivy.array([0.67, -0.98, -3])) >>> y = ivy.Container(a=ivy.zeros(3), b=ivy.zeros(3)) >>> x.cosh(out=y) >>> print(y) { a: ivy.array([10.1, 1.06, 3.76]), b: ivy.array([1.23, 1.52, 10.1]) }