Lesson 10 of 18
Midpoint Rule
Midpoint Rule
Use the midpoint of each subinterval:
a a+h a+2h b
|----|----|----...----|
^ ^ ^
midpoints used
Why Midpoints Are Better
The midpoint rule has error — the same order as the trapezoidal rule, and better than left/right (). Intuitively, the midpoint is the "best representative" of a subinterval because it cancels out the linear error terms from both sides.
Comparison for
| Left | Midpoint | Trapezoid | Right | |
|---|---|---|---|---|
| 4 | 0.219 | 0.328 | 0.344 | 0.469 |
The midpoint rule is more accurate than both left and right for the same .
Exact for Linear Functions
The midpoint rule integrates linear functions exactly, regardless of . For on :
- Midpoint rule with any : ✓
Your Task
Implement double riemann_mid(double (*f)(double), double a, double b, int n).
TCC compiler loading...
Loading...
Click "Run" to execute your code.