Computing determinant of a matrix with non-zero values on three diagonals

In Mathematica, the code

f[n_] := Table[
  Which[i == j, 2, Abs[i - j] == 2, 1, True, 0],
  {i, 1, n}, {j, 1, n}
  ];
Table[Det@f@n, {n, 1, 20}]

results in

{2, 4, 6, 9, 12, 16, 20, 25, 30, 36, 42, 49, 56, 64, 72, 81, 90, 100, 110, 121}

Searching for that sequence in the OEIS results in this and your formula is (up to replacing $n$ by $n+2$) the first one given there.

I'd say that the answer is therefore Yes :D

N.B. You should contact the OEIS so that they add this interpretation ofthe sequence of the (pretty impressive!) list they already have.


Cinkir develops in his paper a formula for the determinant of a pentadiagonal Toeplitz matrix. Specializing to your case, let

$$\mathbf P=\begin{pmatrix}a&b&c&&\\b&a&b&c&\\c&b&a&\ddots&\ddots\\&c&\ddots&\ddots&\\&&\ddots&&\end{pmatrix}$$

and consider the associated polynomial $p(x)=cx^4+bx^3+ax^2+bx+c$. The paper gives an expression for the determinant of $\mathbf P$ in terms of the roots of $p(x)$, with limiting cases considered if $p(x)$ has repeated roots.

For your specific case, $p(x)=(x^2+1)^2$; the formula for $\det \mathbf P$ if $p(x)$ takes the form $(x-r)^2(x-s)^2$ goes like

$$\det \mathbf P=\frac{r^{2 n+4}-r^{n+1} s^{n+1} \left((n+2)^2 r^2-2 (n+1) (n+3) r s+(n+2)^2 s^2\right)+s^{2 n+4}}{(r-s)^4}$$

Letting $r=i$ and $s=-i$ yields your formula.