eigenvalue problem of a simple circulant matrix I've learn that the eigenvalues of this matrix
$$A=\begin{bmatrix}
2&-1&0&0&0\\
-1&2&-1&0&0\\
\vdots&\ddots&\ddots&\ddots&\vdots\\
0&0&-1&2&-1\\
0&0&0&-1&2
\end{bmatrix}$$
is $$\lambda_{j}=4\sin^2{\dfrac{j\pi}{2(n+1)}},j=1,2,\cdots,n$$
see How find this matrix has eigenvalues $\lambda_{j}=4\sin^2{\dfrac{j\pi}{2(n+1)}}$
And I think it is also possible to get similar eigenvalue result for a similar but circulant matrix, but I don't know how? any help? thanks in advance. 
$$A=\begin{bmatrix}
2&-1&0&0&\color{red}{-1}\\
-1&2&-1&0&0\\
\vdots&\ddots&\ddots&\ddots&\vdots\\
0&0&-1&2&-1\\
\color{red}{-1}&0&0&-1&2
\end{bmatrix}$$
 A: From the Wikipedia: the eigenvalues of a $n$-order circulant matrix are given by a certain linear combination of the powers of a certain $n$-th root of unity; namely, the coeficients are the entries of the first row of the matrix. Let $\omega_j := \exp(\tfrac{2\pi j}{n}i)$ where $i=\sqrt{-1}$. The first row of your matrix is
$$\begin{bmatrix}2&-1&0&0&\ldots&0&0&-1\end{bmatrix}.$$
So the eigenvalues are computed as
$$\begin{align}\lambda_j :=& 2+(-1)\omega_j +0\omega^2_j +0\omega^3_j +\ldots +0\omega^{n-3}_j +0\omega^{n-2}_j +(-1)\omega^{n-1}_j\\ {}=& 2-\omega_j-\omega^{n-1}_j.\end{align}$$
Note that $\omega^{n-1}_j =\omega^{-1}$, so
$$\begin{align}\lambda_j&=2-\exp\left(\dfrac{2\pi j}{n}i\right)-\exp\left(-\dfrac{2\pi j}{n}i\right)\\&=2-\left(\cos\left(\dfrac{2\pi j}{n}\right)+i\sin\left(\dfrac{2\pi j}{n}\right)\right)-\left(\cos\left(\dfrac{2\pi j}{n}\right)-i\sin\left(\dfrac{2\pi j}{n}\right)\right)\\&=2\left(1-\cos\left(\dfrac{2\pi j}{n}\right)\right)\\&=4\sin^2\left(\dfrac{\pi}{n}\cdot j\right)\end{align}$$
for $j=0,1,\ldots,n-1$. Note that $\lambda_{n-j}=\lambda_j$ for $1\leq j\leq n/2$, so distinct eigenvalues come in pairs (except for $\lambda_0=0$, and $\lambda_{n/2+1}=4$ when $n$ is even), so a formula fot getting the eigenvalues sorted is (beware, indexing change): $$\lambda_j =4\sin^2\left(\dfrac{\pi}{n} \left\lfloor\dfrac{j}{2}\right\rfloor\right),\quad j=1,2,\ldots,n.$$
