jax.numpy.arctanh#

jax.numpy.arctanh(x, /)[source]#

Calculate element-wise inverse of hyperbolic tangent of input.

JAX implementation of numpy.arctanh.

The inverse of hyperbolic tangent is defined by:

\[arctanh(x) = \frac{1}{2} [\ln(1 + x) - \ln(1 - x)]\]
Parameters:

x (ArrayLike) – input array or scalar.

Returns:

An array of same shape as x containing the inverse of hyperbolic tangent of each element of x, promoting to inexact dtype.

Return type:

Array

Note

  • jnp.arctanh returns nan for real-values outside the range [-1, 1].

  • jnp.arctanh follows the branch cut convention of numpy.arctanh for complex inputs.

See also

Examples

>>> x = jnp.array([-2, -1, -0.5, 0, 0.5, 1, 2])
>>> with jnp.printoptions(precision=3, suppress=True):
...   jnp.arctanh(x)
Array([   nan,   -inf, -0.549,  0.   ,  0.549,    inf,    nan], dtype=float32)

For complex-valued input:

>>> x1 = jnp.array([-2+0j, 3+0j, 4-1j])
>>> with jnp.printoptions(precision=3, suppress=True):
...   jnp.arctanh(x1)
Array([-0.549+1.571j,  0.347+1.571j,  0.239-1.509j], dtype=complex64)