Lesson 9 of 18
Right Riemann Sum
Right Riemann Sum
Use the right endpoint of each subinterval:
a a+h a+2h b
|----|----|----|...|
^ ^ ^
right endpoints used
Left vs. Right vs. Exact
For :
| Method | n=10 | n=100 | n=1000 |
|---|---|---|---|
| Left | 0.285 | 0.328 | 0.332 |
| Right | 0.385 | 0.338 | 0.334 |
| Exact | 0.333 | 0.333 | 0.333 |
The left sum underestimates (for increasing ) and the right sum overestimates. The true integral is sandwiched between them:
(assuming is increasing; swap inequality if decreasing)
Average of Left and Right
The average of the left and right Riemann sums is the trapezoidal rule (next lesson), which has error.
Your Task
Implement double riemann_right(double (*f)(double), double a, double b, int n). The loop runs from to (inclusive).
TCC compiler loading...
Loading...
Click "Run" to execute your code.