Opened 8 years ago

Closed 7 years ago

Last modified 4 years ago

#11423 closed defect (duplicate)

Make atan2(0,0) consistent

Reported by: kcrisman Owned by: burcin
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: symbolics Keywords: sd31
Cc: titusn Merged in:
Authors: Reviewers: Volker Braun, Titus Nicolae, Burcin Erocal
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by chapoton)

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.

Change History (12)

comment:1 Changed 8 years ago by kcrisman

  • Description modified (diff)

comment:2 Changed 8 years ago by vbraun

  • Keywords sd31 added

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

comment:3 Changed 8 years ago by kcrisman

Should that be reported upstream? Just curious.

comment:4 Changed 7 years ago by burcin

  • Cc titusn added

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.

comment:5 follow-up: Changed 7 years ago by burcin

  • Authors set to Volker Braun, Titus Nicolae
  • Milestone changed from sage-5.0 to sage-5.1

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?

comment:6 in reply to: ↑ 5 Changed 7 years ago by kcrisman

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.

comment:7 Changed 7 years ago by burcin

  • Reviewers set to Burcin Erocal
  • Status changed from new to needs_review

This was fixed with #12950.

comment:8 Changed 7 years ago by burcin

  • Status changed from needs_review to positive_review

comment:9 Changed 7 years ago by jdemeyer

  • Milestone changed from sage-5.1 to sage-5.2

comment:10 Changed 7 years ago by jdemeyer

  • Milestone changed from sage-5.2 to sage-duplicate/invalid/wontfix

comment:11 Changed 7 years ago by jdemeyer

  • Authors Volker Braun, Titus Nicolae deleted
  • Resolution set to duplicate
  • Reviewers changed from Burcin Erocal to Volker Braun, Titus Nicolae, Burcin Erocal
  • Status changed from positive_review to closed

comment:12 Changed 4 years ago by chapoton

  • Description modified (diff)
Note: See TracTickets for help on using tickets.