Distance formula

Two dots on a graph paper, and a question: how far apart are they, without touching a ruler? That is what the distance formula answers. Given two points P(x1,y1)P(x_1, y_1) and Q(x2,y2)Q(x_2, y_2) on the Cartesian plane, it turns their coordinates directly into the straight-line distance between them, using nothing more than subtraction, squaring, and one square root. The formula is the opening idea of the Class 10 chapter Coordinate Geometry, and it is not really new mathematics — it is the Pythagoras theorem you already know, rewritten so a right triangle can be built and measured purely from coordinates. Once you can find a distance, you can test whether points are equidistant, decide whether three points lie on one line, and classify triangles by their side lengths — all without drawing a single accurate diagram.

The core insight

The distance between (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2) is the hypotenuse of a right triangle built from their coordinate differences: d=(x2−x1)2+(y2−y1)2d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}.

The core idea

Plot P(x1,y1)P(x_1, y_1) and Q(x2,y2)Q(x_2, y_2). Draw a horizontal line through PP and a vertical line through QQ; they cross at R(x2,y1)R(x_2, y_1), and PRQPRQ is a right triangle with the right angle sitting at RR.

  • The horizontal leg PRPR has length ∣x2−x1∣|x_2 - x_1| — the run.
  • The vertical leg RQRQ has length ∣y2−y1∣|y_2 - y_1| — the rise.
  • PQPQ, the segment we actually want, is the hypotenuse.

By the Pythagoras theorem, PQ2=(x2−x1)2+(y2−y1)2PQ^2 = (x_2-x_1)^2 + (y_2-y_1)^2, so the distance formula is

d=(x2−x1)2+(y2−y1)2d = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}

where: dd is the distance between the two points, (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2) are their coordinates, and the two squared terms are the run and the rise of the right triangle joining them. Squaring each difference removes the need to worry about which coordinate is bigger — (x2−x1)2(x_2-x_1)^2 equals (x1−x2)2(x_1-x_2)^2 either way, so dd never depends on the order in which you list the two points; the formula is symmetric in PP and QQ. A common special case is the distance of a point (x,y)(x,y) from the origin (0,0)(0,0): putting x1=y1=0x_1=y_1=0 gives d=x2+y2d=\sqrt{x^2+y^2}, not a separate rule but the same formula with one point fixed. Two further properties are worth keeping in mind whenever the formula is applied. First, dd is always non-negative, and d=0d=0 only when the two points coincide — a square root can never return a negative value, which matches the everyday sense that a distance of zero means "no gap at all." Second, the formula does not care whether PP and QQ sit in the same quadrant, in different quadrants, or straddle an axis; the coordinate differences (x2−x1)(x_2-x_1) and (y2−y1)(y_2-y_1) automatically pick up the correct sign for the layout, and squaring erases that sign before it can cause trouble. This is why the same one-line formula works for every pair of points on the plane, with no separate cases to remember for "point in the second quadrant" or "points on the same vertical line." It also helps to see the formula as one entry in a small family of coordinate-geometry tools built on the same right-triangle idea. Once you can measure a single distance, you can measure three distances at once and compare them — that comparison is what lets you decide whether three points are collinear, or whether a triangle formed by three points is scalene, isosceles, equilateral, or right-angled, simply by looking at how the squared side lengths relate to one another.

Figure
Right triangle formed by two points with horizontal run and vertical rise meeting at a right angle, hypotenuse labelled distance d
P(x1, y1) Q(x2, y2) R(x2, y1) run = x2 minus x1 rise d

Derivation of the distance formula

Derivation ADistance formula from the Pythagoras theorem

The goal is to show that the straight-line distance between any two points P(x1,y1)P(x_1,y_1) and Q(x2,y2)Q(x_2,y_2) on the Cartesian plane can be written purely in terms of their coordinates as d=(x2−x1)2+(y2−y1)2d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}, using only the Pythagoras theorem and nothing beyond it.

Step 1. Construct a right triangle from the two points. Through P(x1,y1)P(x_1,y_1) draw a line parallel to the x-axis, and through Q(x2,y2)Q(x_2,y_2) draw a line parallel to the y-axis. These two lines meet at the point R(x2,y1)R(x_2, y_1), since RR shares its x-coordinate with QQ and its y-coordinate with PP. The angle at RR is a right angle, because a horizontal line and a vertical line always meet at ninety degrees.

Step 2. Measure the two legs. The leg PRPR runs horizontally from x1x_1 to x2x_2 at the fixed height y1y_1, so its length is ∣x2−x1∣|x_2-x_1|. The leg RQRQ runs vertically from y1y_1 to y2y_2 at the fixed position x2x_2, so its length is ∣y2−y1∣|y_2-y_1|. These are exactly the coordinate differences between the two original points.

Step 3. Apply the Pythagoras theorem to triangle PRQPRQ, where PQPQ is the hypotenuse opposite the right angle at RR. This gives PQ2=PR2+RQ2=∣x2−x1∣2+∣y2−y1∣2PQ^2 = PR^2 + RQ^2 = |x_2-x_1|^2 + |y_2-y_1|^2. Since squaring a number and squaring its negative give the same result, the absolute value bars can be dropped without changing anything: PQ2=(x2−x1)2+(y2−y1)2PQ^2 = (x_2-x_1)^2 + (y_2-y_1)^2.

Step 4. Take the positive square root, since a distance cannot be negative: d=PQ=(x2−x1)2+(y2−y1)2d = PQ = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}. This holds for any placement of PP and QQ — above, below, left, or right of each other — because the squaring step already absorbs every possible sign of the differences.

Step 5. Check the two edge cases to be sure the formula behaves sensibly. If y1=y2y_1=y_2, the two points lie on the same horizontal line and the formula collapses to d=(x2−x1)2=∣x2−x1∣d=\sqrt{(x_2-x_1)^2}=|x_2-x_1|, exactly the ordinary distance between two points on a number line. If x1=x2x_1=x_2, the points lie on the same vertical line and d=∣y2−y1∣d=|y_2-y_1| in the same way. Both special cases fall out of the general formula automatically, without needing separate rules, which is a good sign that the derivation is complete and consistent.

Worked example

Find the distance between A(2,3)A(2,3) and B(7,15)B(7,15), and hence confirm the distance of AA from the origin.

Step 1. Label the coordinates: x1=2, y1=3, x2=7, y2=15x_1=2,\ y_1=3,\ x_2=7,\ y_2=15.

Step 2. Substitute into the formula: AB=(7−2)2+(15−3)2=52+122=25+144=169AB=\sqrt{(7-2)^2+(15-3)^2}=\sqrt{5^2+12^2}=\sqrt{25+144}=\sqrt{169}.

Step 3. Simplify the surd: 169=13\sqrt{169}=13. So AB=13AB = 13 units — and note 5,12,135,12,13 is a Pythagorean triple, the same right-triangle idea used in the derivation, now with concrete numbers.

Competitive stretch

Step 4. Distance of A(2,3)A(2,3) from the origin, using the special case d=x2+y2d=\sqrt{x^2+y^2}: OA=22+32=4+9=13OA=\sqrt{2^2+3^2}=\sqrt{4+9}=\sqrt{13}. Since 1313 is not a perfect square, this stays as the surd OA=13OA=\sqrt{13} units — a reminder that not every distance simplifies to a whole number.

Common traps

  • Forgetting to square before adding. d=(x2−x1)+(y2−y1)d=(x_2-x_1)+(y_2-y_1) is wrong — each difference must be squared individually first, then added, then rooted.
  • Sign errors from mismatched labelling. The order of subtraction (x2−x1x_2-x_1 vs x1−x2x_1-x_2) doesn't matter since it gets squared, but mixing up which coordinate belongs to which point does — keep (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2) clearly assigned.
  • Leaving a surd unsimplified. 45\sqrt{45} should become 353\sqrt5, not stay as 45\sqrt{45} or get rounded off unless a decimal is asked for.
  • Treating "distance from origin" as a separate rule. It is just d=x2+y2d=\sqrt{x^2+y^2}, the general formula with one point fixed at (0,0)(0,0) — no new formula to memorise.
  • Rushing the collinearity check without simplifying surds first. When comparing three pairwise distances to test collinearity, write every distance as a multiple of the same simplified surd wherever possible — spotting that PR+PQ=QRPR+PQ=QR is easy once all three are multiples of 5\sqrt5, but nearly impossible to see if they are left as 20\sqrt{20}, 45\sqrt{45}, and 125\sqrt{125}.

Ask the tutor: If a distance-formula problem gives an answer that doesn't match yours, ask the AI tutor to walk through the right-triangle picture and each step with your exact numbers.

Why do we square the differences instead of just subtracting the coordinates?

Because a plain subtraction like (x2−x1)+(y2−y1)(x_2-x_1)+(y_2-y_1) mixes horizontal and vertical movement in a way that has no geometric meaning, and it can even come out negative, which distance never should. Squaring each difference first turns both legs into positive lengths, and the Pythagoras theorem is precisely the rule for combining two perpendicular legs into a hypotenuse. That is the whole reason the formula has the shape it does — it is geometry, not an arbitrary algebra trick.

Does it matter which point I call P and which I call Q?

No. Swapping the two points swaps which difference is x2−x1x_2-x_1 versus x1−x2x_1-x_2, but since (x2−x1)2=(x1−x2)2(x_2-x_1)^2=(x_1-x_2)^2, the squared terms come out identical either way, and so does the final distance. You can pick either point as the first one; just be consistent about which x goes with which y so you don't accidentally pair up the wrong coordinates.

How is the distance formula used to check if points form a triangle or are collinear?

Compute all three pairwise distances between the points. If the sum of two of them equals the third, the three points are collinear — one point sits exactly on the line joining the other two, and no triangle forms. If instead all three sums are strictly greater than the remaining side, the points form a genuine triangle, and comparing the squared distances further tells you whether it is right-angled (Pythagoras holds), isosceles (two distances equal), or equilateral (all three equal).

Before this

Where this leads