mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Norbert Lange <nolange79@gmail.com>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] asinf pulls in sqrt (double version)
Date: Thu, 10 Mar 2022 18:36:25 +0100	[thread overview]
Message-ID: <CADYdroMB0PCWjqSTeca2mzjMcqWgaZF9LH87=7M+jKVvh_p1RQ@mail.gmail.com> (raw)
In-Reply-To: <20220310170531.GV7074@brightrain.aerifal.cx>

Am Do., 10. März 2022 um 18:05 Uhr schrieb Rich Felker <dalias@libc.org>:
>
> On Thu, Mar 10, 2022 at 04:44:37PM +0100, Norbert Lange wrote:
> > Hello,
> >
> > pulled some of the math routines for a float-only project,
> > what I found is that asinf pulls in sqrt, and I cant tell whether this
> > is necessary because of precision.
> >
> > The line is in src/math/asinf.c:
> > s = sqrt(z);
>
> It looks like it's intentional -- s has type double and is used in an
> expression where the additional precision would make a difference:
>
>         x = pio2 - 2*(s+s*R(z));
>
> I suspect it would be more work (and slower) to get suitable precision
> without the double intermediate here, but I have not done the analysis
> myself.

the extended precision is necessary *if* "2*(s+s*R(z))" is close to pio2,
*or* s is close to -1 * s*R(z), so that it would cancel out several of
the highest bits.

Given that this block results in 1 > |x| >= 0.5, which is atleast
0.5 away from pio2 and 0, my gut tells me that this is not the case.

So my argument would be that sqrtf might be viable without affecting
the result at all or more than one ulp.
I know that this doesn't mean much without a proof.

Any hints where the algorithm is coming from?

Norbert

      reply	other threads:[~2022-03-10 17:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10 15:44 Norbert Lange
2022-03-10 17:05 ` Rich Felker
2022-03-10 17:36   ` Norbert Lange [this message]

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='CADYdroMB0PCWjqSTeca2mzjMcqWgaZF9LH87=7M+jKVvh_p1RQ@mail.gmail.com' \
    --to=nolange79@gmail.com \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).