All power sums have a closed polynomial forms for integral powers. For example,
In the case of , , , and .
Solving for the General Case
To solve for the closed form solution of every power sum we use the following process.
Take the bottom left half of Pascal's infinite matrix. Remove the top left-bottom right diagonal of 1's. Remove the top row and right most column of 0's. Invert the matrix. Now, the th row from the right yields the coefficients, of the sum of (j-1)th powers. A full proof and explanation is given in this document.
Problems (listed in increasing difficulty)
Table of Coefficients for Closed form Solutions
This table contains the coefficients of the closed form solutions for the first 61 power sums. As an example, the 3rd column from the right reads:
This means , , and . Thus the closed form solution is .
How it was made:
I used the code below for CS50 to generate the bottom 61 rows and columns of Pascal's matrix. After eliminating the unnecessary rows and columns, I then inverted the matrix on this website (huge thanks to whomever made this). I had to fill in 455 0's (probably due to the range of a long double) by hand but don't worry, all numbers in the giant table linked above are accurate.
int count = GetInt();
long double i;
long double j;
long double numb;
long long integer;
long long sign;
for (j = count; j = 0; j--)
for (i = count + 1; i = 1; i--)
if (i j)
numb = roundl(tgammal(i + 1) / tgammal(i - j + 1) / tgammal(j + 1));
/** tgamma in cs50 always underestimates the gamma function by like .00000000001.
* If we typeset numb to an int without using the ceil function, integer would be one too small.
integer = ceill(numb);
// sign on each number
sign = powl(-1, i + j);
printf("%lli ", -1 * integer * sign);