# Calculation of a matrix determinant for general matrix size

Problem:
I have a matrix of the following form

Table[Which[i == j, -2 Cos[k], i == j + 1 , 1, j == i + 1, 1 , True, 0], {i, 1, m}, {j, 1, m}]


and I want to have a formula for its determinant for a general m.

Attempted solution:
I created a list of the values of the determinant for successive m and tried to simplify it to guess the answer.

function[m_Integer] := Det[Table[Which[i == j, -2 Cos[k], i == j + 1 , 1, j == i + 1, 1 , True, 0], {i, 1, m}, {j, 1, m}]];
Table[function[i], {i, 1, 20}] // FullSimplify


However it didn't yield an easily recognizable result:

{-2 Cos[k],1+2 Cos[2 k],-2 (Cos[k]+Cos[3 k]),1+2 Cos[2 k]+2 Cos[4 k],-2 (Cos[k]+Cos[3 k]+Cos[5 k]),1+2 Cos[2 k]+2 Cos[4 k]+2 Cos[6 k],-4 Cos[k] (Cos[2 k]+Cos[6 k]),1+2 Cos[2 k]+2 Cos[4 k]+2 Cos[6 k]+2 Cos[8 k],-2 (Cos[k]+Cos[3 k]+Cos[5 k]+Cos[7 k]+Cos[9 k]),1+2 Cos[2 k]+2 Cos[4 k]+2 Cos[6 k]+2 Cos[8 k]+2 Cos[10 k],-2 (Cos[k]+Cos[3 k]+Cos[5 k]+Cos[7 k]+Cos[9 k]+Cos[11 k]),1+2 Cos[2 k]+2 Cos[4 k]+2 Cos[6 k]+2 Cos[8 k]+2 Cos[10 k]+2 Cos[12 k],-2 (Cos[k]+Cos[3 k]+Cos[5 k]+Cos[7 k]+Cos[9 k]+Cos[11 k]+Cos[13 k]),1+2 Cos[2 k]+2 Cos[4 k]+2 Cos[6 k]+2 Cos[8 k]+2 Cos[10 k]+2 Cos[12 k]+2 Cos[14 k],-2 (Cos[k]+Cos[3 k]+Cos[5 k]+Cos[7 k]+Cos[9 k]+Cos[11 k]+Cos[13 k]+Cos[15 k]),1+2 Cos[2 k]+2 Cos[4 k]+2 Cos[6 k]+2 Cos[8 k]+2 Cos[10 k]+2 Cos[12 k]+2 Cos[14 k]+2 Cos[16 k],-2 (Cos[k]+Cos[3 k]+Cos[5 k]+Cos[7 k]+Cos[9 k]+Cos[11 k]+Cos[13 k]+Cos[15 k]+Cos[17 k]),1+2 Cos[2 k]+2 Cos[4 k]+2 Cos[6 k]+2 Cos[8 k]+2 Cos[10 k]+2 Cos[12 k]+2 Cos[14 k]+2 Cos[16 k]+2 Cos[18 k],-2 (Cos[k]+Cos[3 k]+Cos[5 k]+Cos[7 k]+Cos[9 k]+Cos[11 k]+Cos[13 k]+Cos[15 k]+Cos[17 k]+Cos[19 k]),1+2 Cos[2 k]+2 Cos[4 k]+2 Cos[6 k]+2 Cos[8 k]+2 Cos[10 k]+2 Cos[12 k]+2 Cos[14 k]+2 Cos[16 k]+2 Cos[18 k]+2 Cos[20 k]}


After a guess I could come with

Table[function[i]*Sin[k], {i, 1, 20}] // FullSimplify


which indeed solved the problem:

{-2 Cos[k] Sin[k],Sin[3 k],-Sin[4 k],Sin[5 k],-Sin[6 k],Sin[7 k],-Sin[8 k],Sin[9 k],-Sin[10 k],Sin[11 k],-Sin[12 k],Sin[13 k],-Sin[14 k],Sin[15 k],-Sin[16 k],Sin[17 k],-Sin[18 k],Sin[19 k],-Sin[20 k],Sin[21 k]}


However, this solution will work as long as one could come up with some suggestion about the form of the answer. Is there any better and more general way to solve this problem?

• Try TableForm@TrigToExp(FullSimplify@Table[function[i], {i, 1, 20}]). The result is pretty easy to suss out. Aug 7, 2018 at 12:26

Using the Laplace expansion of the determinant a[n] for the first column leads to a recurrence relation that can be solved with
RSolve[a[n] == -2 Cos[k] a[n - 1] - a[n - 2], a[n], n]

There are two "integration constants" that have to be fitted to a[1] and a[2] (which can be easily computed).