How do you find the shortest distance from the point $\left(-1,7\right)$ to a given $\mbox{curve}\ ?$ I find this difficult to solve. It involves maxima and minima of differential calculus.
Since it's requiring the shortest distance, I have to find $y'$ and set it to zero.
Here's how I did it, but I still can't seem to find the correct answer.
$$
9x^2+25y^2-18x+100y-116=0\quad \mbox{is the given curve.}
$$
I resolved it into an equation of an ellipse,

*

*Completing the square
$$
9x^2-18x  + 25y^2+100y    = 116
$$
$$
9(x^2-2x+1) + 25(y^2+4y+4) = 116+9+100
$$


*Equation of ellipse:
$$\tag{1}
\frac{(x-1)^2}{25} + \frac{(y+2)^2}{9} = 1
$$


*I used the distance formula between two points
$$\tag{2}
d = \sqrt{(x+1)^2 + (y-7)^2}
$$
Let $x$ be $\sqrt{(225-25(y+2)^2) / 9)} + 1 $ from the curve equation


*I input $x$ into the distance formula, and this is the result.
$$
d = \sqrt{(-\frac{16}{9}y^2 -\frac{226}{9}y + \frac{602}{9} + \frac{20}{3} \sqrt{-y^2 -4y+5} }
$$
I find its derivative so it will be equal to zero to be the shortest distance to the curve.
The derivative is $\frac {-32}{9}y -\frac {226}{9} + [\frac {\frac {20}{3}(\frac 12)(-2y-4)}{ \sqrt(-y^2-4y+5)}]$
Equating the derivative of the curve equation to zero,
$$y = 0.921$$
$$x = 2.14$$
Input the values into distance formula,
$d = 6.84$ units
The correct answer is $6.14$ units.
Where could the error be? Please guide me.
 A: There is a systematic, often simpler, method that can be applied to this type of problems: the Lagrange multipliers method.
It will be even shorter by using the translation bringing the point to the origin, solving the same problem of shortest squared distance
$$f(x,y):=(x+2)^2+(y-9)^2$$
between $(-2;9)$ and ellipse with equation:
$$g(x,y):=\frac{X^2}{25} + \frac{Y^2}{9}- 1=0 \ \iff \ g(x,y):=9X^2+25Y^2-225=0\tag{1}$$
The theory (which I will not recall here) says that the minimal distance is achieved by a point $(x,y)$ for which there is a proportionnality of gradients (we have divided by $2$ in order to simplify the expressions):
$$\nabla g = \lambda\nabla f \to \begin{pmatrix}9X\\25Y\end{pmatrix} = \lambda\begin{pmatrix}(X+2)\\(Y-9) \end{pmatrix} \tag{2}$$
(it is this coefficient of proportionality $\lambda$ which is called a "Lagrange multiplier").
The three equations (1)+(2a)+(2b) give a system of 3 equations with 3 unknowns $x,y,\lambda$.
There are different methods for solving it. Usually, one eliminates unknown $\lambda$ which has no interest for the final result ; but here, it is interesting to find its value first by expressing $x$ and $y$ in the following way:
$$\begin{cases}9X&=&\lambda(X+2)\\25Y&=&\lambda(Y-9)\end{cases} \ \iff \ \begin{cases}X&=&\frac{2\lambda}{9-\lambda}\\Y&=&\frac{-9\lambda}{25-\lambda}\end{cases}\tag{3}$$
Plugging these expressions into (1) gives a fourth degree equation with 2 real roots $\lambda_1=-12.009776$ and $\lambda_2=5.332709$  and two complex ones.
Taking the first one and plugging it into equations (3) gives $x,y$, then finally gives the squared distance:
$$f(x,y):=(x+2)^2+(y-9)^2=(6.139545)^2$$
Remark: The second value $\lambda_2$ corresponds to the farthest point of the ellipse with respect to the given point.
A: The ellipse equation is
$ Q_1(x,y) = 9 x^2 + 25 y^2 - 18 x + 100 y -116 = 0 $
The objective function (to be minimized) is the square of the distance between $(x,y)$ and $(-1, 7)$
$ f(x,y) = Q_2(x,y) = (x + 1)^2 + (y - 7)^2 $
So this is a quadratic optimization subject to a quadratic constraint problem.
Using Lagrange multiplier method, the objective function is modified to include the constraint, as follows
$ g(x,y) = Q_2(x,y) + \lambda Q_1(x,y) $
Differentiating $g(x,y)$ with respect to $x, y, \lambda$ gives us
$ g_x = Q_{2x} + \lambda Q_{1x} = 0 $
$ g_y = Q_{2y} + \lambda Q_{1y} = 0 $
$ g_{\lambda} = Q_1 $
Eliminating $\lambda$ from the first two equations results in
$ Q_{2x} Q_{1y} - Q_{2y} Q_{1x} = 0 \hspace{30pt}(1)$
and, in addition, from the third equation, we have,
$ Q_1 = 0 \hspace{30pt} (2)$
Equations $(1), (2)$ are as follows for this particular problem
$ 2 (x + 1) (50 y + 100) - 2 (y - 7) (18 x - 18) = 0 $
which simplifies to
$ (x + 1)(25 y + 50) - (y - 7) (9 x - 9) = 0 \hspace{30pt}(3) $, and
$ 9 x^2 + 25 y^2 - 18 x + 100 y -116 = 0 \hspace{30pt}(4)$
Feeding these equations to wolframalpha.com gives the following two solutions
$ (x,y) = (-0.143256,  0.920525) $
and
$ (x,y) = (3.90826, -4.44032) $
The distances associated with these two points are
$ d_1 = \sqrt{ (-0.143256 + 1 )^2 + (0.920525 - 7)^2 } = 6.139546 $
$ d_2 = \sqrt{ (3.90826 + 1 )^2 + (-4.44032 - 7)^2 } = 12.44877$
So the first pair is the point on the ellipse that is closest to $(-1,7)$ while the second point is the farthest.
