Alexander Bass
This note is one of many taken during 2026

Polynomial Integer Sums as Functional Equations

The sum of natural numbers

Ln=1+2+3++n L_n = 1 + 2 + 3 + \ldots + n

Can be described as a recursive function

f(x)=x+f(x1) f(x) = x + f(x-1)

Or

f(x)f(x1)=x f(x) - f(x-1) = x

We seek f(x)f(x). We will start with a guess-and-check method starting with f(x)=x2f(x) = x^2.

Guess:f(x)=x2x2(x1)2=?xx2x2+2x1x \begin{array}{rlcc} \text{Guess:} & f(x) = x^2\\ \Rightarrow& x^2 - (x-1)^2 &\stackrel{?}{=} &x\\ \Rightarrow& \cancel{x^2} - \cancel{x^2} + 2x - 1 &\ne &x \end{array}

This guess for f(x)f(x) does not satisfy the constraint and must be updated. A more clear method for doing this will be explained later, for now, halve current guess:

Guess:f(x)=12x212x212(x1)2=?x12x212x2+x12x \begin{array}{rlcc} \text{Guess:} & f(x) = \frac{1}{2}x^2\\ \Rightarrow& \frac{1}{2}x^2 - \frac{1}{2}(x-1)^2 &\stackrel{?}{=} &x\\ \Rightarrow& \cancel{\frac{1}{2}x^2} - \cancel{\frac{1}{2}x^2} + x - \frac{1}{2} &\ne &x \end{array}

Now, the guess for f(x)f(x) is a lot closer to satisfying the equation. Update guess again

Guess:f(x)=12x2+12x12x2+12x12(x1)212(x1)=?x12x2+12x12x2+x+12x12+12=x \begin{array}{rlcc} \text{Guess:} & f(x) = \frac{1}{2}x^2 + \frac{1}{2}x\\ \Rightarrow& \frac{1}{2}x^2 + \frac{1}{2}x - \frac{1}{2}(x-1)^2 - \frac{1}{2}(x-1) &\stackrel{?}{=} &x\\ \Rightarrow& \cancel{\frac{1}{2}x^2} + \cancel{\frac{1}{2}x} - \cancel{\frac{1}{2}x^2} +x + \cancel{\frac{1}{2}x} - \cancel{\frac{1}{2}} + \cancel{\frac{1}{2}} &= &x \end{array}

A Bit more formally

This method, as previously shown, works by incrementally adding and removing polynomials to f(x)f(x) until

f(x)f(x1)=h(x) f(x) - f(x-1) = h(x)

Where h(x)h(x) is some polynomial function. A table has been made to better understand the effect which adding a power of xx to the guess for f(x)f(x) has on the overall equation.

x1x22x1x33x33x+1 \begin{array}{lll} x & \Rightarrow &1 \\ x^2 & \Rightarrow &2x -1\\ x^3 & \Rightarrow &3x^3 -3x+1\\ \end{array}

The above table indicates that, if x2x^2 is added to the guess for f(x)f(x), then f(x)f(x1)f(x)-f(x-1) will have 2x12x-1 added to it as a result.

Using this table, the method will again be applied to the sum of squares, where h(x)=x2h(x) = x^2. It is not necessary to use the table, but the algebra becomes pretty murky without it.

The starting guess for f(x)f(x) is informed by the highest power of xx in h(x)h(x). Because h(x)=x2h(x)=x^2, the first guess will be f(x)=13x3f(x) = \frac{1}{3}x^3. The specific 13x3\frac{1}{3}x^3 is chosen because it will make f(x)f(x1)f(x) - f(x-1) contain x2x^2 which is of course desirable.

Guess:f(x)=13x313x313(x1)3=?x2x2x+13x2 \begin{array}{rlcc} \text{Guess:} & f(x) = \frac{1}{3}x^3\\ \Rightarrow& \frac{1}{3}x^3 - \frac{1}{3}(x-1)^3 &\stackrel{?}{=} &x^2\\ \Rightarrow& x^2 - x + \frac{1}{3} &\ne &x^2 \end{array}

Now that the expression contains x2x^2, the unnecessary components x+13-x + \frac{1}{3} must be removed. Remove x-x by adding 12x2\frac{1}{2}x^2 to the guess for f(x)f(x)

Guess:f(x)=13x3+12x213x3+12x213(x1)313(x1)2=?x2x2x+13+x12x2 \begin{array}{rlcc} \text{Guess:} & f(x) = \frac{1}{3}x^3 + \frac{1}{2}x^2\\ \Rightarrow& \frac{1}{3}x^3 + \frac{1}{2}x^2 - \frac{1}{3}(x-1)^3 - \frac{1}{3}(x-1)^2 &\stackrel{?}{=} &x^2\\ \Rightarrow& x^2 - \cancel{x} + \frac{1}{3} + \cancel{x} - \frac{1}{2} &\ne &x^2 \end{array}

Next, 16-\frac{1}{6} is removed by adding 16x\frac{1}{6}x to the guess for f(x)f(x)

Guess:f(x)=13x3+12x2+16x13x3+12x2+16x13(x1)313(x1)216(x1)=?x2x216+16=x2 \begin{array}{rlcc} \text{Guess:} & f(x) = \frac{1}{3}x^3 + \frac{1}{2}x^2 + \frac{1}{6}x\\ \Rightarrow& \frac{1}{3}x^3 + \frac{1}{2}x^2 + \frac{1}{6}x - \frac{1}{3}(x-1)^3 - \frac{1}{3}(x-1)^2 - \frac{1}{6}(x-1) &\stackrel{?}{=} &x^2\\ \Rightarrow& x^2 - \cancel{\frac{1}{6}} + \cancel{\frac{1}{6}} &= &x^2 \end{array}

Thus, the sum of squares formula is

f(x)=13x3+12x2+16x f(x) = \frac{1}{3}x^3 + \frac{1}{2}x^2 + \frac{1}{6}x

Solver Algorithm Implementation

A sample algorithm implementation in Python using NumPy is provided:

View Code
import fractions as F
from numpy.polynomial import polynomial as P

# Possibly unexpected behavior:
assert P.polytrim([0]) == [0]

def polyset(p, n, v):
    while len(p) <= n:
        p.append(0)
    p[n] = v

# Given f(x) - f(x-1) = g(x) Where `g` is given value
given = [F.Fraction(0), F.Fraction(1)] # x^2

# Populate table
table = []
base = [F.Fraction(-1), F.Fraction(1)]
tmp = base.copy()
for i in range(len(given) + 1):
    x = tmp[:-1]
    x = P.polymul(x, [-1])
    leading_coef = x[-1]
    table.append((leading_coef, x))
    tmp = P.polymul(tmp, base)
tmp = None
base = None

# move given to left side of equation: f(x)-f(x-1) - g(x) = 0
working = P.polymul(given, -1)
out = []

# Work until a satisfying function $f$ is found
# such that the equation is zero on both sides
while len(working) > 1 or working[-1] != 0:
    high_pwr = len(working) - 1
    hp_c = working[high_pwr]
    assert hp_c != 0
    lc, tp = table[high_pwr]
    factor = hp_c / lc * -1
    polyset(out, high_pwr + 1, factor)
    tp = P.polymul(tp, [factor])
    working = P.polyadd(working, tp)
    working = P.polytrim(working)

print("The sum of: ", P.Polynomial(given))
print("Has the closed form: ", P.Polynomial(out))

Additionally, I’ve ported it to JavaScript so you can use it interactively. All polynomials must be ine expanded form.

Interactive Solver
(e.g: x^2 + 2/3x^3 - 3)
Parsed as:
Output:
This note is one of many taken during 2026