I'm helping a friend of mine to do her homework, but i need help understanding some results (sorry but i took numeric methods class a looooong time ago)
So, the task is to fit a cubic spline over some mountain shaped function f(x), then calculate the area using Simpson's rule. From what i know, Simpson's rule is exact for degree <= 3, so:
Area(Simpson over splines, n = 2) should equal Area (Integrate over splines)
But i'm getting different results when using n = 2 (number of intervals). I'm using the following function, over the interval [0, 1]
$$1.0 - cos((sin(pi * x^{1.5})))$$
By using Simpson' rule with n = 2, i get 0.2502099, but the integral says that the area is 0.2059441 (which i get if i use n = 20, for example). Why this is happening, and how can i fix it?
Here are the (x, y) points used to fit the Spline:
x y
0.000000 0.000000
0.111111 0.006731
0.222222 0.051774
0.333333 0.157254
0.444444 0.304818
0.555556 0.429594
0.666667 0.451576
0.777778 0.328222
0.888889 0.116309
1.000000 0.000000
I'm using Python, and i can post the code if needed! Thanks for your help!