Skip to main content
Viva Calculator

Distance Between Two Points Calculator

Calculate distance and midpoint between two coordinate points

Calculate Distance

Point 1 (x₁, y₁)

Point 2 (x₂, y₂)

Method and source check

Last checked:

Automated source and implementation review, including worked examples and documented numerical limits. This review does not provide professional advice or specialist approval.

Method

Subtract corresponding coordinates, use the Euclidean distance formula, and average coordinates to find the midpoint. Horizontal and vertical distances are unsigned spans. Use Math.hypot for coordinate differences and sum coordinate halves for the midpoint to avoid unnecessary intermediate overflow.

d = √((x₂−x₁)² + (y₂−y₁)²)

M = ((x₁+x₂)/2, (y₁+y₂)/2)

Variables and units

x₁,y₁
first point coordinates
x₂,y₂
second point coordinates
d
straight-line distance

Worked example

For (0,0) and (3,4), the distance is 5, horizontal span 3, vertical span 4, and midpoint (1.5,2).

Limitations

Displayed numeric values are rounded to six decimal places. When scaling for Math.round would overflow, the finite representable value is retained.

  • Distance is a scalar; displacement is a directed vector whose magnitude equals straight-line distance.
  • Assumes a flat 2D Cartesian coordinate system.
  • Unsupported derived numerical ranges are rejected with a localized error on a visible form field; the calculations use floating-point arithmetic.
  • The same point has distance 0.
  • Distance is nonnegative and independent of point order.
  • A 3e154 by 4e154 right-angle displacement yields a finite 5e154 length.

Sources

How to Use

  1. Enter the x-coordinate of the first point (x₁)
  2. Enter the y-coordinate of the first point (y₁)
  3. Enter the x-coordinate of the second point (x₂)
  4. Enter the y-coordinate of the second point (y₂)

Calculate distance and midpoint between two coordinate points

Calculate the distance between two points in a 2D coordinate plane. Method: Subtract corresponding coordinates, use the Euclidean distance formula, and average coordinates to find the midpoint. Horizontal and vertical distances are unsigned spans.

For two points (x₁, y₁) and (x₂, y₂), the distance d is: d = √[(x₂-x₁)² + (y₂-y₁)²]

Derivation from Pythagorean Theorem

The distance formula comes from the Pythagorean theorem. If you draw a right triangle with the two points as opposite corners:

  • The horizontal leg has length |x₂ - x₁|
  • The vertical leg has length |y₂ - y₁|
  • The hypotenuse is the distance between the points
  • By Pythagorean theorem: d² = (x₂-x₁)² + (y₂-y₁)²
  • Taking the square root gives the distance formula

Midpoint Formula

The midpoint is the point exactly halfway between two points. It's calculated by averaging the x-coordinates and y-coordinates separately.

Midpoint M = ((x₁+x₂)/2, (y₁+y₂)/2)

The midpoint divides the line segment connecting the two points into two equal parts.

Special Cases

CaseConditionResult
Same point(x₁, y₁) = (x₂, y₂)Distance = 0
Horizontal liney₁ = y₂Distance = |x₂ - x₁|
Vertical linex₁ = x₂Distance = |y₂ - y₁|
Origin to point(x₁, y₁) = (0, 0)Distance = √(x₂² + y₂²)

Worked scenario

  • Coordinate plan: (0,0), (3,4) → d=5; M=(1.5,2).

Method, example, rounding, and limits

Method: Subtract corresponding coordinates, use the Euclidean distance formula, and average coordinates to find the midpoint. Horizontal and vertical distances are unsigned spans.

Worked example: (0,0), (3,4) → d=5, M=(1.5,2).

Rounding: 6 decimal places. Displayed values are rounded as stated beside the result.

Limit: Distance is a scalar; displacement is a directed vector whose magnitude equals straight-line distance.

Reference: OpenStax. https://openstax.org/books/college-algebra-2e/pages/2-1-the-rectangular-coordinate-systems-and-graphs

Frequently Asked Questions

What's the difference between distance and displacement?
Report scalar distance and the midpoint. Distance is a scalar; displacement also has direction. d = √((x₂−x₁)² + (y₂−y₁)²); M = ((x₁+x₂)/2, (y₁+y₂)/2).
Can the distance formula be used in 3D space?
Yes! The 3D distance formula is d = √[(x₂-x₁)² + (y₂-y₁)² + (z₂-z₁)²]. It extends the 2D formula by adding the z-component.
Why do we square the differences before adding them?
Squaring ensures all values are positive (eliminating direction) and comes from the Pythagorean theorem. It's the mathematical way to combine perpendicular components into a total distance.
Is the distance formula the same as the Euclidean distance?
Yes, the distance formula calculates Euclidean distance, which is the 'ordinary' straight-line distance in Euclidean geometry. There are other distance metrics (Manhattan, Chebyshev) used in specific applications.