Finding the max/min distance from an ellipse to a line (Lagrange Multiplier Method) An ellipse is specified $ x^2 + 4y^2 = 4$, and a line is specified $x + y = 4$. I need to find the max/min distances from the ellipse to the line.
My idea is to find two points $(x_1, y_1)$ and $(x_2,y_2)$ such that the first point is on the ellipse and the second point is on the line. Furthermore, the line segment formed by these two points should be perpendicular to the line (slope = 1). This gives 3 constraints $g_i$ and an objective $f$.  
$$ g_1: x_1 ^2 + 4y_1 ^2 - 4 = 0$$
$$ g_2: x_2 + y_2 - 4= 0 $$
$$ g_3:\frac{(y_2 - y_1)}{(x_2 - x_1)} - 1 = 0  $$
$$ f: (y_2 - y_1)^2 + (x_2- x_1)^2 $$  
Then I compute $\nabla g_i$ and $\nabla f$:
$$ \nabla g_1 = (2x_1, 8y_1, 0, 0) $$
$$ \nabla g_2 = (0, 0, 1, 1)$$
$$ \nabla g_3 = ( (y_2 - y_1)(x_2 - x_1)^{-2}, -(x_2 - x_1)^{-1}, -(y_2 - y_1)(x_2 - x_1)^{-2}, (x_2 - x_1)^{-1} )$$
$$ \nabla f = (-2(x_2-x_1), -2(y_2-y_1), 2(x_2-x_1), 2(y_2 - y_1))$$  
At this point I try to solve $\nabla f = \sum\lambda_i\nabla g_i$, which, together with the constraints, gives me 7 equations with 7 variables. I'm not sure how to solve this system.  
$$\lambda_1 2 x_1 + \lambda_3(y_2-y_1)(x_2-x_1)^{-2} = -2(x_2-x_1)$$
$$\lambda_1 8 y_1 - \lambda_3 (x_2 - x_1)^{-1} = -2 (y_2 - y_1)$$
$$\lambda_2 - \lambda_3 (y_2 - y_1)(x_2 - x_1)^{-2} = 2(x_2 - x1)$$
$$\lambda_2 + \lambda_3 (x_2 - x_1)^{-1} = 2(y_2 -y_1)$$  
Is there an easy way to see the solutions of this system in $x_1, y_1, x_2, y_2$? If not, is there an easier formulation of this optimization problem?
 A: The ellipse is
$$x^2+4y^2=4\iff \frac{x^2}{2^2}+y^2=1$$
and the line is $\,y=-x+4\,$ , which is then "above" the ellipse all the time and, in particular, in the first quadrant (draw an approximate sketck of the functions to see why is this relevant).
Thus, we can write down a point on the ellipse in the first quadrant as 
$$\left(x\,,\,\frac{1}{2}\sqrt{4-x^2}\right)\;,\;\;x\ge 0$$
so using the formula for the distance between a point as above and the line $\,x+y-4=0\,$ we get
$$\frac{\left|\;x+\frac{1}{2}\sqrt{4-x^2}-4\;\right|}{\sqrt2}=\frac{\left|\;2x+\sqrt{4-x^2}-8\;\right|}{2\sqrt2}$$
But since the expression with the absolute value is always negative (in $\,0\le x\le 2\,$ , that is)(why?) , we must get the minimum of:
$$f(x)=\frac{-2x-\sqrt{4-x^2}+8}{2\sqrt 2}\implies f'(x)=\frac{-2+\frac{x}{\sqrt{4-x^2}}}{2\sqrt 2}=0\iff$$
$$-2\sqrt{4-x^2}+x=0\iff x^2=16-4x^2\iff x=\frac{4}{\sqrt 5}$$
Check the above indeed is a minimum point and input in the resp. equation...
Of course, the maximal distance is...
A: much easier. if your line and ellipse intersect, the minimum distance is zero. if not, it occurs on a line segment that is orthogonal to both your line and to the ellipse. which is not hard to find. there should be two such line segments, one gives the actual min, one gives a local max...draw some graphs! also, no max, there are points on the line arbitrarily far away from your ellipse. 
A: We can solve without using Lagrange Multiplier Method
We have $$\frac{x^2}4+\frac{y^2}1=1$$
So, any point$(P)$ on the ellipse can be represented as $(2\cos t,\sin t)$
SO, the distance from the line : $x+y-4=0$ from $P(2\cos t,\sin t)$
is $$\frac{|2\cos t+\sin t-4|}{\sqrt{1^2+1^2}}=\frac{\left|\sqrt5\cos\left(t-\arccos \frac2{\sqrt5}\right)-4\right|}{\sqrt2}$$ putting $2=r\cos A,1=r\sin A$ where $r>0$
Squaring and adding we get $R^2=5\implies r=\sqrt 5, A=\arccos \frac2r=\arccos \frac2{\sqrt5}$
As $-1\le \cos\left(t-\arccos \frac2{\sqrt5}\right)\le1, $
clearly, this will be maximum if $\cos\left(t-\arccos \frac2{\sqrt5}\right)=-1$ and minimum if $\cos\left(t-\arccos \frac2{\sqrt5}\right)=1$
