Ticket #12950: trac_11423-atan_error.patch

File trac_11423-atan_error.patch, 2.7 KB (added by burcin, 8 years ago)
  • sage/functions/other.py

    # HG changeset patch
    # User Titus Nicolae <nicolaetitus12@gmail.com>
    # Date 1336851175 -7200
    # Node ID 329827139f0960a2427141901bd58c3315c95e46
    # Parent  6eda1f634b03c9b725a1bacd854d85b1aa22df90
    Doctest changes after atan(0,0) started raising an error in Pynac.
    
    diff --git a/sage/functions/other.py b/sage/functions/other.py
    a b  
    16571657            arg(sqrt(2) + I)
    16581658
    16591659        """
    1660         if not isinstance(x,Expression):
    1661             # x contains no variables
    1662             if is_inexact(x):
    1663                 # inexact complex numbers, e.g. 2.0+i
    1664                 return self._evalf_(x, parent(x))
     1660        if not isinstance(x,Expression): # x contains no variables
     1661            if parent(x)(0)==x: #compatibility with maxima
     1662                return parent(x)(0)
    16651663            else:
    1666                 # exact complex numbers, e.g. 2+i
    1667                 return arctan2(imag_part(x),real_part(x))
     1664                if is_inexact(x): # inexact complex numbers, e.g. 2.0+i
     1665                    return self._evalf_(x, parent(x))
     1666                else:  # exact complex numbers, e.g. 2+i
     1667                    return arctan2(imag_part(x),real_part(x))
    16681668        else:
    16691669            # x contains variables, e.g. 2+i+y or 2.0+i+y
    16701670            # or x involves an expression such as sqrt(2)
  • sage/functions/trig.py

    diff --git a/sage/functions/trig.py b/sage/functions/trig.py
    a b  
    853853
    854854            sage: arctan2(0, -log(2)).n()
    855855            3.14159265358979
     856
     857        Check if atan2(0,0) throws error #11423::
     858
     859            sage: atan2(0,0)
     860            Traceback (most recent call last):
     861            ...
     862            RuntimeError: arctan2_eval(): arctan2(0,0) encountered
     863
     864            sage: atan2(0,0,hold=True)
     865            arctan2(0, 0)
     866
     867            sage: atan2(0,0,hold=True).n()
     868            Traceback (most recent call last):
     869            ...
     870            ValueError: arctan2(0,0) undefined
     871           
    856872        """
    857873        GinacFunction.__init__(self, "arctan2", nargs=2, latex_name=r'\arctan',
    858874                conversions=dict(maxima='atan2', sympy='atan2'))
  • sage/symbolic/expression.pyx

    diff --git a/sage/symbolic/expression.pyx b/sage/symbolic/expression.pyx
    a b  
    56615661            0.0
    56625662            sage: maxima('atan2(0,0.6)')
    56635663            0.0
    5664             sage: SR(0).arctan2(0)
    5665             0
    5666            
     5664            sage: SR(0).arctan2(0) #11423
     5665            Traceback (most recent call last):
     5666            ...
     5667            RuntimeError: arctan2_eval(): arctan2(0,0) encountered
    56675668            sage: SR(I).arctan2(1)
    56685669            arctan2(I, 1)
    56695670            sage: SR(CDF(0,1)).arctan2(1)