<s>[INST] Find general sequence equation linear algebra Suppose that the sequence $x_0, x_1, x_2,\dots$ is defined by $x_0 = 7$, $x_1 = 2$, and $x_{k+2} = −x_{k+1}+2x_k$ for $k\geq0$. Find a general formula for $x_k$. Be sure to include parentheses where necessary, e.g. to distinguish $1/(2k)$ from $1/2k$.  
I have no idea how to do this question! Someone please help.
 [/INST] Just to show an alternative way, through generating function.
Allow me to change notation from $x$ to $a$ to avoid confusion in the following.
Starting from your recurrence
$$
\left\{ \begin{gathered}
  a_{\,0}  = 7 \hfill \\
  a_{\,1}  = 2 \hfill \\
  a_{\,k + 2}  =  - a_{\,k + 1}  + 2a_{\,k}  \hfill \\ 
\end{gathered}  \right.
$$
rewrite it so as to incorporate the initial conditions:
$$
\left\{ \begin{gathered}
  a_{\,k < 0}  = 0 \hfill \\
  a_{\,k}  =  - a_{\,k - 1}  + 2a_{\,k - 2}  + 9\left[ {k = 1} \right] + 7\left[ {k = 0} \right] \hfill \\ 
\end{gathered}  \right.
$$
where $[P]$ indicates the Iverson bracket
$$
\left[ P \right] = \left\{ {\begin{array}{*{20}c}
   1 & {P = TRUE}  \\
   0 & {P = FALSE}  \\
 \end{array} } \right.
$$
Then multiply by $z^k$ and sum up
$$
\begin{gathered}
  \sum\limits_{0\, \leqslant \,k} {a_{\,k} z^{\,k} }  =  - \sum\limits_{0\, \leqslant \,k} {a_{\,k - 1} z^{\,k} }  + 2\sum\limits_{0\, \leqslant \,k} {a_{\,k - 2} z^{\,k} }  + 9\sum\limits_{0\, \leqslant \,k} {\left[ {k = 1} \right]z^{\,k} }  + 7\sum\limits_{0\, \leqslant \,k} {\left[ {k = 0} \right]z^{\,k} }  =  \hfill \\
   =  - z\sum\limits_{0\, \leqslant \,k} {a_{\,k - 1} z^{\,k - 1} }  + 2z^2 \sum\limits_{0\, \leqslant \,k} {a_{\,k - 2} z^{\,k - 1} }  + 9z + 7 \hfill \\ 
\end{gathered} 
$$
So we get:
$$
\sum\limits_{0\, \leqslant \,k} {a_{\,k} z^{\,k} }  = F(z) =  - zF(z) + 2z^2 F(z) + 9z + 7
$$
$$
\begin{gathered}
  F(z) = \frac{{9z + 7}}
{{1 + z - 2z^2 }} =  - \frac{{9z + 7}}
{{\left( {2z + 1} \right)\left( {z - 1} \right)}} = \frac{5}
{{3\left( {2z + 1} \right)}} + \frac{{16}}
{{3\left( {1 - z} \right)}} =  \hfill \\
   = \frac{5}
{3}\sum\limits_{0\, \leqslant \,k} {\left( { - 2} \right)^{\,k} z^{\,k} }  + \frac{{16}}
{3}\sum\limits_{0\, \leqslant \,k} {z^{\,k} }  \hfill \\ 
\end{gathered} 
$$
$$
a_{\,k}  = \frac{{5\left( { - 2} \right)^{\,k}  + 16}}
{3}
$$
</s>