Here's an example I just remembered giving a student one time like a million years ago that uses the distance equation.

Find the point on x = 5 that is closest to (1,2).

Now no shit sherlock it's going to be (5,2), but I'm going to use this as a less complicated example of what's going on for you.

This is basically an exercise where we want to minimize distance, so first we want to get an equation for distance using the information we're given. The distance from any given point to (1,2) is:

Distance = [(x-1)^2 + (y-2)^2]^(1/2)

Then we think: Oh snap! We have two variables instead of one! How can we fix that? We look back to the information we were given:

Find the point on x = 5 that is closest to (1,2).
Well that x = 5 bit might be useful...

Distance = [(5-1)^2 + (y-2)^2]^(1/2)
Distance = [16 + (y-2)^2]^(1/2)

Oh boy, we're left with one variable so we can take the derivative!

Distance' = (1/2) (2*(y-2))[16 + (y-2)^2]^(-1/2)

So we set it equal to zero and solve for y...

0 = (1/2) (2*(y-2))[16 + (y-2)^2]^(-1/2)

You quickly realize that you have just (y-2) on the top, so y = 2.

So x = 5, y = 2, the point is (5,2). GG.