Eigenvalues and eigenvectors of a tridiagonal matrix with one nonzero diagonal coefficient I'm looking for the eigenvalues and eigenvectors of the $n\times n$ matrix, denoted $D_n=(d_{i,j})_{1\le i,j\le n}$ defined as
$$ 
d_{i,j} = \left\{\begin{array}{ll}
1 &\text{if } (|i-j|=1)\text{ or } (i=j=n),\\
0 &\text{otherwise.}  
\end{array}
\right.
$$
I tried to find the characteristic polynomial of $D_n$, denoted $\chi_{n}$, and I found that
$$ 
\chi_n(X) = (X-1)\tilde{\chi}_{n-1}(X)-\tilde{\chi}_{n-2}(X)
$$
where $\tilde{\chi}_p$ is the characteristic polynomial of the $p\times p$ matrix, denoted $\tilde{D}_n=(\tilde{d}_{i,j})_{1\le i,j\le n}$ defined as
$$ 
\tilde{d}_{i,j} = \left\{\begin{array}{ll}
1 &\text{if } |i-j|=1,\\
0 &\text{otherwise.}  
\end{array}
\right.
$$
It doesn't seem to lead to an easy solution. Indeed, one can easily find the eigenvalues of $\tilde{D}_n$ with this kind of method but I do not see how to find the eigenvalues of $D_n$ with this method.
 A: If $(\lambda,x)$ is an eigenpair, then we have the recurrence relation $x_k - \lambda x_{k-1} + x_{k-2} = 0$ for $k=3,\ldots,n$ and also the "boundary conditions" $x_2 = \lambda x_1$ and $x_{n-1}+x_n = \lambda x_n$.
Since nonzero multiples of eigenvectors are eigenvectors, the recurrence relation entails that we may take $x_k=e^{i(k\theta+\phi)}+e^{-i(k\theta+\phi)}$ for some real arguments $\theta$ and $\phi$, where
$$
e^{i\theta} = \frac{\lambda+i\sqrt{4-\lambda^2}}2.
$$
So, the boundary condition $x_2 = \lambda x_1$ gives
\begin{align*}
e^{i(2\theta+\phi)}+e^{-i(2\theta+\phi)}
&=\lambda (e^{i(\theta+\phi)}+e^{-i(\theta+\phi)})\\
&= (e^{i\theta}+e^{-i\theta})(e^{i(\theta+\phi)}+e^{-i(\theta+\phi)})\\
&=e^{i(2\theta+\phi)}+e^{-i(2\theta+\phi)}+e^{i\phi}+e^{-i\phi}.
\end{align*}
Hence $e^{i\phi}=-e^{-i\phi}$ and we may further let $x_k=e^{ik\theta}-e^{-ik\theta}$. The second boundary condition $x_{n-1}+x_n = \lambda x_n$ now gives
\begin{align*}
e^{i(n-1)\theta}-e^{-i(n-1)\theta}+e^{in\theta}-e^{-in\theta}
&=\lambda(e^{in\theta}-e^{-in\theta})\\
&=(e^{i\theta}+e^{-i\theta})(e^{in\theta}-e^{-in\theta})\\
&=e^{i(n-1)\theta}-e^{-i(n-1)\theta}+e^{i(n+1)\theta}-e^{-i(n+1)\theta}.
\end{align*}
Thus $e^{i(n+1)\theta}-e^{-i(n+1)\theta}=e^{in\theta}-e^{-in\theta}$, i.e. $\sin\left((n+1)\theta\right)=\sin(n\theta)$. Hence either $\theta=2m\pi$ or $(n+1)\theta=(2m+1)\pi-n\theta$ for some integer $m$. Since $\theta$ is not an integer multiple of $\pi$ (or else $x=0$), we must have
$$
\theta=\frac{2m+1}{2n+1}\pi
$$
for some $m$ such that $2n+1$ doesn't divide $2m+1$. Hence the eigenvalues of $D_n$ are given by $\lambda=2\Re(e^{i\theta})=2\cos\left(\frac{2m+1}{2n+1}\pi\right)$ for $m=0,1,\ldots,n-1$.
