Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: Alternative atan2 (was Motion 52: final ...)



On 2013-12-02 11:56:41 -0500, Michel Hack wrote:
> I was just thinking about why atan2() has this problem, but the other
> inverse-trig functions don't.  Wouldn't every periodic function have
> a problem with defining its inverse?

No, the problem is that atan2 has 2 arguments, so that you can follow
a path on a circle with values in a group like R/Z or similar, such as
R/(2pi)Z. In practice, on a computer, you'll take some representative
in R. This isn't much a problem when dealing with point functions,
except spurious discontinuity (but at Level 2 in fixed precision,
you no longer have the notion of continuity). But when considering
intervals, a small interval of R/Z isn't necessarily a small interval
of R containing the fixed choice of representatives.

[...]
> I think what we need are three point functions, atan2(), atan2p() and
> atan2m(), with respective ranges (-pi,+pi], [+pi,+3pi) and (-3pi,-pi],
> with a rule that selects the appropriate one, based on which argument
> contains zero (if any).  I guess [-pi,+pi]_trv would be returned if
> both arguments contain 0.
> 
> Actually, I'm confused now.  I can't figure out how one would decide
> between atan2p() and atan2m():  perhaps that choice would be fixed,
> and we only need two point functions, atan2() and atan2p().
> 
> In fact, I think we need to define overlapping ranges, i.e. to define
> atan2p() to have the range [0,+2pi).  Would that work?  My head is
> spinning: too many years since I had to think about any of this.
> 
> Suggestions?

I don't think [0,2pi) is OK. How would you represent [-eps,+eps]?
The interval can be almost a period (width = a bit less 2pi), and
its origin can be anywhere in a period, so that I would say that
you need 2 periods, e.g. [-2pi,2pi].

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)