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

Make atan2(0,0) consistent #11423

Closed
kcrisman opened this issue Jun 3, 2011 · 13 comments
Closed

Make atan2(0,0) consistent #11423

kcrisman opened this issue Jun 3, 2011 · 13 comments

Comments

@kcrisman
Copy link
Member

kcrisman commented Jun 3, 2011

This is bad:

    sage: atan2(0,0)
    0
    sage: atan2(0,0,hold=True)
    arctan2(0, 0)
    sage: atan2(0,0,hold=True).n()
    ValueError: arctan2(0,0) undefined
    sage: atan2(0,0,hold=True).simplify()
    -----------------------------------------------------
    TypeError: Error executing code in Maxima
    CODE:
    sage1 : atan2(0,0)$
    Maxima ERROR:
    
    atan2: atan2(0,0) is undefined.
     -- an error. To debug this try: debugmode(true);

Probably we should make sure that atan2(0,0) always raises an error. Wolfram Alpha/Mathematica gives the interval from -pi to pi, which seems as good as any answer, and who knows what others do.

Originally reported at ask.sagemath.org.

CC: @sagetrac-titusn

Component: symbolics

Keywords: sd31

Reviewer: Volker Braun, Titus Nicolae, Burcin Erocal

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

@kcrisman kcrisman added this to the sage-5.0 milestone Jun 3, 2011
@kcrisman

This comment has been minimized.

@vbraun
Copy link
Member

vbraun commented Jun 18, 2011

comment:2

I made a patch to pynac yield the following. I'll try to push the patch into the new pynac release at #9880.

sage: atan2(0,0)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)

/home/vbraun/opt/sage-4.7.1.alpha2/devel/sage-main/<ipython console> in <module>()

/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/symbolic/function.so in sage.symbolic.function.GinacFunction.__call__ (sage/symbolic/function.cpp:6712)()

/home/vbraun/Sage/sage/local/lib/python2.6/site-packages/sage/symbolic/function.so in sage.symbolic.function.Function.__call__ (sage/symbolic/function.cpp:4650)()

RuntimeError: arctan2_eval(): arctan2(0,0) encountered

@vbraun
Copy link
Member

vbraun commented Jun 18, 2011

Changed keywords from none to sd31

@kcrisman
Copy link
Member Author

comment:3

Should that be reported upstream? Just curious.

@burcin
Copy link

burcin commented May 12, 2012

comment:4

GiNaC probably got atan2(0,0) -> 0 from Maple:

    |\^/|     Maple 12 (X86 64 LINUX)
._|\|   |/|_. Copyright (c) Maplesoft, a division of Waterloo Maple Inc. 2008
 \  MAPLE  /  All rights reserved. Maple is a trademark of
 <____ ____>  Waterloo Maple Inc.
      |       Type ? for help.
> arctan(0,0);
                                       0

MMA prints an error like Maxima:

In[5]:= ArcTan[0,0]

ArcTan::indet: Indeterminate expression ArcTan[0, 0] encountered.

Out[5]= Interval[{-Pi, Pi}]

Titus points out that with Volker's patch, arg(0) in Sage also gives an error. All of MMA, Maple and Maxima evaluate that to 0 though.

@burcin
Copy link

burcin commented May 15, 2012

Author: Volker Braun, Titus Nicolae

@burcin
Copy link

burcin commented May 15, 2012

comment:5

Pynac 0.2.4 (#12950), includes the patch Volker mentioned in comment:2. Attached to that ticket there is also a patch by Titus fixing failing doctests in symbolics related files and modifying the arg() function so that arg(0) still returns 0.

Apparently this change breaks some tests in 3d plotting. We should open a ticket with that and make this one depend on it. Titus, can you handle that?

@burcin burcin modified the milestones: sage-5.0, sage-5.1 May 15, 2012
@kcrisman
Copy link
Member Author

comment:6

Apparently this change breaks some tests in 3d plotting. We should open a ticket with that and make this one depend on it. Titus, can you handle that?

And please cc me on that ticket, thanks.

@burcin
Copy link

burcin commented Jun 29, 2012

comment:7

This was fixed with #12950.

@burcin
Copy link

burcin commented Jun 29, 2012

Reviewer: Burcin Erocal

@jdemeyer
Copy link

jdemeyer commented Jul 4, 2012

Changed reviewer from Burcin Erocal to Volker Braun, Titus Nicolae, Burcin Erocal

@jdemeyer
Copy link

jdemeyer commented Jul 4, 2012

Changed author from Volker Braun, Titus Nicolae to none

@fchapoton

This comment has been minimized.

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

5 participants