4

I've noticed a strange behavior of Mathematica's ArcTan function with two arguments. If both arguments are 0 or 0., Mathematica evaluates the ArcTan to Indeterminate.

ArcTan[0, 0]
During evaluation of In[1]:= ArcTan::indet: Indeterminate expression ArcTan[0,0] encountered. >>
Indeterminate
ArcTan[0., 0.]
During evaluation of In[2]:= ArcTan::indet: Indeterminate expression ArcTan[0.,0.] encountered. >>
Indeterminate

However, I get different results if only one argument is using machine precision:

ArcTan[0., 0]
0
ArcTan[0, 0.]
π/2

No warning is displayed. This inconsistent behavior is causing problems in my code. Is it a bug or is it intentional? Why does this happen?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
shrx
  • 7,807
  • 2
  • 22
  • 55

1 Answers1

1

To Mathematica, 0. means "somewhere in the vicinity of zero". 0 means "exactly zero", much stronger. So, when you mix them, the stronger condition wins.

John Doty
  • 13,712
  • 1
  • 22
  • 42