% [xg,wg] = gauherm(n)
% nodes xg(1),...,xg(n) and weights wg(1),...,wg(n) for Gauss-Hermite quadrature
%
% integral of f(x)*exp(-x^2) from -infinity to infinity
% is approximated by
% wg(1)*f(xg(1)) + ... + wg(n)*f(xg(n))  

% adapted from gqzero.m from Matlab Central

function [x,w] = gauherm(n)
d = sqrt((1:n-1)/2);
T = diag(d,1)+diag(d,-1);
[V,D] = eig(T);
w = V(1,:).^2;
w = w*sqrt(pi);
x = diag(D);
[x,ind] = sort(x);
w = w(ind);
w=w';
