Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 23 Feb 2019 21:30:31 +0100
From: Szabolcs Nagy <>
Cc: Shane Seelig <>
Subject: Re: x87 asin and acos

* Shane Seelig <> [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.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.