Let f be a function satisfying (1). Set C=1007 and define the function g:Z→Z by g(m)=f(3m)−f(m)+2C for all m∈Z; in particular, g(0)=2C. Now (1) rewrites as
f(f(m)+n)=g(m)+f(n)
for all m,n∈Z. By induction in both directions it follows that
f(tf(m)+n)=tg(m)+f(n)
holds for all m,n,t∈Z. Applying this, for any r∈Z, to the triples (r,0,f(0)) and (0,0,f(r)) in place of (m,n,t) we obtain
f(0)g(r)=f(f(r)f(0))−f(0)=f(r)g(0)
Now if f(0) vanished, then g(0)=2C>0 would entail that f vanishes identically, contrary to (1). Thus f(0)=0 and the previous equation yields g(r)=αf(r), where α=f(0)g(0) is some nonzero constant.
So the definition of g reveals f(3m)=(1+α)f(m)−2C, i.e.,
f(3m)−β=(1+α)(f(m)−β)
for all m∈Z, where β=α2C. By induction on k this implies
f(3km)−β=(1+α)k(f(m)−β)
for all integers k⩾0 and m. Since 3∤2014, there exists by (1) some value d=f(a) attained by f that is not divisible by 3. Now by (2) we have f(n+td)=f(n)+tg(a)=f(n)+α⋅tf(a), i.e.,
f(n+td)=f(n)+α⋅td
for all n,t∈Z. Let us fix any positive integer k with d∣(3k−1), which is possible, since gcd(3,d)=1. E.g., by the Euler-Fermat theorem, we may take k=φ(∣d∣). Now for each m∈Z we get
f(3km)=f(m)+α(3k−1)m
from (5), which in view of (4) yields ((1+α)k−1)(f(m)−β)=α(3k−1)m. Since α=0, the right hand side does not vanish for m=0, wherefore the first factor on the left hand side cannot vanish either. It follows that
f(m)=(1+α)k−1α(3k−1)⋅m+β
So f is a linear function, say f(m)=Am+β for all m∈Z with some constant A∈Q. Plugging this into (1) one obtains (A2−2A)m+(Aβ−2C)=0 for all m, which is equivalent to the conjunction of
A2=2A and Aβ=2C
The first equation is equivalent to A∈{0,2}, and as C=0 the second one gives
A=2 and β=C
This shows that f is indeed the function mentioned in the answer and as the numbers found in (7) do indeed satisfy the equations (6) this function is indeed as desired.
Comment 1. One may see that α=2. A more pedestrian version of the above solution starts with a direct proof of this fact, that can be obtained by substituting some special values into (1), e.g., as follows.
Set D=f(0). Plugging m=0 into (1) and simplifying, we get
f(n+D)=f(n)+2C
for all n∈Z. In particular, for n=0,D,2D we obtain f(D)=2C+D,f(2D)=f(D)+2C=4C+D, and f(3D)=f(2D)+2C=6C+D. So substituting m=D and n=r−D into (1) and applying (8) with n=r−D afterwards we learn
f(r+2C)+2C+D=(f(r)−2C)+(6C+D)+2C
i.e., f(r+2C)=f(r)+4C. By induction in both directions it follows that
f(n+2Ct)=f(n)+4Ct
holds for all n,t∈Z. Claim. If a and b denote two integers with the property that f(n+a)=f(n)+b holds for all n∈Z, then b=2a. Proof. Applying induction in both directions to the assumption we get f(n+ta)=f(n)+tb for all n,t∈Z. Plugging (n,t)=(0,2C) into this equation and (n,t)=(0,a) into (9) we get f(2aC)−f(0)= 2bC=4aC, and, as C=0, the claim follows.
Now by (1), for any m∈Z, the numbers a=f(m) and b=f(3m)−f(m)+2C have the property mentioned in the claim, whence we have
f(3m)−C=3(f(m)−C).
In view of (3) this tells us indeed that α=2. Now the solution may be completed as above, but due to our knowledge of α=2 we get the desired formula f(m)=2m+C directly without having the need to go through all linear functions. Now it just remains to check that this function does indeed satisfy (1).
Comment 2. It is natural to wonder what happens if one replaces the number 2014 appearing in the statement of the problem by some arbitrary integer B.
If B is odd, there is no such function, as can be seen by using the same ideas as in the above solution.
If B=0 is even, however, then the only such function is given by n⟼2n+B/2. In case 3∤B this was essentially proved above, but for the general case one more idea seems to be necessary. Writing B=3ν⋅k with some integers ν and k such that 3∤k one can obtain f(n)=2n+B/2 for all n that are divisible by 3ν in the same manner as usual; then one may use the formula f(3n)=3f(n)−B to establish the remaining cases.
Finally, in case B=0 there are more solutions than just the function n⟼2n. It can be shown that all these other functions are periodic; to mention just one kind of example, for any even integers r and s the function
f(n)={rs if n is even, if n is odd
also has the property under discussion.