For each $n \in \mathbb{N}$, let the sequence $m_n$ be defined by \begin{equation} m_n(x) = |\{(a_1, \ldots, a_{x+1}) \in \{1, \ldots, n\}^{x + 1} \mid a_1 = a_{n + 1}, \hspace{1mm} a_i \neq a_{i+1} \text{ for all } i\}| \end{equation}
That is, $m_n(x)$ is the cardinality of the set of all lists of length $x+1$ of numbers in $\{1, \ldots, n\}$, such that the first and last numbers in the list are equal, and such that no two consecutive elements in the list are equal. I want to show that $m_n(x) = tr((B - I)^n)$, where $B$ is the $n \times n$ matrix will all entries equal to $1$.
Here are my observations:
- The trace of a matrix $A$, by definition, is the sum of the eigenvalues of the matrix $A$, counting multiplicities.
- If $\lambda_1, \ldots, \lambda_n$ are the eigenvalues of a matrix $A$, then the eigenvalues of the matrix $A^k$ are exactly $\lambda_1^k, \ldots, \lambda_n^k$ (from here).
- $B - I$ is the matrix with main diagonal $0$ and all other entries $1$. From my work, it seems that row-reducing $B - I$ always leads to $I$ itself, and always involves an odd number of row swaps. Thus, I believe the determinant of $B - I$ is always $-1$, but I'm not sure about the trace.
- I also tried to combinatorically compute the size of $m_n(x)$. If we let
\begin{equation} D^K_{ij}(x) = |\{(a_1, \ldots, a_{x + 1}) \in \{1, \ldots, K\}^{x + 1} \mid a_y \neq a_{y+1} \text{ for all } y, \text{ and } a_1 = i, a_{x+1}=j\}| \end{equation}
- ...then we have the recurrence $D^K_{ij}(x) =$ the sum of all $D^K_{ib}(x - 1)$ such that $b \neq j$.
Could someone give hints/provide a solution to this problem?