We seek
f(x). We will start with a guess-and-check method starting with
f(x)=x2.
Guess:⇒⇒f(x)=x2x2−(x−1)2x2−x2+2x−1=?=xx
This guess for
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:
This method, as previously shown, works by incrementally adding and removing polynomials to
f(x) until
f(x)−f(x−1)=h(x)
Where
h(x) is some polynomial function. A table has been made to better understand the effect which adding a power of
x to the guess for
f(x) has on the overall equation.
xx2x3⇒⇒⇒12x−13x3−3x+1
The above table indicates that, if
x2 is added to the guess for
f(x), then
f(x)−f(x−1) will have
2x−1 added to it as a result.
Using this table, the method will again be applied to the sum of squares, where
h(x)=x2.
It is not necessary to use the table, but the algebra becomes pretty murky without it.
The starting guess for
f(x) is informed by the highest power of
x in
h(x).
Because
h(x)=x2, the first guess will be
f(x)=31x3.
The specific
31x3 is chosen because it will make
f(x)−f(x−1) contain
x2 which is of course desirable.
A sample algorithm implementation in Python using NumPy is provided:
View Code
importfractionsasFfromnumpy.polynomialimportpolynomialasP# Possibly unexpected behavior:assertP.polytrim([0])==[0]defpolyset(p,n,v):whilelen(p)<=n:p.append(0)p[n]=v# Given f(x) - f(x-1) = g(x) Where `g` is given valuegiven=[F.Fraction(0),F.Fraction(1)]# x^2# Populate tabletable=[]base=[F.Fraction(-1),F.Fraction(1)]tmp=base.copy()foriinrange(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=Nonebase=None# move given to left side of equation: f(x)-f(x-1) - g(x) = 0working=P.polymul(given,-1)out=[]# Work until a satisfying function $f$ is found# such that the equation is zero on both sideswhilelen(working)>1orworking[-1]!=0:high_pwr=len(working)-1hp_c=working[high_pwr]asserthp_c!=0lc,tp=table[high_pwr]factor=hp_c/lc*-1polyset(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.