$f(x+1) + f(x-1) = x^2$ ; $f(x+4) + f(x-4) = 2\sin x$ , then $f(x) =$? Given $f$ is a complex valued function satisfying $$f(x+1) + f(x-1) = x^2 \\ 
f(x+4) + f(x-4) = 2\sin x$$
what is $f(x)$ ?
Here,  only for the first part MathWolfram alpha is showing $f(x)$ to be of type $c_1(i)^x + c_2(-i)^x + \dfrac{x^2 - 1}{2}$ but how are they introducing "$i$"? I used a generating function but was still unable to get those terms containing $i$ . Please help me with this problem.  
 A: The two conditions can be rewritten as
$$f(x+2)+f(x)=(x+1)^2$$
$$f(x+8)+f(x)=2\sin(x+4)$$
Iterating the first one gives
$$f(x+4)+f(x+2)=(x+3)^2$$
$$f(x+6)+f(x+4)=(x+5)^2$$
$$f(x+8)+f(x+6)=(x+7)^2$$
It follows
\begin{align}
2\sin(x+4) &= f(x+8)+f(x)\\
&= (x+7)^2-f(x+6)+f(x)\\
&= (x+7)^2-(x+5)^2+f(x+4)+f(x)\\
&= (x+7)^2-(x+5)^2+(x+3)^2-f(x+2)+f(x)\\
&= (x+7)^2-(x+5)^2+(x+3)^2-(x+1)^2+f(x)+f(x)\\
\end{align}
so
\begin{align}
f(x) &= \frac{2\sin(x+4)+(x+1)^2-(x+3)^2+(x+5)^2-(x+7)^2}{2}\\
&= \sin(x+4)-4x-16
\end{align}
A: Let's do two change of variables. First, $u = x-1$:
$$f(u+2) = (u+1)^2 - f(u)$$
Let's apply that multiple times:
$$\begin{align}
f(u+4) &= (u+3)^2 - f(u+2) = (u+3)^2 - (u+1)^2 + f(u)\\
f(u+6) &= (u+5)^2 - f(u+4) = (u+5)^2 - (u+3)^2 + (u+1)^2 - f(u)\\
f(u+8) &= (u+7)^2 - f(u+6) = (u+7)^2 - (u+5)^2 + (u+3)^2 - (u+1)^2 + f(u)
\end{align}$$
Which can be simplified to:
$$f(u+8) = 8u + 32 + f(u)$$
However we can also do the variable substitution $u = x - 4$ in our second identity:
$$f(u+8) = 2\sin (u+4) - f(u)$$
Giving equation:
$$8x + 32 + f(x) = 2\sin (x+4) - f(x)$$
$$2f(x) = 2\sin (x+4) - 8x - 32$$
$$f(x) = \sin (x+4) - 4x - 16$$
