Numerical Quadrature

We wrote the program quad.c to approximate the definite integral

abf(x)dx

using the trapezoid and Simpson methods.

For a=0, b=5 and f(x)=x2 the output of the program is

s10=   4.187500000000000e+01
s20=   4.171875000000000e+01
Simp=   4.166666666666666e+01
Since the exact value of the integral is

53/3 ≈ 41.6666666...

we see that Simpson's method gives the exact value.


Last Updated: Fri Sep 19 15:08:33 PDT 2014