Ticket #4102: trac4102_diff.patch

File trac4102_diff.patch, 3.2 KB (added by eviatarbach, 8 years ago)
  • sage/functions/bessel.py

    # HG changeset patch
    # User Eviatar Bach <eviatarbach@gmail.com>
    # Date 1375857451 25200
    # Node ID 82511eed8f2981d0bbd983a7c61b1788a11c29fd
    # Parent  2276f8addef20c5d1f59ebe11e82e7d5451e5cae
    Fixing differentiation
    
    diff --git a/sage/functions/bessel.py b/sage/functions/bessel.py
    a b  
    351351        import mpmath
    352352        return mpmath_utils.call(mpmath.besselj, n, x, parent=parent)
    353353
    354     def _derivative_(self, n, x, diff_param=None):
     354    def _derivative_(self, n, x, diff_param):
    355355        """
    356356        Return the derivative of the Bessel J function.
    357357
     
    361361            sage: derivative(f, z)
    362362            z |--> -1/2*bessel_J(11, z) + 1/2*bessel_J(9, z)
    363363        """
    364         return (bessel_J(n - 1, x) - bessel_J(n + 1, x)) / Integer(2)
     364        if diff_param == 1:
     365            return (bessel_J(n - 1, x) - bessel_J(n + 1, x)) / Integer(2)
     366        else:
     367            raise NotImplementedError('derivative with respect to order')
    365368
    366369    def _print_latex_(self, n, z):
    367370        """
     
    511514        import mpmath
    512515        return mpmath_utils.call(mpmath.bessely, n, x, parent=parent)
    513516
    514     def _derivative_(self, n, x, diff_param=None):
     517    def _derivative_(self, n, x, diff_param):
    515518        """
    516519        Return the derivative of the Bessel Y function.
    517520
     
    521524            sage: derivative(f, x)
    522525            x |--> -1/2*bessel_Y(11, x) + 1/2*bessel_Y(9, x)
    523526        """
    524         return (bessel_Y(n - 1, x) - bessel_Y(n + 1, x)) / Integer(2)
     527        if diff_param == 1:
     528            return (bessel_Y(n - 1, x) - bessel_Y(n + 1, x)) / Integer(2)
     529        else:
     530            raise NotImplementedError('derivative with respect to order')
    525531
    526532    def _print_latex_(self, n, z):
    527533        """
     
    683689        import mpmath
    684690        return mpmath_utils.call(mpmath.besseli, n, x, parent=parent)
    685691
    686     def _derivative_(self, n, x, diff_param=None):
     692    def _derivative_(self, n, x, diff_param):
    687693        """
    688694        Return the derivative of the Bessel I function `I_n(x)` with respect
    689695        to `x`.
     
    694700            sage: derivative(f, x)
    695701            z |--> 1/2*bessel_I(11, x) + 1/2*bessel_I(9, x)
    696702        """
    697         return (bessel_I(n - 1, x) + bessel_I(n + 1, x)) / Integer(2)
     703        if diff_param == 1:
     704            return (bessel_I(n - 1, x) + bessel_I(n + 1, x)) / Integer(2)
     705        else:
     706            raise NotImplementedError('derivative with respect to order')
    698707
    699708    def _print_latex_(self, n, z):
    700709        """
     
    869878        import mpmath
    870879        return mpmath_utils.call(mpmath.besselk, n, x, parent=parent)
    871880
    872     def _derivative_(self, n, x, diff_param=None):
     881    def _derivative_(self, n, x, diff_param):
    873882        """
    874883        Return the derivative of the Bessel K function.
    875884
     
    879888            sage: derivative(f, x)
    880889            x |--> 1/2*bessel_K(11, x) + 1/2*bessel_K(9, x)
    881890        """
    882         return (bessel_K(n - 1, x) + bessel_K(n + 1, x)) / Integer(2)
     891        if diff_param == 1:
     892            return (bessel_K(n - 1, x) + bessel_K(n + 1, x)) / Integer(2)
     893        else:
     894            raise NotImplementedError('derivative with respect to order')
    883895
    884896    def _print_latex_(self, n, z):
    885897        """