\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage[osf]{mathpazo}
\usepackage{euler}
\renewcommand\ttdefault{pxtt}
\parindent 0pt
\begin{document}

An ellipse centered at $(0,0)$ with semi-axes of length $a$ and $b$
aligned with the x- and y-axes respectively, is defined by the
familiar equation $u^2\slash a^2 + v^2\slash b^2 = 1$, where $(u,v)$
is a point on the ellipse.  In this analysis we care only about the
first quadrant ($0\le u \le a$, $0 \le v \le b$), so
\begin{equation}\label{vfromu}
v = \frac{b}{a}\sqrt{a^2 - u^2}
\end{equation}
The squared Euclidean distance from an arbitrary point $(x,y)$ to a point on
the ellipse is then
\begin{equation}\label{distance}
||d||^2 = (u - x)^2 + \left(\frac{b}{a}\sqrt{a^2 - u^2} - y\right)^2
\end{equation}
We wish to minimize this as a function of $u$; the first derivative is
\begin{equation*}
\frac{\partial ||d||^2}{\partial u} =
2\left(
 u - x + \frac{byu}{a\sqrt{a^2-u^2}} - \frac{b^2u}{a^2}
\right)
\end{equation*}
Ignoring the removable singularity when $a = u$, this is zero when
\begin{equation*}
\frac{by}{\sqrt{a^2-u^2}} = \frac{a^2x + (b^2 - a^2)\,u}{au}
\end{equation*}
Multiplying out the fractions and taking the square of both sides,
\begin{equation*}
\bigl(abyu\bigr)^2 = \bigl(a^2-u^2\bigr)\bigl(a^2x + (b^2-a^2)\,u\bigr)^2
\end{equation*}
or in polynomial form
\begin{equation}\label{polyderiv}
\begin{aligned}
   &\; u^4\;\phantom{2a^2x^2}\,(b^4-2a^2b^2+a^4)
\\+&\; u^3\;2a^2x^{\phantom{2}}\,(b^2-a^2)
\\-&\; u^2\;\phantom{2}a^2\phantom{x^2}\,(b^4-2a^2b^2+a^4-b^2y^2-a^2x^2)
\\-&\; u^{\phantom{2}}\;2a^4x^{\phantom{2}}\,(b^2-a^2)
\\-&\; \phantom{u^2}\;\phantom{2}a^6x^2
\\=&\; 0
\end{aligned}
\end{equation}
One of the four roots of this polynomial will be the x-coordinate $u$
of the point $(u,v)$ on the ellipse closest to our test point $(x,y)$.
There is an algebraic expression for the roots, but it is too large to
write down.  Instead, we find numeric values of the roots using a
standard algorithm, substitute those that are real-valued and positive
back into equation (\ref{distance}) and pick whichever one gives the
shortest distance.  (In practice there is only one real-valued
positive root.)
\end{document}
