The math.hypot()
function is used to calculate the Euclidean length of a vector in n-dimensional space. It takes two or more numbers as its arguments and returns the square root of the sum of the squares of each argument. For example: math.hypot(3,4)
This would return 5.0, which is the length of the vector (3,4).
math.hypt(*args)
Where, Parameter args
represents arbitrary real numbers.
import math
print(math.hypot(4))
print(math.hypot(3, 4))
print(math.hypot(6, 8))
print(math.hypot(3, 4, 5))
print(math.hypot(1.5, 4.5, 9.5, 17.5))
print(math.hypot(10, 20, 30, 40))
The math.hypot() function is useful for a variety of calculations involving vectors, such as computing the angle between two vectors, calculating the length of the cross product of two vectors, or finding the distance between two points.