Approximating definite integrals using midpoint Riemann sums and Simpson's Rule.
I. Midpoint Riemann sum approximations.
Note: D[f[x],{x,2}] gives the second derivative of f with respect to x, same as f''[x].
Notice that the above shows that Pi/4 equals .7854002... with an
accuracy guaranteed to 5 decimal places. Let's check the acutal
difference:
The following took a couple of minutes of runtime on my PC. If you don't want to wait on a calculation like this--from "Kernel" on
the main MATHEMATICA menu choose "Abort Evaluation".
Analyzing approximations for different values of n in tabular form is sometimes useful for getting an idea of the closeness of the approximations:
II. Approximation using Simpson's Rule.
In this example Ksimp equals 24. Here's a picture showing it:
| Created by Mathematica (December 5, 2006) |