Ticket #12237: trac_12237_complex_erfc.patch

File trac_12237_complex_erfc.patch, 1.8 KB (added by Volker Braun, 11 years ago)

Initial patch

  • sage/functions/other.py

    # HG changeset patch
    # User Volker Braun <vbraun@stp.dias.ie>
    # Date 1325267921 0
    # Node ID 547974050a2468583bd1c98d5d29a459a55831f9
    # Parent  29829c29f3379831ac259e5fd359d27b638ee577
    Trac #12237: erf of complex arguments
    
    diff --git a/sage/functions/other.py b/sage/functions/other.py
    a b  
    4040            erf(2)
    4141            sage: erf(2).n()
    4242            0.995322265018953
     43            sage: erf(2+I).n()
     44            1.00360634272565 - 0.0112590060288150*I
    4345            sage: loads(dumps(erf))
    4446            erf
    4547
    46         The following fails because we haven't implemented
    47         erf yet for complex values::
    48        
    49             sage: complex(erf(3*I))
    50             Traceback (most recent call last):
    51             ...
    52             TypeError: unable to simplify to complex approximation
    53 
    5448        TESTS:
    5549
    5650        Check if conversion from maxima elements work::
     
    7165            Traceback (most recent call last):
    7266            ...
    7367            NotImplementedError: erf not implemented for precision higher than 53
     68
     69        TESTS::
     70
     71            sage: integrate(sin(x)*(x^(1/2)),x,0,1).n()   # maxima's solution involves erf(complex)
     72            0.364221932032132
     73            sage: type( erf(2+I).n() )
     74            <type 'sage.rings.complex_number.ComplexNumber'>
     75            sage: type( erf(2).n() )
     76            <type 'sage.rings.real_mpfr.RealNumber'>
    7477        """
    7578        try:
    7679            prec = parent.prec()
     
    7881            prec = 0
    7982        if prec > 53:
    8083            raise NotImplementedError, "erf not implemented for precision higher than 53"
    81         return parent(1 - pari(float(x)).erfc())
     84        return parent(1 - pari(complex(x)).erfc())
    8285       
    8386    def _derivative_(self, x, diff_param=None):
    8487        """