Sub topic 2
The Distance Formula and What It Proves About Shapes
Assume you know fractions, square roots, the Pythagorean theorem, and basic triangle and quadrilateral properties. In CAT Quant, the distance formula turns the visual length of a segment into an algebraic calculation. It also lets you prove that a shape is isosceles, right-angled, a rectangle, or a square.
Deriving the distance formula
Let \(A(x1,y1)\) and \(B(x2,y2)\) be two points. The horizontal change is \(x2-x1\), and the vertical change is \(y2-y1\). These changes form the legs of a right triangle whose hypotenuse is \(AB\).
By the Pythagorean theorem,
\[ AB^2=(x2-x1)^2+(y2-y1)^2 \]
Therefore,
\[ AB=\sqrt{(x2-x1)^2+(y2-y1)^2}. \]
The squares remove the effect of negative changes. You can subtract the coordinates in either order, as long as you use the same order for both points.
A worked example
For \(A(0,0)\) and \(B(3,4)\),
\[ AB=\sqrt{(3-0)^2+(4-0)^2} =\sqrt{9+16} =\sqrt{25}=5. \]
This is the familiar \(3\)-\(4\)-\(5\) right triangle.
For \(P(-2,5)\) and \(Q(4,-3)\),
\[ PQ=\sqrt{(4+2)^2+(-3-5)^2} =\sqrt{6^2+(-8)^2} =\sqrt{100}=10. \]
A common mistake is to use \(x1+x2\) or \(y1+y2\). The formula needs coordinate differences.
Using squared distances to identify shapes
When comparing lengths, you often do not need the square root. Compare the squared distances instead:
\[ AB^2=(x2-x1)^2+(y2-y1)^2. \]
This is faster and avoids unpleasant radicals.
For points \(A,B,C\):
- \(AB=AC\) proves that triangle \(ABC\) is isosceles.
- If \(AB^2+BC^2=AC^2\), the triangle is right-angled at \(B\).
- Equal diagonals in a parallelogram prove that it is a rectangle.
- Equal diagonals and perpendicular diagonals can help prove that a quadrilateral is a square, but first confirm that the points are ordered around the shape.
For example, suppose a triangle has side squares \(25,25,\) and \(36\). Two equal side squares show that it is isosceles. Since \(25+25\ne36\), it is not right-angled.
CAT workflow and error checks
- Label the two endpoints clearly.
- Compute the horizontal and vertical differences.
- Square both differences and add them.
- Take the square root only if an actual length is required.
- Check that the result is non-negative and that it is at least as large as either coordinate difference in absolute value.
If two points share an \(x\)-coordinate, the distance is the absolute vertical difference. If they share a \(y\)-coordinate, it is the absolute horizontal difference.
def distance(p, q):
return ((p[0] - q[0]) ** 2 + (p[1] - q[1]) ** 2) ** 0.5
print(distance((0, 0), (3, 4)))Exercise
The points A(1, 2), B(5, 5), and C(9, 2) form a triangle. What type of triangle is it, and why?
Show answer
AB² = 25, BC² = 25, and AC² = 64. Since AB = BC, the triangle is isosceles. Since 25 + 25 ≠ 64, it is not right-angled.