The result of integrating of your function between 0 and 1 is:
I = (exp(1)^2*(2*sin(5)-5*cos(5)) + 5)/29;
so relative error is
relerror = abs(sum/I - 1);
As an aside, "sum" is a built-in Matlab function, so it's best not to use it as a variable name.
