mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Szabolcs Nagy <nsz@port70.net>
To: musl@lists.openwall.com
Cc: Shane Seelig <stseelig@mail.com>
Subject: Re: x87 asin and acos
Date: Sat, 23 Feb 2019 21:30:31 +0100	[thread overview]
Message-ID: <20190223203030.GX21289@port70.net> (raw)
In-Reply-To: <e5a4695c-2333-f496-88ab-51b2241696e6@mail.com>

* Shane Seelig <stseelig@mail.com> [2019-02-23 09:21:08 -0500]:
> Currently 'asin' uses the algorithm:
> 	arcsin(x) == arctan(x/(sqrt((1-x)(1+x))))
> If the following algorithm were to be used instead, an 'fadd' could be
> removed.
> 	arcsin(x) == arctan(x/(sqrt(1-x**2)))

that change seems valid as far as the result is concerned.
(the worst case rounding error of the sqrt argument should
be around LDBL_EPS in both cases)

but the fenv behaviour is not valid:
for tiny x, x*x raises spurious underflow exception
for large x, x*x raises spurious overflow exception

(1-x)(1+x) avoids these issues.

note that there is not much performance difference between
the two expressions: 1-x and 1+x are independent computations
so the latency is 1 add + 1 mul in both cases, and the entire
function is likely dominated by fpsqrt followed by fpatan
both of which have huge latency compared to add or mul.


  parent reply	other threads:[~2019-02-23 20:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-23 14:21 Shane Seelig
2019-02-23 15:08 ` Rich Felker
2019-02-23 19:57   ` Rich Felker
2019-02-24  2:53     ` Damian McGuckin
2019-02-23 20:30 ` Szabolcs Nagy [this message]
2019-02-23 20:36   ` Szabolcs Nagy

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=20190223203030.GX21289@port70.net \
    --to=nsz@port70.net \
    --cc=musl@lists.openwall.com \
    --cc=stseelig@mail.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).