I think there is some confusion here - by definition a tangent just touches a circle at a single point
I think what you mean is that it returns the distance from the point to the closest point on the circles perimeter i.e the length of the Normal rather than the tangent?
So take the circle with a radius 3 x²+y²=9
if we take the point (0,1) then it's 2 units from the circle's perimeter at (0,3)
put this in to the left hand side and subtract the *Square Root* of the figure on the right and you get 1-3 = -2 which is what you're looking for
Not sure about an elipse - probably different as the above is so because the formula gives you the radius from a central point which obviously isn't true for an elipse
A bit of manipulation might get you a similar formula
Check out these resources:
http://www.mathopenref.com/ellipse.html (simple)
http://mathworld.wolfram.com/Ellipse.html (more complex)