How does simpsons rule work

can anyone tell me how it works, like visually, what does it do. Im curious.
iv heard its a three point approximation whereas the trapazoidal rule is a two point approximation. But im not entirely sure i understand.

The trapezoid method approximates the curve, between successive points, by a straight line while Simpson's rule uses three points at a time and approximates the curve by the parabola passing through the three points.

Suppose your function is f(x) and you take three points, [itex](x_0, f(x_0), (x_1, f(x_1), (x_2, f(x_2)), equally spaced on the x-axis. For simplicity, take the x-values to be [itex]x_0= x_1- h[/itex], [itex]x_1[/itex], and [itex]x_2= x_1+ h[/itex] where h is the distance between succesive x values so the points themselves are [itex](x_1- h, f(x_0)), (x_1, f(x_1)), (x_1+ h,f(x_2))[/itex].

That is the formula for exactly 3 data points. If we have more, we can separte into groups of three and do that for each such interval. Bacause the overlap at the ends, we must have an odd number of points to do that.

For example, if we had only an even number of points, [itex]x_0, x_1, x_2, x_3[/itex], our first parabola would be over [itex]x_0, x_1, x_2[/itex] but, even including [itex]x_3[/itex] as our first endpoint in the next interval we would have only [itex]x_2, x_3[/itex], not enough for a parabola. But with 5 points, we could have [itex]x_0, x_1, x_2[/itex], [itex]x_2, x_3, x_4[/itex]. Similarly, with 6 points, an even number, we would have [itex]x_0, x_1, x_2[/itex], [itex]x_2, x_3, x_4[/itex], [itex]x_4, x_4[/itex] and not be able to complete the last parabola but with 7, an odd number, we would have [itex]x_0, x_1, x_2[/itex], [itex]x_2, x_3, x_4[/itex], [itex]x_4, x_5, x_6[/itex].

Now see what happens when we "attach" parabolas: on [itex]x_0, x_1, x_2[/itex] we have
[tex]h\frac{2f(x_0)- 4f(x_1)+ 2f(x_2)}{3}[/itex]
while on [itex]x_2, x_3, x_4[/itex]
[tex]h\frac{2f(x_2)- 4f(x_3)+ 2f(x_4)}{3}[/itex]

Those add to give
[tex]h\frac{2f(x_0)- 4f(x_1)+ 4f(x_2)- 4f(x_3)+ 2f(x_4)}{3}[/itex]
so you see why we have "4" multiplying everything except the first and last terms. Taking the integral to be from a to b and using n intervals, h= (b-a)/n so the formula becomes
[tex](b-a)\frac{2f(x_0)- 4f(x_1)+ 4f(x_2)- 4f(x_3)+ 2f(x_4)}{3n}[/itex]
Simpson's rule.