Novice user here. I was about to show off Mathematica's RegionNearest[] function to a mathematics teacher when I ran into the following. To simplify, the problem statement is: Find the closest point on the parabola y=x^2 to the point (-1/2,4), in decimals.
RegionNearest[ImplicitRegion[y - x^2 == 0, {x, y}], {-1/2, 4}] // N
gives the correct result. But if instead of (-1/2,4) you enter the point as (-0.5,4), i.e.
RegionNearest[ImplicitRegion[y - x^2 == 0, {x, y}], {-0.5, 4}]
you will get an (x,y) pair on the curve which is a local minimum in distance, not a global one. Minimize[EuclidieanDistance[]] seems to have the same issue.
On the other hand, if you form your own squared distance function (a quartic) and then apply Minimize[] to it, using either (-1/2,4) or (-0.5,4) for the point of interest, you will always get the correct value. I have attached a notebook demonstrating this behavior, including a plot. Minimize[] has been around for a long time and I would not be surprised it if checks the extrema and picks the global minimum for a polynomial function. RegionNearest[] does not seem to be doing that.
This is a bit concerning because I have been relying on RegionNearest[] as a shorthand way of getting the closest point on a curve to a point in the plane. Now I hope that no-one is using it for anything vital, such as directing a ship to shore!
Is this a bug or a feature that I have found, or am I missing the "point" somehow?
Attachments: