Suppose we want to integrate x2 from 0 to 2. Analytically, know the solution is 2 2/3. Even if we couldn't solve it analytically, we could solve it numerically using the rectangle method. This is done in the example spreadsheet, with dx set to 0.1. I'm using the "midpoint" approximation instead of the top-left or top-right corner approximation.
You'll notice that I don't bother to calculate the midpoint between x=0 and x=-dx since we won't be using that in the calculations. Very often when doing numerical integrals or derivatives in a spreadsheet, you end up with a column with one extra or one fewer row.
If you try changing dx to 1.0, you see that the solution comes out to 3.0, which is pretty close to correct. If you try changing it to 0.01 and scroll down, you'll see that you get a closer answer.
No comments:
Post a Comment