Distance Between Two Points Calculator

Calculate the distance, midpoint, and slope between two points

Enter the coordinates of two points and click Calculate distance to find the straight-line distance, midpoint, and slope between them.

The distance formula, midpoint formula, and slope in coordinate geometry

Coordinate geometry (also called analytic geometry) describes geometric shapes and relationships using a coordinate system, typically a two-dimensional Cartesian plane with an x-axis and a y-axis. Points on the plane are described by pairs of numbers (x, y). Three of the most fundamental calculations in coordinate geometry are the distance between two points, the midpoint of a line segment joining two points, and the slope of that segment. This calculator computes all three from a single set of four coordinate inputs.

To use the calculator, enter the x and y coordinates of the first point (x1, y1) in the first two fields, and the x and y coordinates of the second point (x2, y2) in the last two fields. Coordinates can be positive, negative, or zero. After clicking Calculate distance, the result panel shows the straight-line distance between the points, the coordinates of the midpoint, and the slope of the line through both points.

The distance formula is derived directly from the Pythagorean theorem. If you draw a right triangle with the two points as the endpoints of the hypotenuse, the horizontal leg has length equal to the absolute difference in x-coordinates, and the vertical leg has length equal to the absolute difference in y-coordinates. The hypotenuse, which is the direct distance between the points, therefore equals the square root of ((x2 minus x1) squared plus (y2 minus y1) squared). This formula gives the shortest path between the two points, which is the straight-line or Euclidean distance.

The midpoint formula gives the coordinates of the point exactly halfway between the two input points. The midpoint x-coordinate is the average of x1 and x2, and the midpoint y-coordinate is the average of y1 and y2. In other words, midpoint = ((x1 + x2) / 2, (y1 + y2) / 2). The midpoint lies on the line segment connecting the two points and is equidistant from both endpoints.

The slope of the line through two points is the ratio of the vertical change (rise) to the horizontal change (run). Slope m = (y2 minus y1) divided by (x2 minus x1). If x1 equals x2, the line is vertical and the slope is undefined, since you would be dividing by zero. In that case, the calculator displays "Undefined (vertical line)" rather than attempting the division.

What distance, midpoint, and slope tell you about two points

The distance between two points tells you the length of the line segment connecting them. This is useful in mapping (how far apart are two locations on a grid), physics (the displacement between two positions), engineering (the length of a cable or beam between two attachment points), and computer graphics (the pixel distance between two screen coordinates).

The midpoint is useful when you need to find the centre of a segment, divide a line segment into equal halves, or locate the average position of two points. In data visualisation, midpoints are used to label the middle of bars and segments. In construction, finding the midpoint of a span determines the position of a central support. In geometry, midpoints are used to construct perpendicular bisectors and to prove properties of shapes.

The slope tells you the direction and steepness of the line through the two points. A positive slope means the line rises from left to right. A negative slope means it falls. A slope of zero means the line is horizontal. An undefined slope means the line is vertical. The steeper the line, the larger the absolute value of the slope. A slope of 1 means the line rises at a 45-degree angle. A slope of 2 means it rises twice as fast horizontally as it moves vertically.

Applications in school mathematics

These three formulas are standard components of the coordinate geometry curriculum in secondary school mathematics. Students encounter them when studying linear equations, graphing, geometric proofs, and the relationships between algebra and geometry. Exam questions commonly ask students to find the length of a line segment, determine whether a shape has equal diagonals, verify that a point lies on a perpendicular bisector, or confirm that a quadrilateral is a rectangle by checking that its diagonals bisect each other.

This calculator supports exam preparation by allowing students to check their manual working. After computing distance, midpoint, or slope by hand, entering the values here confirms whether the result is correct. The calculator also reinforces the process: by seeing the result of different coordinate inputs, students build intuition about how changing the coordinates changes the distance and slope.

For work in three dimensions, the distance formula extends to: distance = the square root of ((x2-x1) squared + (y2-y1) squared + (z2-z1) squared). The midpoint in three dimensions follows the same averaging logic with a third coordinate. This calculator covers the standard two-dimensional case that appears in most secondary school and introductory college mathematics curricula.

Last updated: 2026-05-06