public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wdijkstr at arm dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug math/28472] pow(10, i) accuracy
Date: Mon, 04 Mar 2024 18:27:42 +0000	[thread overview]
Message-ID: <bug-28472-131-gFlmq98BHG@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28472-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=28472

--- Comment #19 from Wilco <wdijkstr at arm dot com> ---
(In reply to Vincent Lefèvre from comment #18)
> (In reply to Wilco from comment #17)
> > (In reply to Vincent Lefèvre from comment #16)
> > > (In reply to Wilco from comment #15)
> > > > GLIBC double precision pow is the most accurate of all libraries tested at
> > > > 0.523 ULP [1].
> > > 
> > > What you forget is that this is the accuracy *tested* on arbitrary values.
> > > The actual accuracy may be worse. And this is the case here, with an
> > > accuracy larger than 1 ulp, according to the results in Comment #6!
> > 
> > Please see the implementation - it documents the accuracy across the full
> > input ranges. The worst-case reported by random testing is slightly lower
> > due to not being able to test all input values.
> 
> OK, this is something that is new to me. So perhaps [1] should also document
> the proved error bounds.

That might be too much work to figure out for every math library (AFAIK only
GLIBC documents these error bounds in the implementations). Note the final
result vary depending on FMA support, evaluation order etc.

> > Ie. if we have an algorithm that does < 0.55ULP before rounding, we can't ever > get a 2 ULP error.
> 
> OK, but in addition to the source, such proved error bounds (assuming no
> mistakes in the analysis) should be given in the glibc manual.
> 
> Also, note that an error < 0.55 ULP before rounding does not guarantee that
> pow(2,i) will be correct for the integers i. So, perhaps more should be said.

As it happens, it does work out perfectly for pow(2, i) and exp2(i). Only exp10
and pow(10, i) have a few cases that are not:

exp10(126): 0x1.7a2ecc414a04p+418 0x1.7a2ecc414a03f7ff6ca1cb527788p+418

pow(10, 23): 0x1.52d02c7e14af7p+76 0x1.52d02c7e14af68p+76 
pow(10, 210): 0x1.8557f31326bbcp+697 0x1.8557f31326bbb7fcd59ff127a01dp+697 

These are very close to the halfway rounding point and would need an extra 16
bits internal precision to get right. pow(10, 23) is exactly on the mid-point,
so is even harder.

Note GLIBC previously had some correctly rounded math functions, but they were
a total nightmare. Whenever you got close to a halfway point, performance
dropped by a factor of a million times, even for cases that were relatively
easy.

That's a lesson learnt that we don't ever want to repeat again.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2024-03-04 18:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 23:54 [Bug math/28472] New: " mwelinder at gmail dot com
2021-10-19 15:44 ` [Bug math/28472] " joseph at codesourcery dot com
2021-10-19 21:28 ` mwelinder at gmail dot com
2021-10-19 21:42 ` joseph at codesourcery dot com
2021-10-25  8:44 ` newbie-02 at gmx dot de
2021-11-14  5:38 ` newbie-02 at gmx dot de
2022-01-24 21:45 ` mwelinder at gmail dot com
2022-01-24 21:56 ` joseph at codesourcery dot com
2022-09-23 16:33 ` newbie-02 at gmx dot de
2023-01-09 14:43 ` newbie-02 at gmx dot de
2023-01-09 18:35 ` joseph at codesourcery dot com
2023-01-09 21:23 ` newbie-02 at gmx dot de
2023-01-09 21:36 ` joseph at codesourcery dot com
2023-01-10  0:23 ` newbie-02 at gmx dot de
2024-03-02 22:53 ` vincent-srcware at vinc17 dot net
2024-03-04 14:58 ` wdijkstr at arm dot com
2024-03-04 15:35 ` vincent-srcware at vinc17 dot net
2024-03-04 16:07 ` wdijkstr at arm dot com
2024-03-04 17:09 ` vincent-srcware at vinc17 dot net
2024-03-04 18:27 ` wdijkstr at arm dot com [this message]
2024-03-04 19:23 ` vincent-srcware at vinc17 dot net
2024-03-18 21:09 ` newbie-02 at gmx dot de
2024-03-18 22:17 ` wdijkstr at arm dot com
2024-03-20  9:02 ` newbie-02 at gmx dot de
2024-03-20  9:56 ` vincent-srcware at vinc17 dot net
2024-03-20 13:54 ` wdijkstr at arm dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28472-131-gFlmq98BHG@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).