Find a diagonal matrix M

Find a diagonal M, made up of 1's and -1's, to show that
$A=\begin{pmatrix} 2 & 1 & & \\ 1 & 2 & 1 & \\ & 1 & 2 & 1 \\ & & 1 & 2 \end{pmatrix}$ is similar to $B=\begin{pmatrix} 2 & -1 & & \\ -1 & 2 & -1 & \\ & -1 & 2 & -1 \\ & & -1 & 2 \end{pmatrix}$

I'm trying to understand $M^{-1}AM=B$ decomposition but a bit tricky for me.
Can anyone help me to understand how to solve this problem
and what is the solution?

-
I'm not sure how you're thinking of similarity, but if you think about it it terms of changing basis, simply find the change of basis matrix from $\{e_1,e_2,e_3,e_4\}$ to $\{e_1,-e_2,e_3,-e_4\}$ – Tom Oldfield Nov 24 '12 at 17:14

Think of it in terms of row and column operations. Given a $4\times 4$ matrix $C$, we have that $$\left(\begin{array}{cccc}1 & & & \\ & -1 & & \\ & & 1 & \\ & & & 1\end{array}\right)\cdot C,$$ for example, is the same as $C$, but with all the elements of the second row of $C$ multiplied by $-1$. On the other hand, $$C\cdot\left(\begin{array}{cccc}1 & & & \\ & -1 & & \\ & & 1 & \\ & & & 1\end{array}\right)$$ is the same as $C$, but with all the elements of the second column of $C$ multiplied by $-1$.

It's worth noting that a diagonal matrix with $\pm1$ on the diagonal is its own inverse, so that should also make things a bit easier.

-
Thanks for your explanation! – thistime Nov 24 '12 at 17:31

Multiplying by a diagonal matrix from the left multiplies the rows by the diagonal elements; multiplying by a diagonal matrix from the right multiplies the columns by the diagonal elements.

In the present case, you want the diagonal elements to remain unchanged and the off-diagonal elements to change sign; you can achieve this by multiplying, say, the even-numbered rows and columns by $-1$.

-
Thanks for your explanation! – thistime Nov 24 '12 at 17:30