Pythagoras & Coordinate Distance

Start from zero — the basic math you need before everything else

Look at a triangle with one square corner: an angle of 90°. That corner is the right angle, and a triangle with one is a right triangle. The two shorter sides meet right there at the square corner. The third side, stretched across from the right angle, is called the hypotenuse, and it's always the longest side of the three.

Picture a snooker table and its four corner pockets. To send the cue ball from one pocket to the opposite one, you could bank it along the length and then along the width, tracing two sides of the table. Or you could send it straight across the diagonal, the shortest way there. That diagonal is a hypotenuse, and the table's length and width are its two legs, whatever size the table happens to be. Try dragging either blue point in the figure below, and watch a² and b² add up to c², no matter where the points land.

Give the two legs the names a and b, and call the hypotenuse c. Build a square on each side, using that side's length. Add up the areas of the two smaller squares, the ones on the legs, and you get exactly the area of the big square on the hypotenuse. This only works for right triangles: try it on a triangle without a square corner and the two areas won't match.

Where this lives in MLNearest-neighbour methods decide how similar two examples are by measuring the distance between them, and clustering groups together whichever points sit close in feature space. Both lean on this exact sum-of-squares idea. The same geometry shows up as the L2 norm, as the distance between two embeddings, and as the length of a gradient vector. Every extra feature in a dataset just adds one more…
▶ Pythagoras & Coordinate Distance
← Plotting PointsSlope →