hypot#

ivy.hypot(x1, x2, /, *, out=None)[source]#

Return the hypotenuse given the two sides of a right angle triangle.

Parameters:
  • x1 (Union[Array, NativeArray]) – The first input array

  • x2 (Union[Array, NativeArray]) – The second input array

Return type:

Union[Array, NativeArray]

Returns:

ret – An array with the hypotenuse

Examples

>>> a = ivy.array([3.0, 4.0, 5.0])
>>> b = ivy.array([4.0, 5.0, 6.0])
>>> ivy.hypot(a, b)
ivy.array([5.0, 6.4031, 7.8102])
Array.hypot(self, x2, /, *, out=None)[source]#

ivy.Array instance method variant of ivy.hypot. This method simply wraps the function, and so the docstring for ivy.hypot also applies to this method with minimal changes.

Parameters:
  • self (Array) – First input array

  • x2 (Array) – Second input array

  • 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 hypotenuse computed from each element of the input arrays.

Examples

>>> x = ivy.array([3.0, 4.0, 5.0])
>>> y = ivy.array([4.0, 5.0, 6.0])
>>> x.hypot(y)
ivy.array([5.0, 6.4031, 7.8102])
Container.hypot(self, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.hypot. This method simply wraps the function, and so the docstring for ivy.hypot also applies to this method with minimal changes.

Parameters:
  • self (Container) – Input container containing first input array.

  • x2 (Container) – Input container containing second input array.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – container including the hypot function computed element-wise

Examples

>>> x = ivy.Container(a=ivy.array([2.0]),        ...                         b=ivy.array([3.0]))
>>> y = ivy.Container(a=ivy.array([3.0]),                                    b=ivy.array([4.0]))
>>> x.hypot(y)
{
    a: ivy.array([3.6055]),
    b: ivy.array([5.])
}