Improve `rationalize` fallback result (#61297)
Fixes #61296
When the result of `rationalize(T, x, tol)` doesn't fit in `T` (ie.
rational components overflows `T`) the function catches the error and
returns the last convergent that has been computed, which is not
necessarily the best rational approximation of `x` for `T`. With this
fix, the catch block tries to find a semi-convegent closer to `x` than
the last convergent and if such rational exists returns it, otherwise it
returns the last convergent.
---------
Co-authored-by: Andy Dienes <51664769+adienes@users.noreply.github.com>