Dealing with a Discontinuous ArcTan[] Function in Mathematica

  • Context: Mathematica 
  • Thread starter Thread starter guerom00
  • Start date Start date
  • Tags Tags
    Bug Mathematica
Click For Summary

Discussion Overview

The discussion revolves around the behavior of the ArcTan function in Mathematica when applied to complex arguments. Participants explore the discrepancies in results when using complex numbers versus real numbers, particularly focusing on the discontinuities and branch cuts associated with the function.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant notes that the output of ArcTan[x, y] appears incorrect when x and y are complex, suggesting that the function may assume real inputs.
  • Another participant references the help page, indicating that ArcTan can handle complex arguments, but expresses confusion over the nature of x and y in their specific case.
  • There is a discussion about the interpretation of ArcTan[x, y] as ArcTan[y/x], which could lead to complex results if either argument is complex.
  • Concerns are raised about numerical computation and the behavior of algorithms near special values, with one participant suggesting that branch cuts may be influencing the results.
  • A participant points out that the differences in results from Wolfram Alpha can be subtle, indicating that the complex version of the function may not be consistently applied.
  • One participant acknowledges the discontinuity in the function at certain points and mentions the need for specific tests to handle these cases.

Areas of Agreement / Disagreement

Participants generally agree that there are issues with the behavior of ArcTan when dealing with complex numbers, but multiple competing views remain regarding the interpretation and implications of these results. The discussion does not reach a consensus on the underlying cause of the discrepancies.

Contextual Notes

Participants express uncertainty about the definitions and behavior of the ArcTan function with complex arguments, particularly in relation to numerical stability and branch cuts. There are unresolved questions about the implications of using approximate values in calculations.

guerom00
Messages
90
Reaction score
0
Hello everyone,

I copy-paste here a little bit of code:
Code:
In[4417]:= x = (1.5` + 0.` I);
y = (0.` + 0.` I);

(* 1 *) ArcTan[x, y]
(* 2 *) ArcTan[x // Chop, y // Chop]
(* 3 *) -I Log[(x + I y)/Sqrt[x^2 + y^2]]
{y == 0, Re[y] == 0, Im[y] == 0, Im[x] == 0}

Out[4419]= -1.5708 + 0. I

Out[4420]= 0

Out[4421]= 0. + 0. I

Out[4422]= {True, True, True, True}

The quantities x and y are calculated elsewhere.
The expression 1 for the arctangent is wrong since it gives me -pi/2 :confused:
In expression 2, I chop the arguments and the result is right.
Expression 3 is used when x or y is complex and gives the right answer as well.
Finally, some tests…

Any thoughts ?
TIA
 
Physics news on Phys.org
I agree it looks wrong, but I think ArcTan[x,y] is assuming x and y are both real. It must have a problem when thy are complex.
 
The help page of ArcTan[x,y] indicates that it can handle complex arguments. It then uses the expression which involves the Log[] I gave.
Problem is: my quantities x and y are not complex according to the tests I make… Which is strange because I thought that the number 0.` is different from 0 (== wise)…
 
ArcTan[x] should handle complex arguments, but what does ArcTan[x,y] even mean when the arguments are complex?
 
guerom00 said:
WTF ?! This is clearly broken, no ?
No and yes.

No, in the sense that you should expect numerical algorithms to misbehave at special values. Yes, in the sense that it's a little surprising these values are special.


What's most likely happening internally is that there is an algebraic identity being used and your point is right on a branch cut of the terms involved. And because your numbers are approximate, different sides of the branch cut wind up being used in different terms.
 
  • #10
I see now… :)
Well, that doesn't solve my problem: I now have a function of this angle (I use this ArcTan[] to calculate an angle, obviously) which is discontinuous at one point… I'll have to make a specific test to avoid this very point.

Thanks :)
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K