$T(n) = \begin{cases} 2: & n=0\\ 5: & n=1 \\ 2T(n-2) - T(n-1): &n \geq 2 \end{cases}$
I have found a few examples including https://math.stackexchange.com/questions/1316301/if-tn-tn-1-2tn-2 But I am still lost about how to solve this one.
$T(n) = \begin{cases} 2: & n=0\\ 5: & n=1 \\ 2T(n-2) - T(n-1): &n \geq 2 \end{cases}$
I have found a few examples including https://math.stackexchange.com/questions/1316301/if-tn-tn-1-2tn-2 But I am still lost about how to solve this one.
Here's a general technique on linear recurrences that's useful to know. Observe that:
$$ \begin{bmatrix} T(n) \\ T(n+1) \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ 2 & -1 \end{bmatrix}^{n} \begin{bmatrix} 2 \\ 5 \end{bmatrix}$$
If we can perform an eigendecomposition of $M$:
$$M = Q \Lambda Q^{-1}$$
where $\Lambda$ is a diagonal matrix, then:
$$M^n = Q \Lambda^n Q^{-1}$$
Raising a diagonal matrix to a power is trivial. This gives you a closed form for $M^n$.
In your case:
$$\begin{bmatrix} 0 & 1 \\ 2 & -1 \end{bmatrix} = \begin{bmatrix} -\frac{1}{\sqrt{5}} & \frac{1}{\sqrt{2}} \\ \frac{2}{\sqrt{5}} & \frac{1}{\sqrt{2}} \end{bmatrix} \begin{bmatrix} -2 & 0 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} \frac{-\sqrt{5}}{3} & \frac{\sqrt{5}}{3} \\ \frac{2\sqrt{2}}{3} & \frac{\sqrt{2}}{3} \end{bmatrix}$$
So:
$$ \begin{bmatrix} T(n) \\ T(n+1) \end{bmatrix} = \begin{bmatrix} -\frac{1}{\sqrt{5}} & \frac{1}{\sqrt{2}} \\ \frac{2}{\sqrt{5}} & \frac{1}{\sqrt{2}} \end{bmatrix} \begin{bmatrix} -2 & 0 \\ 0 & 1 \end{bmatrix}^n \begin{bmatrix} \frac{-\sqrt{5}}{3} & \frac{\sqrt{5}}{3} \\ \frac{2\sqrt{2}}{3} & \frac{\sqrt{2}}{3} \end{bmatrix} \begin{bmatrix} 2 \\ 5 \end{bmatrix}$$
Multiplying the matrices together, taking the top row, and simplifying gives:
$$T(n) = 3 - (-2)^n$$
It's a lot of work (if you don't have a computer algebra system handy), but it always gives an answer if the system is linear and diagonalisable.