Ticket #12345: trac_12345_minusinfinity_sympyfication.patch

File trac_12345_minusinfinity_sympyfication.patch, 1.6 KB (added by jdemeyer, 10 years ago)

add _sympy_ method to MinusInfinity?

  • sage/rings/infinity.py

    # HG changeset patch
    # User D. S. McNeil <dsm054@gmail.com>
    # Date 1338006426 25200
    # Node ID 492d4883f71339510efec470ecadd717b818dbba
    # Parent  6c345ac8a80ecf9ed03a07896b98c608aa79f1e5
    Trac #12345: allow MinusInfinity to work with sympy
    
    diff --git a/sage/rings/infinity.py b/sage/rings/infinity.py
    a b  
    11931193        """
    11941194        raise SignError, "cannot take square root of negative infinity"
    11951195
     1196    def _sympy_(self):
     1197        """
     1198        Converts -oo to sympy -oo.
     1199       
     1200        Then you don't have to worry which oo you use, like in these
     1201        examples:
     1202       
     1203        EXAMPLE::
     1204       
     1205            sage: import sympy
     1206            sage: bool(-oo == -sympy.oo)
     1207            True
     1208            sage: bool(SR(-oo) == -sympy.oo)
     1209            True
     1210            sage: bool((-oo)._sympy_() == -sympy.oo)
     1211            True
     1212
     1213        """
     1214        import sympy
     1215        return -sympy.oo
     1216
     1217
    11961218class PlusInfinity(_uniq, AnInfinity, PlusInfinityElement):
    11971219
    11981220    _sign = 1
  • sage/symbolic/integration/integral.py

    diff --git a/sage/symbolic/integration/integral.py b/sage/symbolic/integration/integral.py
    a b  
    662662        sage: F(x=1, a=7).numerical_approx() # abs tol 1e-10
    663663        4.32025625668262
    664664
     665    Verify that MinusInfinity works with sympy (:trac:`12345`)::
     666   
     667        sage: integral(1/x^2, x, -infinity, -1, algorithm='sympy')
     668        1
     669
    665670    """
    666671    expression, v, a, b = _normalize_integral_input(expression, v, a, b)
    667672    if algorithm is not None: