Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong atan2 of complex arguments #22877

Closed
rwst opened this issue Apr 26, 2017 · 13 comments
Closed

Wrong atan2 of complex arguments #22877

rwst opened this issue Apr 26, 2017 · 13 comments

Comments

@rwst
Copy link

rwst commented Apr 26, 2017

sage: atan2(CC(I), CC(I+1))
0.615479708670387
sage: atan2(I, I+1)
arctan2(I, I + 1)
sage: atan2(CBF(I), CBF(I+1))
...
/home/ralf/sage/src/sage/libs/pynac/pynac.pyx in sage.libs.pynac.pynac.py_atan2 (build/cythonized/sage/libs/pynac/pynac.cpp:21132)()
   1798         P = RR
   1799     if y != 0:
-> 1800         if x > 0:
   1801             res = py_atan(abs(y/x))
   1802         elif x < 0:
...
TypeError: No order is defined for ComplexBalls.

But both SymPy and Wolfram Alpha use the form atan2(y,x) = -I*log((x + I*y)/sqrt(x^2 + y^2)) for complex x,y:

In [18]: atan2(I,I+1)
Out[18]: 
      ⎛        ⅈ         ⎞
-ⅈ⋅log⎜──────────────────⎟
      ⎜   _______________⎟
      ⎜  ╱             2 ⎟
      ⎝╲╱  -1 + (1 + ⅈ)  ⎠

In [19]: _.n()
Out[19]: 0.553574358897045 + 0.402359478108525⋅ⅈ

which is arctan(1/2*I + 1/2).
(Wolfram reverses the argument and so one must input arctan(I+1,I) there)

Component: calculus

Author: Ralf Stephan

Branch/Commit: f5c35ff

Reviewer: Travis Scrimshaw

Issue created by migration from https://trac.sagemath.org/ticket/22877

@rwst rwst added this to the sage-8.0 milestone Apr 26, 2017
@rwst

This comment has been minimized.

@rwst

This comment has been minimized.

@rwst rwst changed the title atan2 of complex arguments inconsistencies Wrong atan2 of complex arguments May 2, 2017
@rwst
Copy link
Author

rwst commented May 2, 2017

@rwst
Copy link
Author

rwst commented May 2, 2017

New commits:

88e55d122877: Wrong atan2 of complex arguments

@rwst
Copy link
Author

rwst commented May 2, 2017

Commit: 88e55d1

@rwst
Copy link
Author

rwst commented May 2, 2017

Author: Ralf Stephan

@tscrim
Copy link
Collaborator

tscrim commented May 3, 2017

comment:6

LGTM.

@tscrim
Copy link
Collaborator

tscrim commented May 3, 2017

Reviewer: Travis Scrimshaw

@rwst
Copy link
Author

rwst commented May 3, 2017

comment:7

Thanks.

@vbraun
Copy link
Member

vbraun commented May 5, 2017

comment:8
[sagelib-8.0.beta5]     if P in (float, RR, RBF):
[sagelib-8.0.beta5]                           ^
[sagelib-8.0.beta5] ------------------------------------------------------------
[sagelib-8.0.beta5] 
[sagelib-8.0.beta5] sage/libs/pynac/pynac.pyx:1807:27: undeclared name not builtin: RBF

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 6, 2017

Changed commit from 88e55d1 to f5c35ff

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented May 6, 2017

Branch pushed to git repo; I updated commit sha1. New commits:

401237eMerge branch 'develop' into t/22877/atan2_of_complex_arguments_inconsistencies
f5c35ff22877: fix reality check

@vbraun
Copy link
Member

vbraun commented May 11, 2017

Changed branch from u/rws/atan2_of_complex_arguments_inconsistencies to f5c35ff

@vbraun vbraun closed this as completed in dd7d64f May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants