Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240815134415.GO10433@brightrain.aerifal.cx>
Date: Thu, 15 Aug 2024 09:44:15 -0400
From: Rich Felker <dalias@...c.org>
To: Morten Welinder <mwelinder@...il.com>
Cc: musl@...ts.openwall.com
Subject: Re: 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 <damianm@....com.au> 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

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.