-- x^2 sampled at 5 points, interpolated by a B-spline of degree 2, which is exact for x^2 x = {0, 0.5, 1, 1.5, 2} y = {} for i = 1, #x do y[i] = x[i]^2 end f = InterpolatingFunction.BSpline(x, y, 2) print(string.format("from 0 to 2: %.12f (exact %.12f)", InterpolatingFunction.Integrate(f), 8/3)) print(string.format("from 1 to 0.3: %.12f (exact %.12f)", InterpolatingFunction.Integrate(f, 1, 0.3), (0.3^3 - 1)/3)) ok, message = pcall(function() return InterpolatingFunction.Integrate(f, 0, 3) end) print(message)