|
From: Raymond T. <rt...@us...> - 2025-12-01 16:02:59
|
Here's one way for doing `cabs(x+%i*y)`, where `x` is a number. Divide by the arg by `sqrt(x)` to get `cabs(sqrt(x)+%i*y/sqrt(x))` = `sqrt(y^2/x+x)`. The final answer will be `sqrt(x)*sqrt(y^2/x+x)`. Something similiar if `y` is a number. I don't know how to do this if both `x` and `y` are more complicated expressions composed of numbers + variables. One alternative is to convert the floats to bfloats if we get an overflow. We don't normally do that anywhere else, so this would be very odd. I don't think a nounform would be a bad answer, if we printed a warning that there would be a potential overflow when computing the result. I personally think if a user is doing numerical stuff, it's his responsiblity to deal with numerical issues that might arise. We'll be careful to limit overflows, but we can't solve all the potential numerical issues that might arise. --- **[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 02:21 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. |