From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id C6DB6275F0 for ; Thu, 15 Aug 2024 15:44:29 +0200 (CEST) Received: (qmail 24429 invoked by uid 550); 15 Aug 2024 13:44:24 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 24382 invoked from network); 15 Aug 2024 13:44:23 -0000 Date: Thu, 15 Aug 2024 09:44:15 -0400 From: Rich Felker To: Morten Welinder Cc: musl@lists.openwall.com Message-ID: <20240815134415.GO10433@brightrain.aerifal.cx> References: <21ca5c9-b1e-71b5-87b-a37f81f691ab@esi.com.au> <20240811200812.GZ3766212@port70.net> <7e9463-98a3-4b2-c10-e3fbf79a6b8@esi.com.au> <5918d2a7-7b3-932b-2b4-b24390832244@esi.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] catan(z) On Thu, Aug 15, 2024 at 09:18:19AM -0400, Morten Welinder wrote: > atan2 definitely isn't supposed to always output rational numbers on > rational input. > > atan2(+0,-1) is Pi. > atan2(-0,-1) is -Pi > atan2(1,1) is Pi/4 -- clearly not a rational number. > > These aren't exactly rational results (unless you mean their > floating-point approximations). The way I read it, the claim was not that the exact mathematical value of atan2 for some argument is rational, but that the floating point number returned by the C function is necessarily rational (because all floating point numbers are diadic rationals) and thus never actually equal to ±pi. This means you don't have any issue with whatever happens exactly at the endpoints. > On Sun, Aug 11, 2024 at 11:56 PM Damian McGuckin wrote: > > > > On Mon, 12 Aug 2024, Damian McGuckin wrote: > > > > > There is some argument that if you handle the special cases at infinity > > > separately (which I think MUSL should do but I do not have time at the > > > moment), then one can assume that because pi/2 is irrational, then one > > > should never have to deal with the end points in the chunk of code where > > > those two lines of code seen above should appear. I will have a chat > > > sometime with the guy who wrote that logic in a WG14 paper when I get a > > > really clear head and can line him up. > > > > Consider > > > > atan2(y, x) > > > > For any finite y and finite non-zero x floating point number arguments, > > i.e. rational numbers, the result of atan2(y, x) must be rational and so > > is never +/- pi (which is irrational and only occurs when the ration y/x > > is a mathematical infinity, not an overflowing infinity). So, we can > > ignore the endpoints as long as our special case handling takes care of > > the case of zero x. > > > > I think that is correct .... or is my brain still not working properly > > after too many late nights watching the Olympics. > > > > Thanks - Damian