flintlib / arb

Arb has been merged into FLINT -- use https://github.com/flintlib/flint/ instead
http://arblib.org/
GNU Lesser General Public License v2.1
457 stars 137 forks source link

Issue 441: create arb_nonnegative_abs. #443

Closed postmath closed 1 year ago

postmath commented 1 year ago

Note the following behaviour. Taking the "nonnegative abs" of [0 \pm 1]:

arb_t t;
arb_init(t);
arf_zero(arb_midref(t));
mag_one(arb_radref(t));

arb_nonnegative_abs(t, t);

you don't get the exact interval [0.5 \pm 0.5], but instead the centre and radius are one ulp (of a mag_t) greater than that. That ulp is introduced in arf_get_mag. I'm not sure there is an obvious workaround for that. (The example I ran into started with [0 \pm 0.25], but I think [0 \pm 1] should work the same.)

Note furthermore that the "whole real line" object can be returned by this function, which still contains negative numbers. So the result does not always satisfy arb_is_nonnegative. Neither does NaN, of course. I think those are the only two cases.

fredrik-johansson commented 1 year ago

Looks good. If you prefer a different name for this function, I don't mind changing it.

arf_get_mag rounds inexactly for speed reasons. It would indeed be better to make it round exactly, so that cases like this work as expected, having an arf_get_mag_sloppy for the cases where saving the 1-2 cycles matters.

postmath commented 1 year ago

No need for the other name, I changed my mind and I like this version now :)

On Fri, Nov 11, 2022, 16:33 Fredrik Johansson @.***> wrote:

Looks good. If you prefer a different name for this function, I don't mind changing it.

arf_get_mag rounds inexactly for speed reasons. It would indeed be better to make it round exactly, so that cases like this work as expected, having an arf_get_mag_sloppy for the cases where saving the 1-2 cycles matters.

— Reply to this email directly, view it on GitHub https://github.com/fredrik-johansson/arb/pull/443#issuecomment-1312208117, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACDYH3WOT3FCQYKJXSLC6C3WH23TPANCNFSM6AAAAAAR5VFV2Y . You are receiving this because you authored the thread.Message ID: @.***>