function [x,w] = hermite(n);
%
% [x,w] = hermite(n)
%
% n-point Gauss quadrature rule on (-\infty,\infty) with weight function
% w(t) = 1/sqrt(2*pi) * exp(-t^2/2), t \in R
%
% INPUT
%
% n    : number of nodes, n > 0
%
% OUTPUT
%
% x   : n x 1 vector containing cubature nodes
% w   : n x 1 vector containing cubature weights
%
% \int_R f(t) * w(t) dt = \sum_{n=1}^n f(x(n,:))*w(n)
%
% Copyright (c) 2007 E. Ullmann
%
alpha = zeros(n,1);
m = [2:n]';
beta = sqrt(m-1);   

% Set up Jacobi matrix and compute eigendecomposition
%
J = spdiags(beta,-1,n,n);
J = J + J' + spdiags(alpha,0,n,n);
    
[C,mu] = eig(full(J));
x = diag(mu);
w = (C(1,:)').^2;

return