This is an example of the Pythagorean Theorem. The path that is created is a right triangle. If you square the legs, their sum is equal to the square of the hypotenuse. The hypotenuse is the distance d in this problem.
The distance d could be described as:
![d= √(x^2+y^2)](https://img.qammunity.org/2019/formulas/mathematics/middle-school/2oz91t5fnl15ybouuhdyn82vjm0stcerlr.png)