# Numpy hypot() method

This function is used to calculate the hypotenuse for the right angled triangle. The hypotenuse of the right angle is calculated as:

snippet
`h = sqrt(b**2 + p**2)`

where b and p are the base and perpendicular of the right angled triangle.

Each value of h is copied into the output array.

### Syntax

snippet
`numpy.hypot(array1, array2 out)`

### Parameters

1. array1: It is the input array of bases of the given right angled triangles.
2. array2: It is the input array of perpendiculars of the given right angled triangles.
3. Out: It is the shape of the output array.

### Return

It returns an array containing the hypotenuse of the given right angled triangles.

### Example 1

snippet
```import numpy as np

base = [10,2,5,50]
per= [3,10,23,6]

print("Input base array:",base)
print("Input perpendicular array:",per)

hyp = np.hypot(base,per)

print("hypotenuse ",hyp)```

Output:

Output
Input base array: [10, 2, 5, 50] Input perpendicular array: [3, 10, 23, 6] hypotenuse [10.44030651 10.19803903 23.53720459 50.35871325]

### Example 2

snippet
```import numpy as np

base = np.random.rand(3,4)
per= np.random.rand(3, 4)

print("Input base array:",base)
print("Input perpendicular array:",per)

hyp = np.hypot(base,per)

print("hypotenuse ",hyp)```

Output:

Output
Input base array: [[0.38040712 0.8629511 0.5018026 0.08201071] [0.77464952 0.68392036 0.10326945 0.69031164] [0.35380139 0.58803283 0.19791751 0.48756617]] Input perpendicular array: [[0.50466085 0.38053395 0.96808322 0.69790711] [0.77802303 0.5486305 0.34418331 0.69201998] [0.28038631 0.35850426 0.90459831 0.13383838]] hypotenuse [[0.63197481 0.94312814 1.09040862 0.70270911] [1.09790788 0.87677961 0.35934208 0.97745681] [0.45143318 0.68870017 0.92599646 0.5056021 ]]
Related Tutorial