Ticket #21639: 0001-Implement-derivative-of-gegenbauer-n-a-x-w.r.t-x.patch

File 0001-Implement-derivative-of-gegenbauer-n-a-x-w.r.t-x.patch, 2.0 KB (added by mafra, 5 years ago)

Patch implementing the derivative of gegenbauer(n,a,x) wrt x

  • src/sage/functions/orthogonal_polys.py

    From e71983bcef03a1429cb3bc58065709a1f5e93529 Mon Sep 17 00:00:00 2001
    From: "Carlos R. Mafra" <crmafra@gmail.com>
    Date: Tue, 4 Oct 2016 17:52:47 +0100
    Subject: [PATCH] Implement derivative of gegenbauer(n,a,x) w.r.t x
    
    Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
    ---
     src/sage/functions/orthogonal_polys.py | 27 +++++++++++++++++++++++++++
     1 file changed, 27 insertions(+)
    
    diff --git a/src/sage/functions/orthogonal_polys.py b/src/sage/functions/orthogonal_polys.py
    index 8a593d5..88e6509 100644
    a b class Func_ultraspherical(GinacFunction): 
    15051505                conversions={'maxima':'ultraspherical', 'mathematica':'GegenbauerC',
    15061506                    'maple':'GegenbauerC', 'sympy':'gegenbauer'})
    15071507
     1508    def _derivative_(self, n, a, x, diff_param):
     1509        """
     1510        Return the derivative of the Gegenbauer polynomial
     1511        in terms of other Gegenbauer polynomials.
     1512
     1513        EXAMPLES::
     1514
     1515            sage: var('a n')
     1516            (a, n)
     1517            sage: derivative(gegenbauer(n,a,x),x)
     1518            2*a*gegenbauer(n - 1, a + 1, x)
     1519            sage: derivative(gegenbauer(3,a,x),x)
     1520            4*(a + 2)*(a + 1)*a*x^2 - 2*(a + 1)*a
     1521            sage: derivative(gegenbauer(n,a,x),a)
     1522            Traceback (most recent call last):
     1523            ...
     1524            NotImplementedError: derivative w.r.t. to the second index is not supported yet
     1525        """
     1526        if diff_param == 0:
     1527            raise NotImplementedError("derivative w.r.t. to the index is not supported yet")
     1528        elif diff_param == 1:
     1529            raise NotImplementedError("derivative w.r.t. to the second index is not supported yet")
     1530        elif diff_param == 2:
     1531            return 2*a*ultraspherical(n-1, a+1, x)
     1532        raise ValueError("illegal differentiation parameter {}".format(diff_param))
     1533
     1534
    15081535ultraspherical = Func_ultraspherical()
    15091536gegenbauer = Func_ultraspherical()
    15101537