# Thread: Optimize distance from the origin for an ellipse

1. ## Optimize distance from the origin for an ellipse

The question: Find the maximum distance from the origin to the ellipse $x^2+xy+y^2=3.3$.

My work: I figure that the distance to the origin is defined by the equation $\sqrt{x^2+y^2}$ so that is the function I need to maximize subject to the constraint defined by the equation of the ellipse.

So I've formed the Lagrangian $L= \sqrt{x^2+y^2} + \mu (x^2+xy+y^2-3.3)$ and taken the partials:

$\frac{\partial L}{\partial x}= \frac{2x}{2 \sqrt{x^2+y^2}}-2\mu x-\mu y$

$\frac{\partial L}{\partial y}= \frac{2y}{2 \sqrt{x^2+y^2}}-2\mu y-\mu x$

$\frac{\partial L}{\partial \mu}= -x^2-xy-y^2+3.3$

After setting all the partials equal to zero, I don't know where to go. No obvious algebraic solutions are coming to mind.

2. You could do this without Lagrange by solving the ellipse equation for y and subbing into $x^{2}+y^{2}=L$, differentiating, setting to 0 and solving for x.

It will take some algebra, but it certainly doable.

3. Originally Posted by galactus
You could do this without Lagrange by solving the ellipse equation for y and subbing into $x^{2}+y^{2}=L$, differentiating, setting to 0 and solving for x.

It will take some algebra, but it certainly doable.
Hmm, I'm not talented enough to solve $x^2+xy+y^2=3.3$ for y. Is it possible?

4. Yes, it is. I get

$y=\frac{\sqrt{13.2-3x^{2}}-x}{2}, \;\ y=\frac{-\sqrt{13.2-3x^{2}}-x}{2}$

5. Originally Posted by galactus
Yes, it is. I get

$y=\frac{\sqrt{13.2-3x^{2}}-x}{2}, \;\ y=\frac{-\sqrt{13.2-3x^{2}}-x}{2}$
That's great... can you show me how to do it?

6. Actually, it is amazingly easy. Use the quadratic formula.

$y^{2}+\underbrace{x}_{\text{b}}\cdot y+\overbrace{x^{2}-3.3}^{\text{c}}=0$

$y=\frac{-x\pm\sqrt{x^{2}-4(1)(x^{2}-3.3)}}{2(1)}$

Just simplify a wee bit and that's it.

See there?.

7. Originally Posted by galactus
Actually, it is amazingly easy. Use the quadratic formula.

$y^{2}+\underbrace{x}_{\text{b}}\cdot y+\overbrace{x^{2}-3.3}^{\text{c}}=0$

$y=\frac{-x\pm\sqrt{x^{2}-4(1)(x^{2}-3.3)}}{2(1)}$

Just simplify a wee bit and that's it.

See there?.
Very cool.

As for solving this thing, why would I want to sub my newly found y into $x^{2}+y^{2}=L$? The function I want to maximize is
$
\sqrt{x^2+y^2}=L
$
(where L is distance to origin) isn't it?

8. It is better to maximize $x^{2}+y^{2}$ because there is no radical. Remember, the distance and the square of the distance have their max and min at the same point. Therefore, no need to differentiate the radical. Just differentiate $L=x^{2}+y^{2}$

9. Originally Posted by galactus
It is better to maximize $x^{2}+y^{2}$ because there is no radical. Remember, the distance and the square of the distance have their max and min at the same point. Therefore, no need to differentiate the radical. Just differentiate $L=x^{2}+y^{2}$
That's a really super idea. Good insight.

So my solution is x=1.816, y=-1.816 and it looks roughly correct on a graph. Think it's right?

10. Yeah, that looks good.

11. Originally Posted by galactus
Yeah, that looks good.
Thanks for your fast responses and great help!