We want to compute the area under an arbitrary parabola through three points, $(x_0,y_0)$, $(x_1,y_1)$, $(x_2,y_2)$, where $x_0=x_1-h$ and $x_2=x_1+h$. First, we get Sage to solve for the coefficients $a$, $b$, and $c$ of the parabola $q(x)=ax^2+bx+c$.

The coefficients are a bit messy but Sage doesn't care. Now we substitute the values into $ax^2+bx+c$ to get the actual parabola.

Now we integrate from $x_0=x_1-h$ to $x_2=x_1+h$.

Still messy, but let's tell Sage to multiply everything out and simplify.

Voila! A simple formula for the area, namely $(h/3)(y_0+4y_1+y_2)$.

To use this worksheet in Sage, download this file simpson_derive.sws and then upload it to your own Sage account.