On this page
math.hypot
Prev: math.gcd | Up: math | Next: math.isclose
Rel: math.acos, math.acosh, math.asin, math.asinh
Ref: docs.python.org — math.hypot
Tags: #public #python3 #stdlib #math
Import
import math
from math import hypot
Signature & Overview
math.hypot(*coordinates)
Multidimensional Euclidean distance from the origin to a point.
Usage
import math
assert math.isclose(math.hypot(3, 4), 5.0)
assert math.isclose(math.hypot(2, 3, 6), 7.0)
Gotchas
- Overflow-safe Euclidean norm: Avoids
x*xoverflow/underflow thatmath.sqrt(x*x + y*y)suffers on extreme floats, and accepts $n$ dimensions.
REPL Inspect
from math import hypot
help(hypot)
Linked from
Related notes
- tuts/python3/stdlib_module/math/gcd Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/isclose Linked here; links to this page; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/math/acos Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/acosh Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asin Linked here; shared tags: #math, #stdlib
- tuts/python3/stdlib_module/math/asinh Linked here; shared tags: #math, #stdlib
- tuts/c/stdlib/math shared tags: #math, #stdlib
- tuts/c/stdlib/math/fabs shared tags: #math, #stdlib
- tuts/c/stdlib/math/floor shared tags: #math, #stdlib