def _next_legen_der(n, x, p0, p01, p0d, p0dd):
 help_ = p0
 helpd = p0d
 p0 = ((((((2 * n) - 1) * x) * help_) - ((n - 1) * p01)) / n)
 p0d = ((n * help_) + (x * helpd))
 p0dd = (((n + 1) * helpd) + (x * p0dd))
 p01 = help_
 return (p0, p0d, p0dd)

def _next_legen_der ( n , x , p0 , p01 , p0d , p0dd ) : help_ = p0 helpd = p0d p0 = ( ( ( ( ( ( 2 * n ) - 1 ) * x ) * help_ ) - ( ( n - 1 ) * p01 ) ) / n ) p0d = ( ( n * help_ ) + ( x * helpd ) ) p0dd = ( ( ( n + 1 ) * helpd ) + ( x * p0dd ) ) p01 = help_ return ( p0 , p0d , p0dd )
compute the next legendre polynomial and its derivatives .