# Shortest distance between ellipse and a line

I was trying to find the shortest distance between the ellipse

$$\frac{x^2}{4} + y^2 = 1$$

and the line $x+y=4$. We have to find the point on the ellipse where its tangent line is parallel to $x+y=4$ and find the distance between those two points. However, when I used the implicit differentiation, I get

$$\frac{x}{2} + 2y\frac{dy}{dx} = 0$$ $$\frac{dy}{dx} = \frac{-x}{4y}$$

If it's parallel to $x+y=4$, then we need $x=4y$. Do I just plug it into ellipse equation and solve for it and calculate the distance between the point and a line or am I doing it wrong? I just wanted to clarify. Any help would be appreciated. Thanks!

-
Have you already studied "Lagrange Multipliers"? – DonAntonio Mar 21 '14 at 15:11
@DonAntonio kind of. but I thought my approach worked, and didn't bother to use it. – user98235 Mar 21 '14 at 15:13
As for your approach: if you draw a picture you will easily convince yourself that there will be two points on the ellipse where the tangent is parallel to the line. – Thomas Mar 21 '14 at 15:16
@user98235 Your approach is correct and indeed $\;x=4y$... – DonAntonio Mar 21 '14 at 15:17
You are much of the way to the answer. Yes, find the point(s) on the ellipse where the tangent line has the right slope. Then you have a point to a line distance problem. Standard geometry, or can even use calculus. – André Nicolas Mar 21 '14 at 15:19

## 5 Answers

If $F(x,y) \equiv \frac{1}{4}x^2 + y^2$, then $\nabla F = (\frac{1}{2}x, 2y)$ is orthogonal to curves of constant $F$, hence orthogonal to the ellipse when $(x,y)$ is on the ellipse. Also make $\nabla F$ orthogonal to the given line, so $(\frac{1}{2}x, 2y)\cdot (1, -1) = 0$ gives $y = \frac{1}{4}x$.

-

Another, hopefully correct in the basics, hints:

You want to minimize the distance function

$$\frac{|x+y-2|}{\sqrt2}\;\;<--\;\;\text{distance of a point to line}\;\;x+y-4=0$$

subject to the constraint

$$\frac12x^2+y^2-1=0$$

Putting things this way, we don't really care anymore whether the line intersects or not the ellipse! Now proceed as usual.

-
This is correct only if the elipse and the line don't intersect. Otherwise shortest distance is $0$ and realized in the intersection point(s). (Which does not happen here..) – Thomas Mar 21 '14 at 15:17
why does the solution minimize the distance between the ellipse and the line? – mookid Mar 21 '14 at 15:19
@Thomas, though it doesn't seem hard to check they don't intersect as the ellipse's biggest radius (on the abscissas) is 2... – DonAntonio Mar 21 '14 at 15:19
@mookid It does not, you only get critical points which are good candidates for a minimum. Additional work is needed to find the actual minimum. – Thomas Mar 21 '14 at 15:20
@DonAntonio it's just that people tend to use the multipliers as general recipe and forget that there might be other solutions which do not obey that logic. – Thomas Mar 21 '14 at 15:22

actually,only rewrite the function of the ellipse as $y=\sqrt{1-\frac{x^2}{4}}$,the upper half part. $k=\frac{dy}{dx}=\frac{-\frac{x}{2}}{2\sqrt{1-\frac{x^2}{4}}}$, thus,the point$({x_0},{y_0})$ on the ellipse and $\frac{-\frac{x_0}{2}}{2\sqrt{1-\frac{x_0^2}{4}}}=-1$, solving , we have $x_1=\sqrt{2},x_2=-\sqrt{2}$(not satisfied). so,$x_0=\sqrt{2}$,and by the ellipse equation,we have $y_0=\frac{1}{\sqrt{2}}$. THE DISTANCE BETWEEN THE POINT$({x_0},{y_0})$ TO A LINE $x+y=4$ IS TRIVIAL.I HOPE IT IS HELPFUL .

-

Perhaps you can try explicit differentiation. From the ellipse equation: $$y=\sqrt{1-\frac{x^2}4}$$ so $$y'=\frac{-x}{4\sqrt{1-\frac{x^2}4}}$$

(If you display the ellipse and the line, it is clear that the point you are looking for is in the upper half of the ellipse).

Then look for the point where this derivative is equal to the slope of the line:

$$\frac{-x}{4\sqrt{1-\frac{x^2}4}}=-1$$

Then solve this equation and it si done.

Arternatively, you can solve the system: $$\left\{ \begin{array}{rcl} \frac{x^2}4+y^2&=&1\\ x+y&=&k \end{array} \right.$$

When you get a discriminant that depends on $k$, it must be $0$. Find $k$ and then the point where the line touches the ellipse. You will obtain two values for $k$: you should take the greater, since the line is "above" from the ellipse.

-

Any point on the ellipse can be represented as $\displaystyle P(2\cos\phi,\sin\phi)$

So, if $s$ is the distance of $P$ from the given line is $$s=\frac{|2\cos\phi+\sin\phi-4|}{\sqrt{1^2+1^2}}$$

So, we need minimize $\displaystyle|2\cos\phi+\sin\phi-4|$

We can achieve this by Second derivative test.

Otherwise, setting $\displaystyle2=r\cos\psi,1=r\sin\psi\implies \tan\psi=2$ and $r=\sqrt{2^2+1^2}=\sqrt5$

$\displaystyle2\cos\phi+\sin\phi=\sqrt5\sin\left(\phi+\arctan2\right)$

$\displaystyle\implies-\sqrt5\le2\cos\phi+\sin\phi\le\sqrt5$

$\displaystyle\implies-\sqrt5-4\le2\cos\phi+\sin\phi-4\le\sqrt5-4$

$\displaystyle\implies\sqrt5+4\ge4-2\cos\phi-\sin\phi\ge4-\sqrt5$

$\displaystyle\implies\sqrt5+4\ge|4-2\cos\phi-\sin\phi|\ge4-\sqrt5$

$\displaystyle\implies\sqrt5+4\ge|2\cos\phi+\sin\phi-4|\ge4-\sqrt5$

$\displaystyle\implies\frac{\sqrt5+4}{\sqrt2}\ge s\ge\frac{4-\sqrt5}{\sqrt2}$

-