# Alternating sum

An alternating sum is a series of real numbers in which the terms alternate sign.

For example, the alternating harmonic series is $1 - \frac12 + \frac13 - \frac 14 + \ldots = \sum_{i = 1}^\infty \frac{(-1)^{i+1}}{i}$.

Alternating sums also arise in other cases. For instance, the divisibility rule for 11 is to take the alternating sum of the digits of the integer in question and check if the result is divisble by 11.

Given an infinite alternating sum, $\sum_{i = 0}^\infty (-1)^i a_i$, with $a_i \geq 0$, if corresponding sequence $a_0, a_1, a_2, \ldots$ approaches a limit of zero monotonically then the series converges.

## Error estimation

Suppose that an infinite alternating sum $\sum_{i=0}^{\infty} (-1)^ia_i$ satisfies the the above test for convergence. Then letting $\sum_{i=0}^{\infty} (-1)^ia_i$ equal $S$ and the $k$-term partial sum $\sum_{i=0}^{k} (-1)^ia_i$ equal $S_k$, the Alternating Series Error Bound states that $$|S - S_k| \leq a_{k+1}.$$ The value of the error term $S - S_k$ must also have the opposite sign as $(-1)^ka_k$, the last term of the partial series.

## Examples of infinite alternating sums $$\frac{1}{3} = \frac{1}{2} - \frac{1}{4} + \frac{1}{8} - \frac{1}{16} + \dots = \sum_{i=1}^{\infty} \left(-\frac{1}{2} \right)^i$$ $$\cos 1 = 1 - \frac{1}{2} + \frac{1}{24} - \frac{1}{720} + \dots = \sum_{i=0}^{\infty} \frac{(-1)^i}{(2i)!}$$ $$\sin 1 = 1 - \frac{1}{6} + \frac{1}{120} - \frac{1}{5040} + \dots = \sum_{i=0}^{\infty} \frac{(-1)^i}{(2i+1)!}$$ $$\frac{1}{e} = e^{-1} = \frac{1}{2} - \frac{1}{6} + \frac{1}{24} - \frac{1}{120} + \dots = \sum_{i=2}^{\infty} \frac{(-1)^i}{i!}$$