function gaussj_ex(n)
% example for Gauss-Jacobi on general interval [a,b]
% integral x^(1/2)*exp(x) dx for x=0..1

% exact = double(vpa('exp(1)+1/2*i*pi^(1/2)*erf(i)'));
exact = 1.2556300825518636265562388844957;

a = 0; b = 1;
alpha = .5; beta = 0;

[xj,wj] = gaussjac(n,alpha,beta);        % Gauss-Jacobi
[xg,wg] = gaussjac(n,0,0);               % Gauss-Legendre, same as [xg,wg]=gauleg(n)

c = (b-a)/2;
tj = (a+b)/2 + xj*c;
qj = c^(1+alpha+beta)*sum(wj.*exp(tj));  % NOTE: only exp(x) evaluated at nodes

tg = (a+b)/2 + xg*c;
qg = c*sum(wg.*tg.^.5.*exp(tg));         % NOTE: x^.5*exp(x) evaluated at nodes

error_jacobi = qj - exact
err_legendre = qg - exact
