How to solve this difference equation $2x(k)-x(k+1)+x(k+2)=0$, with $x(0)=1, x(1)=0$

How to solve this difference equation $2x(k)-x(k+1)+x(k+2)=0$, with $x(0)=1, x(1)=0$?

I'm suggested to apply $\mathcal{Z}$ transform: then applying both sides we get

$$2X(z)-(zX(z)-zx(0))+(z^2X(x)-z^2x(0)-zx(1))=0 $$ which is equivalent to

$$ X(z)=\frac{z^2-z}{z^2-z+2} $$

here starts the difficult part, I only have a few inverses for $X(z)$ in a table, and that one is not in there. I have seen that some examples try to rewrite as $$\frac{1}{1+z^{-1}} $$ from where they get $(-1)^n$ but here $$ X(z)=\frac{z^2-z}{z^2-z+2}=\frac{z^2-\frac{1}{2}z}{z^2-z+\sqrt{2}^2}-\frac{\frac{1}{2}z}{z^2-z+\sqrt{2}^2}$$ but not sure how to continue. I don't even find the right tag for this question.

Wolfram gives a solution but seems difficult to get it: enter image description here

enter image description here

UPDATE: I found out what's happening. From a table I have applying $\mathcal{Z}$ $$\frac{zb(\sin a)}{z^2-2zb\cos a+b^2} \Longrightarrow b^n \sin(an) $$ and $$ \frac{z(z-b(\cos a))}{z^2-2zb\cos a+b^2} \Longrightarrow b^n \cos(an) $$ so rewriting with $b=\sqrt{2}$ and $a=\arctan \sqrt{7}$ so that $\sqrt{2}\cos(\arctan \sqrt{7})=1/2$ and $ \sqrt{2}\sin(\arctan \sqrt{7})/\sqrt{7}=1/2$ we have $$X(z)=\frac{z^2-z\sqrt{2}\cos(\arctan \sqrt{7})}{z^2-2\sqrt{2}\cos(\arctan \sqrt{7})z+\sqrt{2}^2}-\frac{z\sqrt{2}\sin(\arctan \sqrt{7})}{z^2-2\sqrt{2}\cos(\arctan \sqrt{7})z+\sqrt{2}^2} \cdot 1/\sqrt{7}$$

and the result from Wolfram follows immediatly.


It is a recursive sequence. \begin{gather*} x(k+2)−x(k+1)+2x(k)=0\\ x(0)=1,\quad x(1)=0\\ y^2−y+2=(y−2)(y+1)=0\\ y\in\{2,-1\}\Rightarrow x(k)=c_12^k+c_2(-1)^k\\ x(0)=c_12^0+c_2(-1)^0=c_1+c_2=1\\ x(1)=c_12^1+c_2(-1)^1=2c_1−c_2=0\\ c_1=\frac13,\quad c_2=\frac23\Rightarrow x(k)=\frac{2^k+2(-1)^k}3 \end{gather*} Hope this solution is acceptable.