Lesson 8 of 18
Alternating Series
Alternating Series
An alternating series has terms that switch sign:
Alternating Series Test (Leibniz)
If , is decreasing, and , then the series converges.
Famous Example: Alternating Harmonic
1 - rac{1}{2} + rac{1}{3} - rac{1}{4} + cdots = ln(2) approx 0.6931
The partial sums oscillate around , narrowing with each term.
Error Bound
The error of stopping at term is at most — the next term's absolute value. This makes alternating series easy to approximate with controlled accuracy.
Comparison
| (alternating harmonic) | |
|---|---|
The partial sums zigzag toward , each one closer than the last.
Your Task
Implement double alternating_sum(double (*a_n)(int), int n) that computes .
TCC compiler loading...
Loading...
Click "Run" to execute your code.