summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2018-07-31 07:45:49 (GMT)
committerGitHub <noreply@github.com>2018-07-31 07:45:49 (GMT)
commit9c18b1ae527346bc178250ad1ca07bffdacde5dd (patch)
tree117fc5de5a05d5f9da9bed73921d3ef9c02409bc /Doc
parent9d5727326af53ddd91016d98e16ae7cf829caa95 (diff)
downloadcpython-9c18b1ae527346bc178250ad1ca07bffdacde5dd.zip
cpython-9c18b1ae527346bc178250ad1ca07bffdacde5dd.tar.gz
cpython-9c18b1ae527346bc178250ad1ca07bffdacde5dd.tar.bz2
bpo-33089: Add math.dist() for computing the Euclidean distance between two points (GH-8561)
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/math.rst12
1 files changed, 12 insertions, 0 deletions
diff --git a/Doc/library/math.rst b/Doc/library/math.rst
index e60d029..76226c2 100644
--- a/Doc/library/math.rst
+++ b/Doc/library/math.rst
@@ -330,6 +330,18 @@ Trigonometric functions
Return the cosine of *x* radians.
+.. function:: dist(p, q)
+
+ Return the Euclidean distance between two points *p* and *q*, each
+ given as a tuple of coordinates. The two tuples must be the same size.
+
+ Roughly equivalent to::
+
+ sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q)))
+
+ .. versionadded:: 3.8
+
+
.. function:: hypot(*coordinates)
Return the Euclidean norm, ``sqrt(sum(x**2 for x in coordinates))``.