The formula in the linked answer is correct; however, the issue is that the equation for $t$ may have up to four solutions (it's a polynomial equation of 4th degree). In the specific example here,
-8768.46 is the right value of $t$ to use. It gives the point with approximate coordinates
(157,29), which is the correct answer:
When the point $(u,v)$ lies outside of the ellipse, the equation for $t$ has a unique negative root, and this is the one to pick.
When the point $(u,v)$ lies inside of the ellipse, all roots will be positive. I'm pretty sure that the smallest root should be used. This worked in all examples I tried. It matches the idea that smaller values of $t$ move the points by the least amount.
Thus, in either case you should pick the smallest value of $t$ that solves the equation.
To make the life of numerical routines easier, you should clear the denominators prior to solving. It makes the equation slightly longer for humans to read, but easier for numerical methods to handle.
$$ a^2u^2(b^2-t)^2 +b^2v^2(a^2-t)^2 =(a^2-t)^2 (b^2-t)^2 \tag1$$
Here is how I coded this in Maple:
a:=180; b:=60; u:=200; v:=100;
x0:=(a^2*u)/(a^2-t0); y0:= (b^2*v)/(b^2-t0);
fsolve is used instead of
solve may also find complex roots of the polynomial, making
min throw an error: complex numbers are not ordered. When used for polynomials,
fsolve finds all real roots. If I did not use clear denominators, it would find one real root only, not necessarily the one I want.
Finally, the graphic output part which made the plot shown above.
ellipse:= implicitplot(x^2/a^2+y^2/b^2=1, x=-a..a, y=-b..b, thickness=2):
points:= pointplot([[x0,y0],[u,v]], symbol=soliddiamond, symbolsize=20):