<s>[INST] How to compute the determinant of a tridiagonal matrix with constant diagonals? How to show that the determinant of the following $(n\times n)$ matrix
$$\begin{pmatrix}
5 & 2 & 0 & 0 & 0 & \cdots & 0 \\
2 & 5 & 2 & 0 & 0 & \cdots & 0 \\
0 & 2 & 5 & 2 & 0 & \cdots & 0 \\
\vdots & \vdots& \vdots& \vdots & \vdots & \vdots & \vdots \\
0 & \cdots & \cdots & 0 & 2 & 5 & 2 \\
0 & \cdots & \cdots & \cdots & \cdots & 2 & 5
\end{pmatrix}$$
is equal to $\frac13(4^{n+1}-1)$?

More generally:

How does one compute the determinant of the following tridiagonal matrix (where the three diagonals are constant)?
$$M_n(a,b,c) = \begin{pmatrix}
a & b & 0 & 0 & 0 & \cdots & 0 \\
c & a & b & 0 & 0 & \cdots & 0 \\
0 & c & a & b & 0 & \cdots & 0 \\
\vdots & \vdots& \vdots& \vdots & \vdots& \vdots & \vdots \\
0 & \cdots & \cdots & 0 & c & a & b \\
0 & \cdots & \cdots & \cdots & \cdots & c & a
\end{pmatrix}$$
Here $a,b,c$ can be taken to be real numbers, or complex numbers.

In other words, the matrix $M_n(a,b,c) = (m_{ij})_{1 \le i,j \le n}$ is such that
$$m_{ij} = \begin{cases}
a & i = j, \\
b & i = j - 1, \\
c & i = j + 1, \\
0 & \text{otherwise.}
\end{cases}$$
There does not seem to be an easy pattern to use induction: the matrix is not a diagonal block matrix of the type $M = \bigl(\begin{smallmatrix} A & C \\ 0 & B \end{smallmatrix}\bigr)$ (where we could use $\det(M) = \det(A) \det(B)$ for the induction step), and there are no lines or columns with only one nonzero entry, so Laplace expansion gets complicated quickly.
Is there a general pattern that one could use? Or is the answer only known on a case-by-case basis? It's possible to compute the determinant by hand for small $n$:
$$\begin{align}
\det(M_1(a,b,c)) & = \begin{vmatrix} a \end{vmatrix} = a  \\
\det(M_2(a,b,c)) & = \begin{vmatrix} a & b \\ c & a \end{vmatrix} = a^2 - bc \\
\det(M_3(a,b,c)) & = \begin{vmatrix} a & b & 0 \\ c & a & b \\ 0 & c & a \end{vmatrix} = a^3 - 2abc
\end{align}$$
But there is no readily apparent pattern and the computation becomes very difficult when $n$ gets large.
 [/INST] We will generalize Calvin Lin's answer a bit. Let
$$A_n = \begin{bmatrix} a & b & 0 & 0 & \cdots & 0\\ c & a & b & 0 & \cdots & 0\\ 0 & c & a & b & \cdots & 0\\ \vdots & \vdots & \vdots & \ddots & \cdots & 0\\ \vdots & \vdots & \vdots & \vdots & a & b\\ 0 & 0 & 0 & \cdots & c & a \end{bmatrix}.$$
We then have, by using Laplace expansion twice,
$$\det(A_n) = a \det(A_{n-1}) - bc \det(A_{n-2}).$$
Calling $\det(A_n) = d_n$ we have the following linear homogeneous recurrence relation:
$$d_n = a d_{n-1} - bc d_{n-2}.$$
The characteristic equation is
$$\begin{align}
x^2 - ax + bc = 0 & \implies \left(x - \frac{a}2 \right)^2 - \left(\frac{a}2 \right)^2 + bc = 0 \\
& \implies x = \frac{a \pm \sqrt{a^2-4bc}}2.
\end{align}$$
(This assumes a square roots exist. It's always the case in $\mathbb{C}$.)
Case 1: $a^2 - 4bc \neq 0$
In this case the characteristic polynomial has two distinct roots, so we have (for some constants $k_1$, $k_2$): $$d_n = k_1 \left( \dfrac{a + \sqrt{a^2-4bc}}2\right)^n + k_2 \left( \dfrac{a - \sqrt{a^2-4bc}}2\right)^n.$$
We have $d_1 = a$ and $d_2 = a^2 - bc$. We then get that $d_0 = 1$. Hence,
$$k_1 + k_2 = 1.$$
$$a (k_1 + k_2) + (k_1 - k_2)\sqrt{a^2-4bc} = 2a \implies k_1 - k_2 = \dfrac{a}{\sqrt{a^2-4bc}}.$$
Hence,
$$\begin{align}
k_1 & = \dfrac{a + \sqrt{a^2-4bc}}{2\sqrt{a^2-4bc}}, & k_2 & = -\dfrac{a-\sqrt{a^2-4bc}}{2\sqrt{a^2-4bc}}
\end{align}$$
And finally:
$$\color{red}{\det(A_n) = \dfrac1{\sqrt{a^2-4bc}} \left( \left( \dfrac{a + \sqrt{a^2-4bc}}2\right)^{n+1} - \left( \dfrac{a - \sqrt{a^2-4bc}}2\right)^{n+1}\right)}.$$

Plug in $a = 5$ and $b=c=2$ ($a^2 - 4 bc \neq 0$), to get
  $$\det(A_n) = \frac{1}{3} ( 4^{n+1} - 1)$$

Case 2: $a^2 - 4bc = 0$
If the characteristic polynomial has a double root $x = a/2$, there exist constants $k_1$, $k_2$ such that:
$$d_n = (k_1 + k_2 n) \bigl(\frac{a}{2}\bigr)^n.$$
The initial conditions are $d_0 = 1$ and $d_1 = a$, thus:
$$\begin{align}
k_1 & = 1 & (k_1 + k_2) a = 2a
\end{align}$$
If $a = 0$, then $4bc = a^2$ implies either $b$ or $c$ is zero, and $d_n = 0$ for $n \ge 1$. Otherwise $$(k_1 + k_2) a = 2a \implies k_1 + k_2 = 2 \implies k_2 = 1.$$
And finally:
$$\color{red}{\det(A_n) = (n+1) \bigl(\frac{a}{2}\bigr)^n}.$$
</s>