Determinant of nxn almost diagonal matrix [duplicate]

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}.$$


Let $M_n$ be the $n \times n$ matrix. Calculate the determinant by expanding along the first row and then by the second column, we get $ Det(M_n) = 5 Det(M_{n-1} ) - 4 Det(M_{n-2})$.

Let $Det(M_n) = D_n$, so $D_n$ satisfies the recurrence relation $D_n - 5 D_{n-1} + 4 D_{n-2} = 0$, with initial values $D_0 = 1, D_1 = 5$. The characteristic equation $x^2 - 5x + 4$ has roots $x= 4, 1$, so the solution has form $A4^n + B1^n$. Plugging in the initial values, we get $A= \frac {4}{3}, B= -\frac {1}{3}$, which yields the value $D_n = \frac {1}{3} (4^{n+1} - 1)$.


$D_0 = 1$ because it is the empty product, which by definition has the value 1. If you do not like to use $D_0 = 1$, you can just calculate $D_1 = 5$ and $D_2 = 5 \times 5 - 2 \times 2 = 21$ and then find the values of $A, B$.