Let Di=gcd(a1,…,ai−1,ai+1,…,ak) (i=1,…,k). Then f(x)=Cx+f1(x)+⋯+fk(x) such that f1,…,fk are periodic of period Di and fi(0)=0. Let P=a1…ak then if f(P)=0 it follows that for all i=j and m≥0 we have f(maiaj)=0. Indeed, letting M=f(a1a2) then f(2a1a2)=2M, f(3a1a2)=3M. By induction we find f(ma1a2)=mM. Choose m=a2…ak we are done.
Let g(x)=f(x)−Pxf(P) it follows that g(P)=0 and therefore, for all i=j, m≥0 we have g(maiaj)=0. Writing C=Pf(P) it follows that f(x)=Cx+g(x).
If for a given i we have ∑j=1kujaj≡∑j=1kvjaj(modDi) with ui≥0, vi≥0 then g(uiai)=g(viai). It suffices to prove it for i=1. Indeed, the congruence implies that u1a1≡v1a1(modD1), since gcd(a1,D1)=1 we conclude that u1≡v1(modD1). Since D1=gcd(a2,…,ak), write
v1−u1=j=2∑kwjaj
where wj=cj−cj′, cj,cj′≥0. Thus,
u1+j=2∑kcjaj=v1+j=2∑kcj′aj.
Multiplying both sides by a1 and taking g from both sides yields
g(u1a1)+j=2∑kg(cja1aj)=g(v1a1)+j=2∑kg(cj′a1aj).
Thus, g(u1a1)=g(v1a1).
For every x=∑aiui∈S we define a function f1(x)=g(a1u1). If x∈S can be written x=∑aiui and also x=∑aiui′ then g(a1u1)=g(a1u1′). Moreover, if x,z both are in S such that x≡z(modD1) then we have f1(x)=f1(z). We finally observe that every residue class modD1 contains elements in S, in fact already elements of the subset a1u1 (u1≥0), because gcd(a1,D1)=1. We may therefore extend the definition of f1(x) to all integers obtaining a function having the period D1. Similarly, we define a function fi(x) (i=1,…,k) over all integers, having the period Di with the property that fi(x)=g(aiui) if x=∑aiui∈S.
And, in particular fi(0)=0. If x=∑aiui∈S then the functional equation gives
g(x)=g(∑aiui)=∑g(aiui)=∑fi(x).
Hence, g(x)=f1(x)+⋯+fk(x). We now use this to extend the definition of g(x) to all integers x. Let us show that this implies g(aiui)=fi(aiui). Indeed, if ui≥0 we have nothing to do. If ui<0 then we shall have g(aiui)=∑fi(aiui)=fi(aiui). It follows that g(x) satisfies the unrestricted equation
g(∑aiui)=∑g(aiui),ui∈Z.
The converse is also easy. Indeed, the periodic function fi(x) depends on Di−1 arbitrary parameters and therefore the general solution depends on 1+∑(Di−1) arbitrary parameters. So, if all Di=1 the function is f(x)=Cx.
The least slope among the slopes of the sides of the polygonal graph of the function fi(x)(x∈Z) is given by −mi=minx∈ZΔfi(x), where Δfi(x)=fi(x+1)−fi(x). Evidently, mi≥0. If we choose C≥∑mi then f(x) is certainly non-decreasing since for all x:Δf(x)=C+∑Δfi(x)≥C−∑mi≥0.
We then prove that the solution of the above functional equation is non-decreasing if and only if ∑i=1kmi≤C. Indeed, let the minimum of Δfi(x) is reached at x≡ci(modDi) so that Δfi(ci)=−mi (i=1,…,k). Since Di are pair-wise coprime. By the CRT the system x≡ci(modD1) has a solution t. Then, 0≤Δf(t)=C+∑Δfi(t)=C−∑i=1kmi. ■