Ticket #8568: trac_8568-erf-deriv.patch

File trac_8568-erf-deriv.patch, 1.2 KB (added by burcin, 3 years ago)
  • sage/functions/other.py

    # HG changeset patch
    # User Karl-Dieter Crisman <kcrisman@gmail.com>
    # Date 1274975156 14400
    # Node ID a4a7a2386364dbced964bb66ecb68449c824e6d8
    # Parent  d3bb1a7a0ac49eccad3ea4053f938a3518c403ed
    Trac 8568 - implement derivative for erf and ensure only legal symbolic derivatives are converted to Maxima
    
    diff --git a/sage/functions/other.py b/sage/functions/other.py
    a b  
    7979            raise NotImplementedError, "erf not implemented for precision higher than 53" 
    8080        return parent(1 - pari(float(x)).erfc()) 
    8181         
     82    def _derivative_(self, x, diff_param=None): 
     83        """ 
     84        Derivative of erf function 
     85 
     86        EXAMPLES:: 
     87 
     88            sage: erf(x).diff(x) 
     89            2*e^(-x^2)/sqrt(pi) 
     90 
     91        TESTS:: 
     92 
     93        Check if #8568 is fixed:: 
     94 
     95            sage: var('c,x') 
     96            (c, x) 
     97            sage: derivative(erf(c*x),x) 
     98            2*c*e^(-c^2*x^2)/sqrt(pi) 
     99            sage: erf(c*x).diff(x)._maxima_init_() 
     100            '((%pi)^(-1/2))*(c)*(exp(((c)^(2))*((x)^(2))*(-1)))*(2)' 
     101        """ 
     102        return 2*exp(-x**2)/sqrt(pi) 
     103 
    82104erf = Function_erf() 
    83105 
    84106class Function_abs(GinacFunction):