jax.numpy.cosh — JAX documentation (original) (raw)
jax.numpy.cosh#
Calculate element-wise hyperbolic cosine of input.
JAX implementation of numpy.cosh.
The hyperbolic cosine is defined by:
\[cosh(x) = \frac{e^x + e^{-x}}{2}\]
Parameters:
x (ArrayLike) – input array or scalar.
Returns:
An array containing the hyperbolic cosine of each element of x, promoting to inexact dtype.
Return type:
Note
jnp.cosh is equivalent to computing jnp.cos(1j * x).
See also
- jax.numpy.sinh(): Computes the element-wise hyperbolic sine of the input.
- jax.numpy.tanh(): Computes the element-wise hyperbolic tangent of the input.
- jax.numpy.arccosh(): Computes the element-wise inverse of hyperbolic cosine of the input.
Examples
x = jnp.array([[3, -1, 0], ... [4, 7, -5]]) with jnp.printoptions(precision=3, suppress=True): ... jnp.cosh(x) Array([[ 10.068, 1.543, 1. ], [ 27.308, 548.317, 74.21 ]], dtype=float32) with jnp.printoptions(precision=3, suppress=True): ... jnp.cos(1j * x) Array([[ 10.068+0.j, 1.543+0.j, 1. +0.j], [ 27.308+0.j, 548.317+0.j, 74.21 +0.j]], dtype=complex64, weak_type=True)
For complex-valued input:
with jnp.printoptions(precision=3, suppress=True): ... jnp.cosh(5+1j) Array(40.096+62.44j, dtype=complex64, weak_type=True) with jnp.printoptions(precision=3, suppress=True): ... jnp.cos(1j * (5+1j)) Array(40.096+62.44j, dtype=complex64, weak_type=True)