Explanation:
the distance between 2 points on a coordinate system creates a right-angled triangle.
the distance is the Hypotenuse (the side opposite of the 90° angle). and the x- and y- coordinate differences are the legs.
then Pythagoras applies
c² = a² + b²
c being the Hypotenuse, a and b being the legs.
so,
distance² = (xd - xf)² + (yd - yf)²
5² = (-7 - x)² + (-2 - 2)² = 49 + 14x + x² + 16
25 = x² + 14x + 65
x² + 14x + 40 = 0
the general solution to such a quadratic equation
ax² + bx + c = 0
is
x = (-b ± sqrt(b² - 4ac))/(2a)
in our case
x = (-14 ± sqrt(14² - 4×1×40))/(2×1) =
= (-14 ± sqrt(196 - 160))/2 =
= (-14 ± sqrt(36))/2 = (-14 ± 6)/2 = -7 ± 3
x1 = -7 + 3 = -4
x2 = -7 - 3 = -10