Diagonalization and linear transformations I have this question in my textbook:


  
*Find a basis B of $R^2$ such that the matrix of the linear transformation $T(x, y) = (y, x)$ is diagonal with respect to B, and give the diagonal matrix
  

I have no idea how to proceed.
This is the only relevant explanation in my textbook:
some image description
Maybe I can ask, how did they get that diagonal matrix in the book from the basis?
I can see how they got the standard matrix. 
and I can see how they got the basis:
enter image description here
But in the first photo, how do they go from the basis to the diagonal matrix?
EDIT
Is this right?
I have A = 
$$\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}$$
makes sense to me that this is the linear transformation matrix since 
$$\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} * \begin{bmatrix} 2 \\ 3 \end{bmatrix} = \begin{bmatrix} 3 \\ 2 \end{bmatrix}$$
So finding eigenvalues:
$$(\lambda + 1)(\lambda - 1)$$
so eigenvalues are (1, -1)
Finding eigenvectors:
$$I - A = \begin{bmatrix} 1 & -1 \\ -1 & 1 \end{bmatrix} $$
$$-> \begin{bmatrix} 1 & -1 \\ 0 & 0 \end{bmatrix}$$
$$\begin{bmatrix} x_1 \\ x_2 \end{bmatrix} = \begin{bmatrix} t \\ t \end{bmatrix} = t * \begin{bmatrix} 1 \\ 1 \end{bmatrix} $$
Doing the same thing for eigenvalue = -1 leads me to eigenvector = $\begin{bmatrix} -1 \\ 1 \end{bmatrix}$
So $P = \begin{bmatrix} 1 & -1 \\ 1 & 1 \end{bmatrix}$
And $$P^{-1} = \begin{bmatrix} 1 & -1 & 1 & 0 \\ 1 & 1 & 0 & 1 \end{bmatrix}$$
$$ = \begin{bmatrix} 1 & -1 & 1 & 0 \\ 0 & 2 & -1 & 1 \end{bmatrix}$$
$$\begin{bmatrix} 1 & 0 & \frac{1}{2} & \frac{1}{2} \\ 0 & 1 & \frac{-1}{2} & \frac{1}{2} \end{bmatrix}$$
so $$P^{-1} = \begin{bmatrix} \frac{1}{2} & \frac{1}{2} \\ \frac{-1}{2} & \frac{1}{2} \end{bmatrix}$$
I get the diagonal matrix defined by $$P^{-1} * A * P = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}$$
 A: First you should find the matrix that represents the linear transformation $T$ with respect to the standard basis $\alpha$ which is:
$ [T]_\alpha = \begin{bmatrix} 
0 & 1 \\
1 & 0 
\end{bmatrix}$, since $\begin{bmatrix} 1 \\ 0 \end{bmatrix} $ maps to $\begin{bmatrix} 0 \\ 1 \end{bmatrix} $ and vice versa.
Next, you should try to diagonalize (get into the form $ [T]_\alpha =PDP^{-1}$) the matrix by finding its eigenvalues and eigenvectors. The eigenvectors will form a basis iff $[T]_\alpha$ is diagonalizable, since they are linearly independent and the quantity of them matches the vector space's dimension.
Additionally, they will be the column vectors of $P$ with column $P_i$ being the eigenvector for eigenvalue $\lambda_i$ in the column $D_i$. Call this basis of eigenvectors $\beta$.
Note that is because $P$ is the same as the change-of-basis matrix from $\beta$ to $\alpha$. Therefore, inverting $P$ will give you the change-of-basis matrix from $\alpha$ to $\beta$.
Intuitively, you can think of what happens when you pass a vector $\vec{x}$ in its standard representation into the matrices $PDP^{-1}$ as this: $P^{-1}$ represents $\vec{x}$ in terms of the new basis $\beta$ which is the basis we need in order to easily evaluate the function $T$ (multiplying a vector by a diagonal matrix). After those two multiplications, all we need is to multiply by $P$ to change our value back to the basis that we usually like to work with.
A: If you have a basis of eigenvectors $B$ for a linear operator $T$, then $[T]_B$ is diagonal. The converse is true too: if $[T]_B$ is diagonal for a basis $B$, then $B$ consists only of eigenvectors.
The proof follows directly from the definition of $[T]_B$. Suppose $B = (v_1, \ldots, v_n)$ are eigenvectors, with respective eigenvalues $\lambda_1, \ldots, \lambda_n$. Then, we compute $[T]_B$ by transforming each $v_i$ by $T$, and expressing the result in terms of coordinate column vectors with respect to $B$. These column vectors form the columns of $[T]_B$.
So, if we apply $T$ to $v_i$, we get
$$T v_i = \lambda_i v_i = 0 v_1 + \ldots + 0 v_{i-1} + \lambda_i v_i + 0 v_{i+1} + \ldots + 0v_n,$$
hence the $i$th column of $[T]_B$ contains only $0$s except (possibly) in the $i$th position (i.e. on the main diagonal), where it is equal to $\lambda_i$. That is,
$$[T]_B = \operatorname{diag}(\lambda_1, \ldots, \lambda_n).$$
So, if you follow how to find the basis $B$ of eigenvectors, then simply computing the matrix for $T$ with respect to this basis will quickly and easily lead you to the answer.
