|  |  |  | @ -1003,14 +1003,17 @@ def richardson(Q, k): | 
		
	
		
			
				|  |  |  |  |     return R | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | def quadgr(fun, a, b, abseps=1e-5, max_iter=17): | 
		
	
		
			
				|  |  |  |  | class _Quadgr(object): | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |     def __call__(self, fun, a, b, abseps=1e-5, max_iter=17): | 
		
	
		
			
				|  |  |  |  |         ''' | 
		
	
		
			
				|  |  |  |  |         Gauss-Legendre quadrature with Richardson extrapolation. | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         [Q,ERR] = QUADGR(FUN,A,B,TOL) approximates the integral of a function | 
		
	
		
			
				|  |  |  |  |         FUN from A to B with an absolute error tolerance TOL. FUN is a function | 
		
	
		
			
				|  |  |  |  |         handle and must accept vector arguments. TOL is 1e-6 by default. Q is | 
		
	
		
			
				|  |  |  |  |     the integral approximation and ERR is an estimate of the absolute error. | 
		
	
		
			
				|  |  |  |  |         the integral approximation and ERR is an estimate of the absolute | 
		
	
		
			
				|  |  |  |  |         error. | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         QUADGR uses a 12-point Gauss-Legendre quadrature. The error estimate is | 
		
	
		
			
				|  |  |  |  |         based on successive interval bisection. Richardson extrapolation | 
		
	
	
		
			
				
					|  |  |  | @ -1116,7 +1119,8 @@ def quadgr(fun, a, b, abseps=1e-5, max_iter=17): | 
		
	
		
			
				|  |  |  |  |             hh = hh / 2 | 
		
	
		
			
				|  |  |  |  |             x = np.hstack([x + a, x + b]) / 2 | 
		
	
		
			
				|  |  |  |  |             # Quadrature | 
		
	
		
			
				|  |  |  |  |         Q0[k] = hh * np.sum(wq * np.sum(np.reshape(fun(x), (-1, nq)), axis=0), | 
		
	
		
			
				|  |  |  |  |             Q0[k] = hh * np.sum(wq * np.sum(np.reshape(fun(x), (-1, nq)), | 
		
	
		
			
				|  |  |  |  |                                             axis=0), | 
		
	
		
			
				|  |  |  |  |                                 axis=0) | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |             # Richardson extrapolation | 
		
	
	
		
			
				
					|  |  |  | @ -1148,7 +1152,8 @@ def quadgr(fun, a, b, abseps=1e-5, max_iter=17): | 
		
	
		
			
				|  |  |  |  |             if (err < abseps) | ~np.isfinite(Q): | 
		
	
		
			
				|  |  |  |  |                 break | 
		
	
		
			
				|  |  |  |  |         else: | 
		
	
		
			
				|  |  |  |  |         warnings.warn('Max number of iterations reached without convergence.') | 
		
	
		
			
				|  |  |  |  |             warnings.warn('Max number of iterations reached without ' + | 
		
	
		
			
				|  |  |  |  |                           'convergence.') | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         if ~ np.isfinite(Q): | 
		
	
		
			
				|  |  |  |  |             warnings.warn('Integral approximation is Infinite or NaN.') | 
		
	
	
		
			
				
					|  |  |  | @ -1161,6 +1166,8 @@ def quadgr(fun, a, b, abseps=1e-5, max_iter=17): | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |         return Q, err | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | quadgr = _Quadgr() | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  | def boole(y, x): | 
		
	
		
			
				|  |  |  |  |     a, b = x[0], x[-1] | 
		
	
	
		
			
				
					|  |  |  | 
 |