%QUAD_INERFC Quadrature approximation of the repeated 
%   integral of the co-error function
%
function [y,uflow,oflow]=quad_inerfc(N,n,x)
global ab ab0
uflow=0; oflow=0;
uv=gauss(N,ab0); u=uv(:,1); v=uv(:,2);
if x>=0
  y0=sum(v.*u.^n.*exp(-2*x*u));
  y=2*exp(-x^2)*y0/(sqrt(pi)*factorial(n));
  if isinf(y0), oflow=1; end
  if y==0, uflow=1; end
else
  y0=sum(v.*u.^n.*exp(-(x^2+2*x*u)));
  y=2*y0/(sqrt(pi)*factorial(n));
  if isinf(y0), oflow=1; end
  if y==0, uflow=1; end
end
