(n, a, b, K)
return seq[n]
Low-level implementation of Jacobi polynomials.
Low-level implementation of Jacobi polynomials.
Low - level implementation of Jacobi polynomials .
def dup_jacobi(n, a, b, K):
    """Low-level implementation of Jacobi polynomials. """
    seq = [[K.one], [(a + b + K(2))/K(2), (a - b)/K(2)]]

    for i in xrange(2, n + 1):
        den = K(i)*(a + b + i)*(a + b + K(2)*i - K(2))
        f0 = (a + b + K(2)*i - K.one) * (a*a - b*b) / (K(2)*den)
        f1 = (a + b + K(2)*i - K.one) * (a + b + K(2)*i - K(2)) * (a + b + K(2)*i) / (K(2)*den)
        f2 = (a + i - K.one)*(b + i - K.one)*(a + b + K(2)*i) / den
        p0 = dup_mul_ground(seq[-1], f0, K)
        p1 = dup_mul_ground(dup_lshift(seq[-1], 1, K), f1, K)
        p2 = dup_mul_ground(seq[-2], f2, K)
        seq.append(dup_sub(dup_add(p0, p1, K), p2, K))

    return seq[n]
def dup_jacobi ( n , a , b , K ) : seq = [ [ K . one ] , [ ( a + b + K ( 2 ) ) / K ( 2 ) , ( a - b ) / K ( 2 ) ] ] for i in xrange ( 2 , n + 1 ) : den = K ( i ) * ( a + b + i ) * ( a + b + K ( 2 ) * i - K ( 2 ) ) f0 = ( a + b + K ( 2 ) * i - K . one ) * ( a * a - b * b ) / ( K ( 2 ) * den ) f1 = ( a + b + K ( 2 ) * i - K . one ) * ( a + b + K ( 2 ) * i - K ( 2 ) ) * ( a + b + K ( 2 ) * i ) / ( K ( 2 ) * den ) f2 = ( a + i - K . one ) * ( b + i - K . one ) * ( a + b + K ( 2 ) * i ) / den p0 = dup_mul_ground ( seq [ - 1 ] , f0 , K ) p1 = dup_mul_ground ( dup_lshift ( seq [ - 1 ] , 1 , K ) , f1 , K ) p2 = dup_mul_ground ( seq [ - 2 ] , f2 , K ) seq . append ( dup_sub ( dup_add ( p0 , p1 , K ) , p2 , K ) ) return seq [ n ]