def fixed_quad(func, a, b, args=(), n=5):
 (x, w) = _cached_roots_legendre(n)
 x = np.real(x)
 if (np.isinf(a) or np.isinf(b)):
  raise ValueError('Gaussian quadrature is only available for finite limits.')
 y = ((((b - a) * (x + 1)) / 2.0) + a)
 return ((((b - a) / 2.0) * np.sum((w * func(y, *args)), axis=(-1))), None)

def fixed_quad ( func , a , b , args = ( ) , n = 5 ) : ( x , w ) = _cached_roots_legendre ( n ) x = np . real ( x ) if ( np . isinf ( a ) or np . isinf ( b ) ) : raise ValueError ( 'Gaussian quadrature is only available for finite limits.' ) y = ( ( ( ( b - a ) * ( x + 1 ) ) / 2.0 ) + a ) return ( ( ( ( b - a ) / 2.0 ) * np . sum ( ( w * func ( y , * args ) ) , axis = ( - 1 ) ) ) , None )
compute a definite integral using fixed-order gaussian quadrature .