Professional Documents
Culture Documents
f[x_] = 1 / (1 + x ^ 2);
a = 0;
b = 1;
h = (b - a) / 2;
apprint = (h / 3) (f[a] + 4 f[(a + b) / 2] + f[b]);
exctint = Integrate[f[x], {x, a, b}];
numerror = Abs[exctint - apprint];
Print["Approximate int using Simpson 1/3 = ", N[apprint]];
Print["Exact int = ", N[exctint]];
Print["Numerical error = ", N[numerror]];
Approximate int using Simpson 1/3 = 0.783333