|
From: Raymond T. <rt...@us...> - 2025-12-01 17:49:23
|
Your example of `cabs(x+1e200+%i)` is nice and is only a problem if the result is expanded. I don't have an example off the top of my head that would be a problem. I'm somewhat opposed to converting to bfloats because we don't do that anywhere else, but I believe people have proposed this before. I agree that for numeric values we should do a good job. Matching existing libraries is pretty hard. Take a look at [fdlibm hypot](https://www.netlib.org/fdlibm/e_hypot.c). It's fairly complicated and not even correctly rounded. The ones that do correctly rounded results like [core-math hypot64](https://gitlab.inria.fr/core-math/core-math/-/blob/master/src/binary64/hypot/hypot.c) are even more complicated. FWIW, several years ago I translated lots of [fdlibm C routines to Javascript ](https://github.com/rtoy/fdlibm-js) (to get Chrome to fix it's broken trig functions!) We couldn't really do this in a portable way in Lisp. We have to figure out for each lisp how to get the actual bits of a float64 out. --- **[bugs:#4638] cabs/carg/polarform overflow and underflow** **Status:** open **Group:** None **Labels:** cabs carg **Created:** Sat Nov 29, 2025 07:18 AM UTC by Stavros Macrakis **Last Updated:** Mon Dec 01, 2025 05:18 PM UTC **Owner:** nobody ``cabs`` and ``carg`` on complex floats overflow and underflow even when the result is perfectly representable: <pre> cabs(1e-170 + %i*1e-170) => 0.0 but float(cabs(bfloat(1e-170 + %i*1e-170))) => 1.414213562373095e-170 cabs(1e170 + %i*1e+170) => overflow but float(cabs(bfloat(1e170 + %i*1e170))) => 1.4142135623730952e170 carg(1e170 + %i*1e+170)) => overflow but float(carg(bfloat(1e170 + %i*1e+170))) => 0.7853981633974483 carg(1e-310 + %i*1e-310) => overflow but carg(1b-310 + %i*1b-310) => 7.853981633974483b-1 polarform(1e170 + %i*1e+170) => overflow </pre> Tested in Maxima 5.48.1 SBCL 2.5.7 MacOS Intel --- Sent from sourceforge.net because max...@li... is subscribed to https://sourceforge.net/p/maxima/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/maxima/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |