Consider the problem of finding polynomials S_{h,d}^p for any nonnegative integer p such that : S_{h,d}^p(n)=\sum_{k=0}^{n-1}(h+kd)^p = h^p+(h+d)^p+\cdots+(h+(n-1)d)^p, given
complex numbers h and d \ne 0. Faulhaber's formula handles the simple case S_{1,1}^p(n) = \sum_{k=0}^{n-1}(1+k)^p=1^p+2^p+\dots+n^p. The polynomials S_{1,2}^p(n)=\sum_{k=0}^{n-1}(1+2k)^p=1^p+3^p+\dots+(2n-1)^p compute sums of powers of successive odd numbers, and so on. In general, such polynomials exist for any
arithmetic progression.
Matrix method The general case is solved using the following
matrix formula: :\vec{S_{h,d}}(n)=T(h,d)A^{-1}\vec{N_n}, with row-column definitions :[\vec{S_{h,d}}(n)]_{r}:=S_{h,d}^{r-1}(n),\quad [\vec{N_n}]_r:=n^{r}, :[T(h,d)]_{r,c}:=\begin{cases}0 &\text{if } c>r\\ \binom{r-1}{c-1}h^{r-c}d^{c-1}&\text{if } c\leq r\end{cases}~, \quad [A]_{r,c}:=\begin{cases} 0 &\text{if }c>r\\ \binom{r}{c-1} &\text{if }c\leq r\end{cases}~, \quad where r (row) and c (column) are bound by a given matrix order m.
Example To generalize up to p = 4, apply the above formula for matrix order m = 5: : \begin{pmatrix} S_{h,d}^0({n})\\ S_{h,d}^1(n)\\ S_{h,d}^2(n)\\ S_{h,d}^3(n)\\ S_{h,d}^4(n) \end{pmatrix}= \begin{pmatrix} 1& 0& 0& 0&0\\ h& d& 0& 0&0\\ h^2& 2hd& d^2& 0&0\\ h^3& 3h^2d& 3hd^2& d^3&0\\ h^4& 4h^3d& 6h^2d^2& 4hd^3& d^4\\ \end{pmatrix} \begin{pmatrix} 1& 0& 0& 0&0\\ 1& 2& 0& 0&0\\ 1& 3& 3& 0&0\\ 1& 4& 6& 4&0\\ 1& 5& 10& 10&5\\ \end{pmatrix}^{-1} \begin{pmatrix} n\\ n^2\\ n^3\\ n^4\\ n^5 \end{pmatrix} Note that the nonzero elements of T(h,d) follow the
binomial theorem, and that A is just
Pascal's triangle with each row's last element omitted. Letting h=1, d=2 and computing A^{-1}, we have: T(1,2)=\begin{pmatrix} 1& 0& 0& 0& 0\\ 1& 2& 0& 0& 0 \\ 1& 4& 4& 0& 0\\ 1& 6& 12& 8& 0 \\ 1& 8& 24& 32& 16 \\ \end{pmatrix}, \qquad A^{-1}=\begin{pmatrix} 1 \color{black}&0 &0 &0 &0\\ -\frac{1}{2}\color{black}&\frac{1}{2}&0 &0 &0\\ \frac{1}{6}\color{black}&-\frac{1}{2}&\frac{1}{3} &0 &0\\ 0\color{black}&\frac{1}{4}&-\frac{1}{2}&\frac{1}{4} &0\\ -\frac{1}{30}\color{black}&0&\frac{1}{3}&-\frac{1}{2}&\frac{1}{5} \end{pmatrix} Multiplication therefore yields : \begin{pmatrix} S_{1,2}^0({n})\\ S_{1,2}^1({n})\\ S_{1,2}^2({n})\\ S_{1,2}^3({n})\\ S_{1,2}^4({n}) \end{pmatrix}= \begin{pmatrix} 1 &0 &0 &0 &0\\ 0&1&0 &0 &0 \\ -\frac{1}{3}&0&\frac{4}{3} &0 &0 \\ 0&-1&0&2 &0 \\ \frac{7}{15}&0&-\frac{8}{3}&0&\frac{16}{5} \end{pmatrix} \begin{pmatrix} n\\ n^2\\ n^3\\ n^4\\ n^5\\ \end{pmatrix}=\begin{pmatrix} n\\ n^2\\ -\frac{1}{3}n+\frac{4}{3}n^3\\ -n^2+2n^4\\ \frac{7}{15}n-\frac{8}{3}n^3+\frac{16}{5}n^5\\ \end{pmatrix}.
Methods involving Bernoulli polynomials The following formula implicitly solves the problem using
Bernoulli polynomials: : S_{h,d}^p(n)=\frac{d^p}{p+1}\left(B_{p+1}\left(n+\frac{h}{d}\right)-B_{p+1}\left(\frac{h}{d}\right)\right) == Faulhaber polynomials ==