From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13849 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: x87 asin and acos Date: Sat, 23 Feb 2019 14:57:02 -0500 Message-ID: <20190223195702.GN23599@brightrain.aerifal.cx> References: <20190223150858.GM23599@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="152331"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Shane Seelig To: musl@lists.openwall.com Original-X-From: musl-return-13865-gllmg-musl=m.gmane.org@lists.openwall.com Sat Feb 23 20:57:19 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1gxdQE-000dWe-Du for gllmg-musl@m.gmane.org; Sat, 23 Feb 2019 20:57:18 +0100 Original-Received: (qmail 13891 invoked by uid 550); 23 Feb 2019 19:57:15 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 13870 invoked from network); 23 Feb 2019 19:57:14 -0000 Content-Disposition: inline In-Reply-To: <20190223150858.GM23599@brightrain.aerifal.cx> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:13849 Archived-At: On Sat, Feb 23, 2019 at 10:08:58AM -0500, Rich Felker wrote: > On Sat, Feb 23, 2019 at 09:21:08AM -0500, Shane Seelig wrote: > > 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))) > > They don't seem to be numerically equal. For example, if x is smaller > than sqrt(LDBL_EPSILON/2), 1-x**2 is 1, but (1-x)*(1+x) is not. I > don't recall the process of writing the function in detail, but I'm > pretty sure this matters to the result, especially since sqrt then > expands the magnitude of the error. After some discussion on irc, I think the above may be wrong. I'm not sure if there are other cases where it can matter, but if not this is probably a valid, and maybe useful, optimization. Rich