From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13853 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Damian McGuckin Newsgroups: gmane.linux.lib.musl.general Subject: Re: x87 asin and acos Date: Sun, 24 Feb 2019 13:53:31 +1100 (AEDT) Message-ID: References: <20190223150858.GM23599@brightrain.aerifal.cx> <20190223195702.GN23599@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="211725"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) Cc: Shane Seelig To: musl@lists.openwall.com Original-X-From: musl-return-13869-gllmg-musl=m.gmane.org@lists.openwall.com Sun Feb 24 03:53:52 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 1gxjvL-000szz-6p for gllmg-musl@m.gmane.org; Sun, 24 Feb 2019 03:53:51 +0100 Original-Received: (qmail 30109 invoked by uid 550); 24 Feb 2019 02:53:48 -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 30091 invoked from network); 24 Feb 2019 02:53:47 -0000 X-Authentication-Warning: key0.esi.com.au: damianm owned process doing -bs In-Reply-To: <20190223195702.GN23599@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:13853 Archived-At: On Sat, 23 Feb 2019, Rich Felker wrote: >> 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. >> 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. Yes and no. Interestingly, if you to look at double (or float) for now 1 - x**2 == 1 if |x| < sqrt(DBL_EPSILON/2) whereas (1 - x) is not 1 nor is (1 + x) although interesting, to the precision (a (1 - x) * (1 + x) == 1 if DBL_EPSILON/2 < |x| < sqrt(DBL_EPSILON/2) But at |x| == DBL_EPSILON/2 (== the round bit) (1 + x) == 1 but (1 - x) != 1 and so (1 + x) * (1 - x) != 1 because DBL_EPSILON/2 affects the round bit. That said sqrt((1 - x) * (1 + x)) = 1 + 0.5 * x == 1 because (DBL_EPSILON/2) * 0.5 is half the round bit and does not affect it. So, the formula does not affect the result of the sqrt(). The same happens for floats. I think the same can be said for long double. Regards - Damian Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037 Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here Views & opinions here are mine and not those of any past or present employer