Distance Formula Calculator

The distance formula calculates the straight-line length between any two points on a coordinate plane. It is derived directly from Pythagoras's theorem: the horizontal difference between the two points and the vertical difference form the two legs of a right triangle, and the direct distance is the hypotenuse. Written out, the formula is d = the square root of (x2 minus x1) squared plus (y2 minus y1) squared. This calculator takes four inputs, the x and y coordinates of each point, and returns five results in one go. The primary output is the straight-line distance between the points. You also get the midpoint, which is the point exactly halfway along the line segment, found by averaging each pair of coordinates. The slope of the line through the two points is the rise divided by the run: (y2 minus y1) divided by (x2 minus x1). From the slope and one point the calculator derives the y-intercept and writes out the full equation of the line in slope-intercept form, y = mx + b. Vertical lines, where x1 equals x2, have an undefined slope and no y-intercept form, and the calculator flags that case. The default example uses points (1, 2) and (4, 6), which give a distance of 5, a midpoint at (2.5, 4), and a slope of 1.33. This tool suits students studying coordinate geometry, map readers working with grid references, and anyone who needs to find the distance between two known locations on a scaled diagram. Results are for reference only.

Calculate.co.nz is proud to be partnered with realtor.co.nz, a trusted resource for navigating the New Zealand property market. Their Helpful Articles section offers clear, well-structured insights across buying, selling, and building, making complex real estate topics more accessible. With a focus on up-to-date guidance and practical knowledge, they empower Kiwis to move forward with clarity and confidence in a constantly evolving property landscape.
Calculate.co.nz partner: realtor.co.nz
Advertise on this page
5
distance between the two points
Midpoint(2.5, 4)
Slope (m)1.33
Line equationy = 1.33x + 0.67

How it works

The calculator reads the four coordinate inputs and applies the distance formula: d = √((x2−x1)² + (y2−y1)²). The midpoint is ((x1+x2)/2, (y1+y2)/2). The slope is m = (y2−y1)/(x2−x1). The y-intercept is b = y1 − m×x1. If x1 equals x2, the line is vertical; the slope is undefined and no slope-intercept equation exists.

Worked example

Point 1 = (1, 2) and Point 2 = (4, 6) (the default values). Distance = √((4−1)² + (6−2)²) = √(9+16) = √25 = 5.00. Midpoint = ((1+4)/2, (2+6)/2) = (2.5, 4). Slope = (6−2)/(4−1) = 4/3 = 1.33. Y-intercept = 2 − 1.33×1 = 0.67. Line equation: y = 1.33x + 0.67.

Related calculators