# Simpson's rule over cubic splines

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!

• Well, Simpson's rule is not exact for cubic polynomials.
– fang
Commented Nov 30, 2014 at 8:25
• No? why not? I thought the error bound was depends on the 4th derivative, which is zero por poly(3). Commented Nov 30, 2014 at 17:03
• My understanding is Simpson's rule is derived from approximating the integrand by a quadratic function. Therefore, the approximation can only be accurate when the integrand itself is quadratic. But the Wiki page did say that Simpson's rule is exact for polynomial of degree 3 or less. So, I could be wrong and I need to do more study in this.
– fang
Commented Nov 30, 2014 at 18:14
• OK. I did prove that the Simpson's rule is exact for cubic polynomial.
– fang
Commented Nov 30, 2014 at 18:41
• Look like you have to post your codes for everybody to see in order to spot any problem. BTW, does your cubic spline contain single segment or multiple segments?
– fang
Commented Nov 30, 2014 at 18:44