Find points that give the shortest distance between $y = x^2$ and $y-x+2=0$ using Lagrange multipliers I am asked to find, using Lagrange multipliers, the points on $y = x^2$ and $y-x+2=0$ that give the shortest distance between the curves.
Obviously, $d(x,y) = \sqrt{(x-x_0)^2 + (y-y_0)^2}$, but I am not sure where to start.
 A: I can provide a solution without using a Lagrange Multiplier. Let us call the closest point on the parabola to the line $\left(x_0,x_0^2\right)$. Then $2x_0=1$, since the tangent line to the parabola at that point must be parallel to the line $y-x+2=0$. (If it is unclear why, imagine rotating and translating the graph so that the line $x-y+2=0$ becomes the line $y=0$. The closest point on the rotated parabola to this line is the point where the slope of the tangent line is $0$). Ergo, $x_0=\frac{1}{2}$, and the closest point on the parabola to the line is $\left(\frac{1}{2},\frac{1}{4}\right)$. The distance between $\left(\frac{1}{2},\frac{1}{4}\right)$ and $y=x-2$ can be easily calculated geometrically with a 45, 45, 90 triangle. The final answer is: $$\frac{7\sqrt{2}}{8}$$
A: What you have as "obvious" is not quite correct here.  You have $d(x,y)= \sqrt{(x- x_0)^2+ (y- y_0)^2}$, the distance from an unknown point, $(x, y)$ to a fixed point $(x_0, y_0)$.  What you want to minimize is the distance between two unknown points, say, $d(x_1, y_1, x_2, y_2)= D= \sqrt{(x_2- x_1)^2+ (y_2- y_1)^2}$.  Since those are required to be on two separate curves, we have two "constraints", $y_2= x_2^2$ and $y_2- x_2+ 2= 0$.  Write those as $F(x_1,y_1)= y_1- x_1^2= 0$ and $G(x_2, y_2)= y_2- x_2+ 2= 0$.
Of course, minimizing the distance is the same a minimizing the square or the distance so it is simpler to use $D= (x_2- x_1)^2+ (y_2- y_1)^2$.
Then $\nabla D= 2(x_2- x_1)\vec{i}+ 2(y_2- y_1)\vec{j}$, $\nabla F= -2x_1\vec{i}+ \vec{j}$, and $\nabla G= -\vec{i}+ \vec{j}$.  Taking the "Lagrange multipliers" to be $\lambda$ and $\gamma$, we want $2(x_2- x_1)\vec{i}+ 2(y_2- y_1)\vec{j}= \lambda(-2x_1\vec{i}+ \vec{j})+ \gamma(-\vec{i}+ \vec{j})= (-2\lambda x_1- \gamma)\vec{i}+ (\lambda+ \gamma)\vec{j}$.
So we must have $2(x_2- x_1)= -2\lambda x_1- \gamma$ and $2(y_2- y_1)= \lambda+ \gamma$.
A: Let $(x_1,y_1)$ and $(x_2,y_2)$ be two points in $\mathbb{R}^2$. The squared distance between these two points is
$$f (x_1, x_2, y_1, y_2) := (x_1 - x_2)^2 + (y_1 - y_2)^2$$
If we want $(x_1,y_1)$ to be on the parabola and $(x_2,y_2)$ to be on the line, then we have two equality constraints, namely, $y_1 = x_1^2$ and $y_2 = x_2 - 2$. We build the Lagrangian
$$\mathcal{L} (x_1, x_2, y_1, y_2, \lambda_1, \lambda_2) := (x_1 - x_2)^2 + (y_2 - y_2)^2 +  \lambda_1 (x_1^2 - y_1) +  \lambda_2 (x_2 - y_2 - 2)$$
We take the six partial derivatives and find where they vanish. We obtain a system of $6$ polynomial equations ($3$ linear and $3$ quadratic) in $x_1, x_2, y_1, y_2, \lambda_1, \lambda_2$. After some work, we obtain two quadratic equations in $x_1, x_2$. Once we find $x_1, x_2$, finding $y_1, y_2$ is trivial.
Using Lagrange multipliers in this problem is overkill. It would be much easier to parameterize the parabola and the line, and then find the distance between them.
