The hypot() function - Python math module

The hypot() function returns the Euclidian distance of a point from origin which is defined as the square root of the sum of x value and y value of a point.

Math Updated 25 Sep 2016 1 min read

Function signature

hypot(aPointX_in, aPointY_in)

Parameters

**aPointX_in :**X coordinate value
**aPointY_in :**Y coordinate value

Return value

The Euclidian distance from origin(0,0) to the point at location(x, y).

Function overview

The hypot() function from the math module of python, calculates and returns the Euclidian Distance between the origin(0,0) and a specified point. The value returned is also called as the Euclidian Norm.

It is square root of the sum of the two values: Square of X the coordinate value and Square Y the coordinate value.

Example

python
import math

PointA = (5,5) #A point tuple

distance = round(math.hypot(PointA[0],PointA[1]),2)

print("Euclidian distance between origin and PointA:{}".format(distance))

#Find the X Intercept distance of a point

XIntercept = (7,0) #A point that falls exactly on X axis

XInterceptDistance = math.hypot(XIntercept[0],XIntercept[1])

print("Euclidian distance between origin and X Intercept:{}".format(XInterceptDistance))

#Find the Y Intercept distance of a point

YIntercept = (0,5) #A point that falls exactly on Y axis

YInterceptDistance = math.hypot(YIntercept[0],YIntercept[1])

print("Euclidian distance between origin and Y Intercept:{}".format(YInterceptDistance))

Output

Output
Euclidian distance between origin and PointA:7.07

Euclidian distance between origin and X Intercept:7.0

Euclidian distance between origin and Y Intercept:5.0