# Distance formula

Walk through deriving a general formula for the distance between two points.
The start color blueD, d, i, s, t, a, n, c, e, end color blueD between the points left parenthesis, start color greenD, x, start subscript, 1, end subscript, end color greenD, comma, start color goldD, y, start subscript, 1, end subscript, end color goldD, right parenthesis and left parenthesis, start color greenD, x, start subscript, 2, end subscript, end color greenD, comma, start color goldD, y, start subscript, 2, end subscript, end color goldD, right parenthesis is given by the following formula:
square root of, left parenthesis, start color greenD, x, start subscript, 2, end subscript, minus, x, start subscript, 1, end subscript, end color greenD, right parenthesis, start superscript, 2, end superscript, plus, start color goldD, left parenthesis, y, start subscript, 2, end subscript, minus, y, start subscript, 1, end subscript, end color goldD, right parenthesis, start superscript, 2, end superscript, end square root

## Deriving the distance formula

Let's start by plotting the points left parenthesis, start color greenD, x, start subscript, 1, end subscript, end color greenD, comma, start color goldD, y, start subscript, 1, end subscript, end color goldD, right parenthesis and left parenthesis, start color greenD, x, start subscript, 2, end subscript, end color greenD, comma, start color goldD, y, start subscript, 2, end subscript, end color goldD, right parenthesis.
The length of the segment between the two points is the start color blueD, d, i, s, t, a, n, c, e, end color blueD between them:
We want to find the start color blueD, d, i, s, t, a, n, c, e, end color blueD. If we draw a right triangle, we'll be able to use the Pythagorean theorem!
An expression for the length of the base is start color greenD, x, start subscript, 2, end subscript, minus, x, start subscript, 1, end subscript, end color greenD:
Most people have to stop and think about why this expression works. For example, think about if x, start subscript, 1, end subscript, equals, 3 and x, start subscript, 2, end subscript, equals, 7. Here is how we would find the length of the base:
\begin{aligned} &\phantom{=}\greenD{x_2 - x_1} \\\\ &= 7 - 3 \\\\ &= 4 \end{aligned}
This makes sense because the distance from 3 to 7 is 4.
Similarly, an expression for the length of the height is start color goldD, y, start subscript, 2, end subscript, minus, y, start subscript, 1, end subscript, end color goldD:
Now we can use the Pythagorean theorem to write an equation:
start color blueD, question mark, end color blueD, start superscript, 2, end superscript, space, equals, left parenthesis, start color greenD, x, start subscript, 2, end subscript, minus, x, start subscript, 1, end subscript, end color greenD, right parenthesis, start superscript, 2, end superscript, plus, start color goldD, left parenthesis, y, start subscript, 2, end subscript, minus, y, start subscript, 1, end subscript, end color goldD, right parenthesis, start superscript, 2, end superscript
We can solve for start color blueD, question mark, end color blueD by taking the square root of each side:
start color blueD, question mark, end color blueD, equals, square root of, left parenthesis, start color greenD, x, start subscript, 2, end subscript, minus, x, start subscript, 1, end subscript, end color greenD, right parenthesis, start superscript, 2, end superscript, plus, start color goldD, left parenthesis, y, start subscript, 2, end subscript, minus, y, start subscript, 1, end subscript, end color goldD, right parenthesis, start superscript, 2, end superscript, end square root
That's it! We derived the distance formula!
Interestingly, a lot of people don't actually memorize this formula. Instead, they set up a right triangle, and use the Pythagorean theorem whenever they want to find the distance between two points.