Q:

Finding all of the solutions for a functional equation

Let $P(x+2)+P(x-2) = 8x+6$ . Find all of the solutions for $P(x)$ . If we put $P(x) = ax + b $ the answer is obvious but how to determine all of the solutions ? 

A:

First get rid of the RHS by using $Q(x):=P(x)-4x-3$ so that $$Q(x+2)+Q(x-2)=P(x+2)-4x-8-3+P(x-2)-4x+8-3=0.$$
Then the solution of
$$Q(x+2)=-Q(x-2)$$ is of the form
$$Q(x)=(-1)^{\lfloor x/4\rfloor}Q(x\bmod 4),$$
where $Q(x)$ is absolutely arbitrary in $[0,4)$.
Hence,
$$\color{green}{P(x)=4x+3+(-1)^{\lfloor x/4\rfloor}Q(x\bmod 4)}.$$
Below, an example of a smooth solution:

and another, piecewise linear and discontinuous:

