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 ?
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:
This difference equation is linear so it's solution can be reprasented as

$$
P(x) = P_h(x) + P_p(x)
$$

with

$$
P_h(x+2)+P_h(x-2) = 0\\
P_p(x+2)+P_p(x-2) = 8x+6
$$

for the homogeneous we propose $P_h(x) = \gamma^x$ and after substituting

$$
\gamma^x\left(\gamma^2+\frac{1}{\gamma^2}\right)=0
$$

and the solutions are

$$
\gamma_h = \left\{-\frac{1+i}{\sqrt{2}},\frac{1+i}{\sqrt{2}},\frac{1-i}{\sqrt{2}},-\frac{1-i}{\sqrt{2}}\right\}
$$

so the homogeneous solution is 

$$
P_h(x) = C_1\sin\left(\frac{\pi x}{4}\right)+C_2\cos\left(\frac{\pi x}{4}\right)+C_3\sin\left(\frac{3\pi x}{4}\right)+C_4\cos\left(\frac{3\pi x}{4}\right)
$$

now for the particular making $P_p(x) = 4x+3$ we conclude

$$
P(x) = 4x+3+C_1\sin\left(\frac{\pi x}{4}\right)+C_2\cos\left(\frac{\pi x}{4}\right)+C_3\sin\left(\frac{3\pi x}{4}\right)+C_4\cos\left(\frac{3\pi x}{4}\right)
$$