jax.numpy.hypot
Contents
jax.numpy.hypot#
- jax.numpy.hypot(x1,x2,/)[source]#
Return element-wise hypotenuse for the given legs of a right angle triangle.
JAX implementation of
numpy.hypot.- Parameters:
x1 (ArrayLike) – scalar or array. Specifies one of the legs of right angle triangle.
complexdtype are not supported.x2 (ArrayLike) – scalar or array. Specifies the other leg of right angle triangle.
complexdtype are not supported.x1andx2must either havesame shape or be broadcast compatible.
- Returns:
An array containing the hypotenuse for the given given legs
x1andx2of a right angle triangle, promoting to inexact dtype.- Return type:
Note
jnp.hypotis a more numerically stable way of computingjnp.sqrt(x1**2+x2**2).Examples
>>>jnp.hypot(3,4)Array(5., dtype=float32, weak_type=True)>>>x1=jnp.array([[3,-2,5],...[9,1,-4]])>>>x2=jnp.array([-5,6,8])>>>withjnp.printoptions(precision=3,suppress=True):...jnp.hypot(x1,x2)Array([[ 5.831, 6.325, 9.434], [10.296, 6.083, 8.944]], dtype=float32)
Contents
