Arithmetic series (source code)

= Arithmetic series
{title2=$S_n=\sum_{k=1}^{n}a_k$}

An <arithmetic series> adds the <sequence terms> of an <arithmetic progression>. Its $n$-th <partial sum> is $S_n=\sum_{k=1}^na_k$, with the <empty sum> convention $S_0=0$. For $n\geq1$,
$$
\boxed{S_n=\frac{n(a_1+a_n)}2=na_1+\frac{n(n-1)}2d.}
$$
Thus the total is the number of <sequence terms> multiplied by the <arithmetic mean> of the two endpoints. The formula also covers decreasing and constant <arithmetic progressions>.<NIST Digital Library of Mathematical Functions/1 Algebraic and Analytic Methods>[NIST Digital Library of Mathematical Functions, §1.2(ii) Finite Series, equation 1.2.10: arithmetic progression sum and last-term definition]{ref}

For the eight-entry example, \b[the sum is $8(7+28)/2=140$], and the <arithmetic mean> of all eight entries is $17.5$. A decreasing example $11,9,7,5,3,1$ gives $6(11+1)/2=36$. Negative values cause no algebraic difficulty: $3,1,-1,-3,-5$ has sum $5(3-5)/2=-5$.

The <triangular number> $T_n=1+2+\cdots+n$ is the special case $a_1=d=1$, giving $n(n+1)/2$. More generally, an equal increase in each successive allocation makes the total grow as a <quadratic function> of the number of allocations. The eight-entry example has
$$
a_k=3k+4,\qquad S_n=\frac{3n^2+11n}2.
$$
Its first four entries add to $46$, its first eight to $140$, and its first twelve to $282$. The <sequence terms> lie on a <straight line> when plotted against their <sequence indices>, while the <partial sums> follow a <quadratic function>.

\Image[/arithmetic-progression-terms-and-partial-sums.png]
{title=Constant <common differences> produce linear <sequence terms> and quadratic <partial sums>}
{description=Original example $a_k=7+3(k-1)$. Dots represent <integer> <sequence indices>; connecting lines and the smooth <quadratic function> show the formulas between sample positions. The right panel includes the <empty sum> $S_0=0$.}