Sub topic 2
The Distance Formula and What It Proves About Shapes
What this chapter assumes
You should know the Pythagorean theorem, be able to simplify square roots, and be able to plot a point (x, y) on the Cartesian plane. This chapter uses the distance formula for two jobs: finding lengths, and proving what kind of shape a set of points forms. CAT questions rarely ask for a bare distance. They give you vertices and ask you to identify the figure, or to find the missing coordinate that makes it a particular figure.
The formula and why it works
Take two points P(x₁, y₁) and Q(x₂, y₂). Draw a horizontal segment from P and a vertical segment from Q until they meet at R(x₂, y₁). Triangle PRQ has a right angle at R. Its legs are:
- PR = |x₂ − x₁|
- RQ = |y₂ − y₁|
The Pythagorean theorem gives the length of PQ:
PQ = √((x₂ − x₁)² + (y₂ − y₁)²)
The absolute value signs are not needed inside the formula, because squaring removes the sign. This also means the order of the points does not matter. The distance from the origin to (x, y) is √(x² + y²).
def distance(p, q):
return ((p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2) ** 0.5
print(distance((0, 0), (3, 4)))This prints 5.0, the hypotenuse of a 3-4-5 triangle.
Work with squared distances
Most shape tests only compare lengths, so you can compare squared lengths and skip the square roots. Two lengths are equal exactly when their squares are equal. A triangle is right-angled exactly when the squares satisfy a² + b² = c². Squared distances of integer points are integers, so you avoid decimals and rounding.
def d2(p, q):
return (p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2
print(d2((0, 0), (3, 4)))This prints 25.
Classifying a triangle
Find the three squared side lengths and sort them as s₁ ≤ s₂ ≤ s₃. Then check these in order:
- Collinear check. If the three points lie on one line, there is no triangle. Equivalently, √s₁ + √s₂ = √s₃.
- Equilateral if s₁ = s₂ = s₃.
- Isosceles if any two of the three are equal.
- Right-angled if s₁ + s₂ = s₃.
- Otherwise, if s₁ + s₂ > s₃ the triangle is acute, and if s₁ + s₂ < s₃ it is obtuse.
A triangle can be both right-angled and isosceles. This happens when s₁ = s₂ and s₃ = 2s₁.
The following program applies these tests. It uses a cross product for the collinearity test, which stays exact with integers.
def d2(p, q):
return (p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2
def classify_triangle(a, b, c):
cross = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0])
if cross == 0:
return "degenerate (collinear)"
s1, s2, s3 = sorted([d2(a, b), d2(b, c), d2(c, a)])
if s1 == s3:
return "equilateral"
kind = "isosceles" if (s1 == s2 or s2 == s3) else "scalene"
if s1 + s2 == s3:
return "right " + kind
if s1 + s2 > s3:
return "acute " + kind
return "obtuse " + kind
print(classify_triangle((0, 0), (4, 0), (0, 3)))
print(classify_triangle((0, 0), (2, 0), (1, 1)))
print(classify_triangle((1, 2), (3, 4), (6, 7)))The output is right scalene, right isosceles, and degenerate (collinear).
The third triple shows distance used for collinearity. The squared sides are 8, 18, and 50, so the lengths are 2√2, 3√2, and 5√2. Since 2√2 + 3√2 = 5√2, the three points lie on one line, and the middle point B sits between A and C.
A fact worth remembering: no triangle with all three vertices at integer coordinates is equilateral. If a CAT question gives integer vertices and asks you to pick the equilateral one, you can eliminate that option immediately.
Classifying a quadrilateral
For four points A, B, C, D taken in order around the shape, compute the four sides and the two diagonals AC and BD. Then match the pattern.
| Shape | Sides | Diagonals |
|---|---|---|
| Parallelogram | Opposite sides equal | Midpoints coincide |
| Rectangle | Opposite sides equal | Equal in length |
| Rhombus | All four equal | Midpoints coincide, not equal in length |
| Square | All four equal | Equal in length |
Equal opposite sides alone is enough to show a parallelogram. Equal diagonals then turn it into a rectangle. Equal sides alone can mislead you: four equal sides give a rhombus, and you need equal diagonals to upgrade it to a square.
Worked example: A(0, 0), B(3, 1), C(4, 4), D(1, 3).
- AB² = 9 + 1 = 10, BC² = 1 + 9 = 10, CD² = 9 + 1 = 10, DA² = 1 + 9 = 10. All four sides are equal.
- AC² = 16 + 16 = 32 and BD² = 4 + 4 = 8. The diagonals are unequal, so the shape is a rhombus but not a square.
- The midpoint of AC is (2, 2) and the midpoint of BD is (2, 2). The diagonals bisect each other, which confirms a parallelogram.
def d2(p, q):
return (p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2
def classify_quad(a, b, c, d):
sides = [d2(a, b), d2(b, c), d2(c, d), d2(d, a)]
diag1, diag2 = d2(a, c), d2(b, d)
same_mid = (a[0] + c[0], a[1] + c[1]) == (b[0] + d[0], b[1] + d[1])
if not same_mid:
return "not a parallelogram"
all_equal = len(set(sides)) == 1
if all_equal:
return "square" if diag1 == diag2 else "rhombus"
return "rectangle" if diag1 == diag2 else "parallelogram"
print(classify_quad((0, 0), (3, 1), (4, 4), (1, 3)))
print(classify_quad((2, -2), (8, 4), (5, 7), (-1, 1)))The output is rhombus and rectangle. The code compares sums of coordinates instead of halves, so the midpoint test stays in integers.
Finding unknown coordinates
Distance conditions turn into equations in the unknown coordinate. Write each squared distance and set them equal. The x² or y² terms usually cancel, leaving a linear equation.
Example: find the point on the x-axis equidistant from A(1, 2) and B(5, 6). Let the point be P(x, 0).
- PA² = (x − 1)² + 4
- PB² = (x − 5)² + 36
- Setting them equal: x² − 2x + 5 = x² − 10x + 61, so 8x = 56 and x = 7.
- Check: PA² = 36 + 4 = 40 and PB² = 4 + 36 = 40.
The point is (7, 0). In general, the set of points equidistant from two given points is the perpendicular bisector of the segment joining them. The method above finds where that line meets an axis.
When a problem fixes the distance itself, you get a quadratic. For points (k, 2) and (5, −1) at distance 5, the equation is (k − 5)² + 9 = 25, so (k − 5)² = 16 and k = 9 or k = 1. Both values satisfy the condition.
Equidistance from three points
If a point is equidistant from three vertices, it is the circumcenter of the triangle. You set PA² = PB² and PB² = PC², which gives two linear equations, and then solve them together. For the triangle (0, 0), (4, 0), (0, 3), this gives P(2, 1.5) with distance 2.5 to each vertex. The right angle is at the origin, so the circumcenter is the midpoint of the hypotenuse, as the geometry predicts. A later chapter covers the circumcenter in full. The takeaway here is that you can always find it by equating squared distances.
Common errors
- Writing (x₂² − x₁²) instead of (x₂ − x₁)². The difference must be squared, not the individual coordinates.
- Forgetting to take the square root at the end, when the question asks for the actual distance rather than the squared one.
- Taking the points in the wrong order for a quadrilateral. The side and diagonal tests assume A, B, C, D go around the shape. If the order is scrambled, a side may turn out to be a diagonal.
- Calling a shape a square after testing only the sides, or a rectangle after testing only the diagonals.
- Rounding square roots early. Keep surds such as 2√2 until the end, or work in squared distances.
Practice
Exercise
Classify the triangle with vertices A(1, 1), B(5, 1) and C(3, 5).
Show answer
AB² = 16, BC² = 4 + 16 = 20, CA² = 4 + 16 = 20. Two sides are equal, so it is isosceles with apex C. Since 16 + 20 is greater than 20, the largest square is not the sum of the other two, so it is not right-angled. It is an acute isosceles triangle.
Exercise
Find the point P on the y-axis that is equidistant from A(2, 3) and B(6, −1).
Show answer
Let P = (0, y). Then 4 + (y − 3)² = 36 + (y + 1)². Expanding gives 13 − 6y = 37 + 2y, so y = −3. Check: PA² = 4 + 36 = 40 and PB² = 36 + 4 = 40. P is (0, −3).
Exercise
Show that A(2, −2), B(8, 4), C(5, 7), D(−1, 1) form a rectangle but not a square, and find its area.
Show answer
AB² = 72, BC² = 18, CD² = 72, DA² = 18, so opposite sides are equal. AC² = 9 + 81 = 90 and BD² = 81 + 9 = 90, so the diagonals are equal. That makes it a rectangle. Adjacent sides differ, so it is not a square. The sides are 6√2 and 3√2, so the area is 18 × 2 = 36.