[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can math.atan2 return INF?

On Thu, 23 Jun 2016 05:17 am, Ben Bacarisse wrote:

> pdorange at pas-de-pub-merci.mac.com (Pierre-Alain Dorange) writes:
>> Ben Bacarisse <ben.usenet at bsb.me.uk> wrote:
>>>   >>> math.atan2(INF, INF)
>>>   0.7853981633974483
>>> I would have expected NaN since atan2(INF, INF) could be thought of as
>>> the limit of atan2(x, y) which could be any value in the range.  And I'd
>>> have guessed atan2(0, 0) would have been NaN too but
>> i'm not a math expert, but the limit of atan2 would be 45?, so pi/4
>> radians (0,7854).
>> As x,y are coordinates, the both infinite would tend toward 45?.
> The limit of atan2(x, x) is as you describe, but there is no reason to
> pick that one case.


x = INF
y = INF
assert x == y

there is a reason to pick atan2(y, x) = pi/4:

Since x == y, the answer should be the same as for any other pair of x == y.

It might not be a *great* reason, but it's a reason.