I'm using Gauss-Legendre Quadrature to solve the following integral:
$\int_0^{1}x^xdx$
After I've compared the result with the MatLab vpa(int(...)) of the same integral I've noticed that the error between the quadrature approximation and MatLab's result is quite significant.
Why is that ? Is it possible that I've made a mistake somewhere, or it's a bad behaved integral when it comes to approximation ?
UPDATE
I've made a mistake, it was actually $x^x$ not $x^2$
Here is the matlab code
syms x;
f = x^x;
r = int(x^x, x, 0, 1)
vpaRes = vpa(r, 10)
% change of interval
f = @(t)((1./2).*(((t+1)./2) .^((t+1)./2)));
[nodes, coefficients] = GaussLegendre(10);
I = vquad(nodes, coefficients, f);
gaussRes = vpa(I);
error = vpaRes - gaussRes;
GaussLegendre - function that computes the nodes and coefficients of a Gauss-Legendre polynomial vquad - function that computes the approximation using nodes and coefficients and the function
Both functions are tested and are behaving as expected in other cases.
Am I not using enough nodes ? Or I've made a mistake somewhere, as you can see I've made the change of interval.