Defining the Left/Right sums
The simplest way to approximate an integral is using the left-hand sum or the right-hand sum.
In these definitions, I compute Δx inside the leftSum/rightSum functions because it depends on n (which you won't know until the function is called). Also, don't confuse N with n. N is a Mathematica function that is telling the program how many digits precision we should use (I arbitrarily chose 20 digits). n is the number of subdivisions.
This lists the left-hand and right-hand sums for different numbers of subdivisions n:
| n |
LHS |
RHS |
| 100 |
|
|
| 200 |
|
|
| 300 |
|
|
| 400 |
|
|
| 500 |
|
|
| 600 |
|
|
| 700 |
|
|
| 800 |
|
|
| 900 |
|
|
| 1000 |
|
|
Created by
Mathematica
(April 22, 2004)