# Closest point on Ellipse to a point on the interior.

Suppose you have the ellipse $$\frac{x^2}{a^2}+\frac{y^2}{b^2}=1$$. Suppose somewhere on the interior you have point $$P(m,n)$$. What is the closest point on the ellipse to the $$P$$? Can this be found without having to solve a 4th degree polynomial?

Because of symmetry, we can assume that $$P$$ is in the First Quadrant or on its boundary without loss of generality.

Lagrange multipliers come to mind. Perpendicularity. Figure most efficient approach is parameterization.

Let $$x=a\cos t$$, $$y=b\sin t$$. Let $$d^2=(x-m)^2+(y-n)^2$$.

Take the derivative of $$d^2$$ and set it to zero.

$$0=2(a\cos t-m)(-a\sin t)+2(b\sin t-n)(b\cos t)$$ $$0=(x-m)(\frac{-a}{b}y)+(y-n)(\frac{b}{a}x)$$

This represents a hyperbola passing through the origin and containing $$P(m,n)$$.

Expanding, then rearranging:

$$0=-2a^2\sin t\cos t+2ma\sin t+2b^2\sin t\cos t-2nb\cos t$$ $$nb\cos t=(b^2-a^2)\sin t\cos t+ma\sin t$$

Squaring both sides: $$n^2b^2\cos^2t=(b^2-a^2)^2\sin^2 t\cos^2 t+m^2a^2\sin^2 t+2ma(b^2-a^2)\sin^2 t\cos t$$

That $$\cos t$$ appears to the first power and $$\sin t$$ only to the second, this suggests swapping out $$\sin^2 t$$ with $(1-\cos^2 t): $$n^2b^2\cos^2t$$ $$=(b^2-a^2)^2\cos^2t(1-\cos^2 t)+m^2a^2(1-\cos^2t)-2ma(b^2-a^2)(1-\cos^2t)\cos t$$ or, $$n^2b^2\cos^2t=$$ $$(b^2-a^2)^2\cos^2t -(b^2-a^2)^2\cos^4t+m^2a^2-m^2a^2\cos^2t +2ma(b^2-a^2)\cos t -2ma(b^2-a^2)\cos^3t$$ Isolating $$\cos t$$ to one side: $$(b^2-a^2)^2\cos^4t+2ma(b^2-a^2)\cos^3t+[n^2b^2-(b^2-a^2)^2+m^2a^2]\cos^2 t-2ma(b^2-a^2)\cos t-m^2a^2=0$$ We now have a 4th order polynomial in $$\cos t$$. Numerical methods are available, but can it be reduced further? I think I've made some progress. The x-y form of the equation to be solved represents a hyperbola that passes through the origin as P(m,n). So there must be at least 2 points of intersection of the hyperbola with the ellipse. Swapping in $$(z+1/z)/2=\cos t$$ and $$(z-1/z)/(2i)=\sin t$$ and introducing $$z_0$$ to simply the coefficients a complex equation comes up: $$z^4+2z_0z^3-2\bar{z_0}z-1=0$$ • Seems more like degree 3 once cos t factored out. – coffeemath Oct 2 '18 at 16:01 • Does every term have cos t? If so, it's a cubic. Also, let$b^2-a^2=c^2$to simplify. Give names to the expressions. – marty cohen Oct 2 '18 at 16:04 • Why will this give back the same point? – AnotherJohnDoe Oct 2 '18 at 16:17 • This problem can be reformulate to concurrent normals through a given point. For a point inside the ellipse evolute, there're four concurrent normals (i.e. one absolute minimum and three local minima). Please refer to another post here. – Ng Chung Tak Oct 2 '18 at 16:55 • I'm not sure, but I think the non-uniform scaling might throw some things off. The squared distance being minimized in r=x/a, s=y/b (r,s) coordinates is$(r-\frac{m}{a})^2+(s-\frac{n}{b})^2$, the old squared distance being minimized in the new coordinates is$a^2(r-\frac{m}{a})^2+b^2(s-\frac{n}{b})^2\$. I need to sort out if minimizing the one minimizes the other. – TurlocTheRed Oct 2 '18 at 17:31