I have discrete data points of the function plotted below:
I can have infinite number of points for this function.
First, I used the Trapezoidal rule (of Matlab).
Second, I used the interpolation function of Matlab to be able to use the built-in Integral function of Matlab (in which some adaptive approach is used in order to have a better approximation) as follows:
f1 = griddedInterpolant(x,y); %I used also spline and other methods
f2 = @(t) f1(t);
Result = Integral(f2,0,pi)
Comparing to my reference solution, both of those methods provide significant error(30% relative error). (I verified my code and the way i achieved the reference solution with another smooth function). The difference between using 1000 points or 1million points is negligible. I guess this shows that the problem is not related to round off error. However, I wanted to also use VPAINTEGRAL, but i cannot do it because i cannot convert the interpolated function to a symbolic form. Appreciate any suggestion how to use VPAINTEGRAL (or any other approaches...)