Distance between points

Two points on graph paper, and you want the straight-line gap between them without ever picking up a ruler. That is exactly what the distance formula does: feed it the coordinates of P(x1,y1)P(x_1,y_1) and Q(x2,y2)Q(x_2,y_2), and it hands back the length PQPQ by arithmetic alone. It sits third in the ICSE Class 9 Coordinate Geometry chapter, right after plotting points on the Cartesian plane and solving equations graphically, and it leans on nothing more exotic than the Pythagoras theorem you already know from the Geometry strand. The payoff is bigger than a single number. Once you can measure any segment on the plane, you can decide whether three points line up straight (collinear), what kind of triangle three points form, and whether four points trace out a square, rectangle, or parallelogram — all without drawing an accurate diagram. This section builds the formula from a right triangle, works through both a plain distance and a collinearity check, and flags the slips that cost the most marks.

The core insight

The distance between P(x1,y1)P(x_1,y_1) and Q(x2,y2)Q(x_2,y_2) is the hypotenuse of a right triangle with legs ∣x2−x1∣|x_2-x_1| and ∣y2−y1∣|y_2-y_1|, so d=(x2−x1)2+(y2−y1)2d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2} by the Pythagoras theorem.

The core idea

Setting up the right triangle. Plot P(x1,y1)P(x_1,y_1) and Q(x2,y2)Q(x_2,y_2) on the Cartesian plane. Draw a horizontal line through PP and a vertical line through QQ (or the other way round); they meet at a third point R(x2,y1)R(x_2,y_1). Because one line is horizontal and the other vertical, the angle at RR is exactly 90∘90^\circ, so triangle PQRPQR is right-angled at RR with PR=∣x2−x1∣PR = |x_2-x_1| and QR=∣y2−y1∣QR = |y_2-y_1|.

Applying Pythagoras. In a right triangle, the square of the hypotenuse equals the sum of the squares of the other two sides. Here the hypotenuse is PQPQ, the segment we actually want:

PQ2=PR2+QR2=(x2−x1)2+(y2−y1)2PQ^2 = PR^2 + QR^2 = (x_2-x_1)^2 + (y_2-y_1)^2

where: PR=∣x2−x1∣PR = |x_2-x_1| is the horizontal leg, QR=∣y2−y1∣QR = |y_2-y_1| is the vertical leg, and PQPQ is the distance between the two original points. Taking the square root of both sides gives the distance formula itself:

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

where: dd is the distance between PP and QQ, (x1,y1)(x_1,y_1) and (x2,y2)(x_2,y_2) are their coordinates in any order (each difference is squared, so a sign flip does not change the answer), and the units of dd match whatever units the coordinates are measured in. Swapping which point you call "1" and which you call "2" leaves dd unchanged, because (x2−x1)2=(x1−x2)2(x_2-x_1)^2 = (x_1-x_2)^2 — a useful check when you are unsure which point to subtract from which.

Distance from the origin. A common special case is the distance of a point (x,y)(x,y) from the origin O(0,0)O(0,0). Substituting x1=y1=0x_1=y_1=0 into the formula collapses it to

d=x2+y2d = \sqrt{x^2+y^2}

which is worth remembering on its own, since it turns up whenever a question asks "how far is this point from OO."

What the formula is used for. Beyond a raw length, the same formula tells you whether three points AA, BB, CC form a triangle (compute all three sides ABAB, BCBC, CACA; equal sides signal an isosceles or equilateral triangle, and AB2+BC2=CA2AB^2+BC^2=CA^2-type relations signal a right angle by the converse of Pythagoras theorem) or whether they are collinear instead — no triangle at all, just three points on one line, which happens exactly when the sum of two of the distances equals the third. It also lets you verify that four points form a square, rectangle, or parallelogram by comparing all four sides and both diagonals.

Figure
A right triangle on a coordinate grid with points P Q and R showing the horizontal leg vertical leg and the distance PQ as the hypotenuse
Distance formula from a right triangle P (x1, y1) Q (x2, y2) R (x2, y1) vertical leg horizontal leg distance PQ
Derivation ADeriving the distance formula from Pythagoras theorem

The goal of this derivation is to show, using only the definition of a right triangle and the Pythagoras theorem already known from the Geometry strand, 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 computed purely from their coordinates as d=(x2−x1)2+(y2−y1)2d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}, with no measuring tool needed.

Step 1. Construct a right triangle from the two points. Through P(x1,y1)P(x_1,y_1) draw a horizontal line, and through Q(x2,y2)Q(x_2,y_2) draw a vertical line; call their intersection RR. Since RR shares its xx-coordinate with QQ and its yy-coordinate with PP, R=(x2,y1)R = (x_2,y_1). The line PRPR is horizontal and the line QRQR is vertical, so they meet at exactly 90∘90^\circ: triangle PQRPQR is right-angled at RR.

Step 2. Measure the two legs along the grid. The horizontal leg PRPR spans from x1x_1 to x2x_2 at the fixed height y1y_1, so its length is PR=∣x2−x1∣PR = |x_2-x_1|. The vertical leg QRQR spans from y1y_1 to y2y_2 at the fixed position x2x_2, so its length is QR=∣y2−y1∣QR = |y_2-y_1|. Both legs lie along grid directions, so their lengths are just the numerical differences of the coordinates, no diagonal measurement required.

Step 3. Apply the Pythagoras theorem to the hypotenuse. The segment PQPQ is the hypotenuse of the right triangle PQRPQR (it is opposite the right angle at RR), so PQ2=PR2+QR2PQ^2 = PR^2 + QR^2. Substituting the leg lengths from Step 2, and noting that squaring removes the absolute value bars since ∣a∣2=a2|a|^2 = a^2, gives PQ2=(x2−x1)2+(y2−y1)2PQ^2 = (x_2-x_1)^2 + (y_2-y_1)^2.

Step 4. Take the square root to isolate the distance. Since a length is never negative, PQ=(x2−x1)2+(y2−y1)2PQ = \sqrt{(x_2-x_1)^2+(y_2-y_1)^2}. Renaming PQPQ as dd gives the standard form d=(x2−x1)2+(y2−y1)2d=\sqrt{(x_2-x_1)^2+(y_2-y_1)^2}, valid for any two points anywhere on the plane, including when one or both coordinates are negative, because the differences are squared before the square root is taken.

Worked example

Find the distance between the points A(3,2)A(3,2) and B(−1,−1)B(-1,-1), and then check whether the point P(1,2)P(1,2), Q(4,6)Q(4,6), R(7,10)R(7,10) are collinear.

Step 1. Label the coordinates for AA and BB: take (x1,y1)=(3,2)(x_1,y_1)=(3,2) and (x2,y2)=(−1,−1)(x_2,y_2)=(-1,-1). Substitute into the distance formula: d=(−1−3)2+(−1−2)2d=\sqrt{(-1-3)^2+(-1-2)^2}.

Step 2. Simplify inside the square root. (−1−3)2=(−4)2=16(-1-3)^2=(-4)^2=16 and (−1−2)2=(−3)2=9(-1-2)^2=(-3)^2=9, so d=16+9=25=5d=\sqrt{16+9}=\sqrt{25}=5. This is a 33–44–55 right triangle in disguise: the horizontal leg is 44 units, the vertical leg is 33 units, and the hypotenuse — the distance — is 55 units. So AB=5 unitsAB = \mathbf{5\ units}.

Step 3. For the collinearity check, compute all three pairwise distances among P(1,2)P(1,2), Q(4,6)Q(4,6), R(7,10)R(7,10) using the same formula. PQ=(4−1)2+(6−2)2=9+16=25=5PQ=\sqrt{(4-1)^2+(6-2)^2}=\sqrt{9+16}=\sqrt{25}=5. QR=(7−4)2+(10−6)2=9+16=25=5QR=\sqrt{(7-4)^2+(10-6)^2}=\sqrt{9+16}=\sqrt{25}=5. PR=(7−1)2+(10−2)2=36+64=100=10PR=\sqrt{(7-1)^2+(10-2)^2}=\sqrt{36+64}=\sqrt{100}=10.

Step 4. Compare the sums: PQ+QR=5+5=10=PRPQ+QR = 5+5 = 10 = PR. Since the sum of the two shorter distances equals the longest distance, QQ lies exactly on the segment joining PP and RR, so PP, QQ, RR do not form a triangle — they are collinear.

Competitive stretch

If instead PQ+QRPQ+QR had come out greater than PRPR for every pairing (the strict triangle inequality), the three points would form a genuine triangle, and you could go on to test its type by comparing the three side lengths — equal sides for isosceles or equilateral, or AB2+BC2=CA2AB^2+BC^2=CA^2-style relations for a right angle, using the converse of Pythagoras theorem.

Common traps

  • Forgetting to square before adding: some students write (x2−x1)+(y2−y1)\sqrt{(x_2-x_1)+(y_2-y_1)} or take a square root too early. Square each difference, add the two squares, then take exactly one square root at the end.
  • Sign errors with negative coordinates: when a coordinate is negative, e.g. x1=−1x_1=-1, remember x2−(−1)=x2+1x_2-(-1)=x_2+1. Write the subtraction out fully before squaring rather than doing it in your head.
  • Assuming equal-looking distances always mean equilateral: always compute the exact distances (or compare simplified surd forms), not a rough sketch estimate.
  • Mixing up the collinearity test with the triangle-type test: collinear points satisfy (sum of two distances) equals (the third distance); a genuine triangle needs the strict triangle inequality, sum of any two sides greater than the third. Check which condition actually holds before concluding.

Ask the tutor: Stuck on a sign error with negative coordinates, or want to check step by step whether a set of points forms a triangle or a straight line? Ask the AI tutor to walk through it with you.

Does it matter which point I call x1 y1 and which I call x2 y2?

No. Because each difference is squared in the formula, (x2−x1)2(x_2-x_1)^2 always equals (x1−x2)2(x_1-x_2)^2, so swapping the labels gives exactly the same value of dd. Pick whichever point is more convenient to subtract from, usually the one that keeps more numbers positive, and stay consistent for both the xx and yy differences within the same calculation.

Why do I square the differences instead of just adding the horizontal and vertical gaps?

Adding the two legs directly would give you the length of a path that goes along the grid, like walking along streets in a city, not the straight-line distance "as the crow flies." The straight segment PQPQ is the hypotenuse of a right triangle whose legs are those two gaps, and the Pythagoras theorem is exactly the rule that converts two perpendicular leg lengths into the length of the hypotenuse — hence the squares, the addition, and the final square root.

How do I quickly tell three points are collinear without drawing them?

Compute all three pairwise distances between the points using the distance formula, then check whether the two shorter distances add up to exactly the longest one. If they do, the middle point sits exactly on the segment joining the outer two, so the three points lie on a single straight line and cannot form a triangle. If the sum is strictly greater than the longest distance instead, the points do form a genuine triangle.

Before this

Where this leads