On Thu, Aug 15, 2024 at 12:12:35PM +1000, Damian McGuckin wrote: > On Wed, 14 Aug 2024, Rich Felker wrote: > > >If I'm following, it sounds like the current behavior is either a > >no-op or wrong and removing the _redupi step entirely would make it > >correct or at least closer to correct. Do you agree? > > Just a no-op. Unless there is some subtle reason why Moshier did > this why I am too dumb to understand. I think the issue was that > back in the 80s when he wrote it, there were some unstandardised > atan2() routines which (Moshier alluded to in his book and which) > returned results in [0,2*pi] rather than the now standardized > routines with return in [-pi,+pi] and he was handling those issues. > > >Any suggestions for a test to run? I did some basic smoke testing for > >large positive real inputs and got expected results. > > Not off hand. Other issues taking my brain cycles right nnow. Young > Mr Nagy might have a better idea. OK, that makes sense. Proposed patch attached. I think the code could (maybe should) actually be reordered and simplified at some point without confusing reuse of temporaries and without temp storage of the real result in a complex var, but I made the patch a minimal bad-code-removal for now. Further cleanup could be done separately. Rich