Here is my problem:
If $x\in \mathbb{Z}^{+}$ and $f(x+2)=f(x+1)+2f(x)$ find the function $f(x)$
where, $f(1)=4, f(2)=2.$
When I encounter this problem, I thought the question is wrong. I obviously, I would expect a question like this, for example: $f(5)+f(17)=?$
Anyway, I did something like this:
$f(3)=f(2)+2f(1)$
$f(4)=f(3)+2f(2)=f(2)+2f(1)+2f(2)=3f(2)+2f(1)$
$f(5)=f(4)+2f(3)=3f(2)+2f(1)+2f(2)+4f(1)=5f(2)+6f(1)$
$f(6)=f(5)+2f(4)=5f(2)+6f(1)+6f(2)+4f(1)=11f(2)+10f(1)$
$f(7)=f(6)+2f(5)=11f(2)+10f(1)+10f(2)+12f(1)=21f(2)+22f(1)$
$f(8)=f(7)+2f(6)=21f(2)+22f(1)+22f(2)+20f(1)=43f(2)+42f(1)$
$A_{f(2)} :=\left\{ 1,3,5,11,21,43 ... \right\}$
$B_{f(1)} :=\left\{ 2,2,6,10,22,42 ... \right\}$
Here, $A_{f(2)}$ and $B_{f(1)}$ are coefficients.
$A_{f_1(2)}=2^1-1; A_{f_2(2)}=2^2-2+1; A_{f_3(2)}=2^3-2^2+2-1;...; A_{f_n(2)}=2^n-2^{n-1}+2^{n-2}-2^{n-3}+2^{n-4}-2^{n-5}+...-...+ (-1)^n \Longrightarrow A_{f_n(1)}=\frac {2^{n+1}-2(-1)^{n+2}}{3}=\frac {2^{n+1}+2(-1)^{n+3}}{3}$
$B_{f_1(1)}=2^1; B_{f_2(1)}=2^2-2; B_{f_3(1)}=2^3-2^2+2;...;B_{f_n(1)}=2^n-2^{n-1}+2^{n-2}-2^{n-3}+2^{n-4}-2^{n-5}+...-...+2 (-1)^{n+1} \Longrightarrow B_{f_n(2)}=\frac{2^{n+1}-(-1)^{n+1}}{3}=\frac{2^{n+1}+(-1)^{n+2}}{3}$
$f(n+2)=2A_{f_n(1)}+4B_{f_n(2)}=\frac {2^{n+1}+2(-1)^{n+3}}{3} ×2+ \frac{2^{n+1}+(-1)^{n+2}}{3} ×2^2=2^{n+2}-2(-1)^{n+2} \iff f(x)=2^x-2(-1)^x$
Finally, I got an answer like this:
$$f(x)=2^x+2(-1)^{x+1} , x\in \mathbb Z^{+}$$
Honestly, I don't know. Maybe, this is a ridiculous way. Because, it might be an intelligent way for to do it. And You know what I will actually asking. Is my solution correct? Or,was there an intelligent way to do it?
Thank you!
Your solution is correct. The usual way is to assume the solution is of the form $a^x$ and plug it in to get the characteristic equation, which for you is $$a^2=a+2\\(a-2)(a+1)=0$$ The solution is then $b2^x+c(-1)^x$ and you evaluate $b,c$ from your initial conditions. A longer discussion is in Wikipedia or many texts.