# Section 7.2 $\quad$ Diagonalization and Similar Matrices (contd)

**Recall**
- We say $A$ and $B$ are similar if <br /><br />
- We say $A$ is diagonalizable if <br /><br />
- An $n\times n$ matrix $A$ is diagonalizable if and only if <br /><br />
- If $D = P^{-1}AP$, how to find $D$ and $P$? <br /><br />

### Example 1

Find a nonsingular matrix $P$ such that $P^{-1}AP$ is a diagonal matrix.
\begin{equation*}
  A = \left[
        \begin{array}{ccc}
          1 & 2 & 3\\
          0 & 1 & 0\\
          2 & 1 & 2\\
        \end{array}
      \right]
\end{equation*}


```python
from sympy import *

A = Matrix([[1, 2, 3], [0, 1, 0], [2, 1, 2]]);

A.diagonalize()
```




    (Matrix([
     [-3,  1, 1],
     [ 0, -6, 0],
     [ 2,  4, 1]]), Matrix([
     [-1, 0, 0],
     [ 0, 1, 0],
     [ 0, 0, 4]]))



If an $n\times n$ matrix $A$ has $n$ distinct eigenvalues,<br /><br /><br /><br />

If all roots of the characteristic polynomial of $A$ are not all distinct,<br /><br /><br /><br />

### Example 2

Determine if the matrix $A$ is diagonalizable, where
\begin{equation*}
  A = \left[
        \begin{array}{ccc}
          0 & 0 & 1\\
          0 & 1 & 2\\
          0 & 0 & 1\\
        \end{array}
      \right]
\end{equation*}


```python
from sympy import *

A = Matrix([[0, 0, 1], [0, 1, 2], [0, 0, 1]]);

A.is_diagonalizable()
```




    False



### Example 3

Determine if the matrix $A$ is diagonalizable, where
\begin{equation*}
  A = \left[
        \begin{array}{ccc}
          0 & 0 & 0\\
          0 & 1 & 0\\
          1 & 0 & 1\\
        \end{array}
      \right]
\end{equation*}


```python
from sympy import *

A = Matrix([[0, 0, 0], [0, 1, 0], [1, 0, 1]]);

A.is_diagonalizable()
```




    True



6a479beadc769b2c958d50c678353119c83c8ff9
ipynb
Jupyter Notebook
Jupyter_Notes/Lecture35_Sec7-2_DiagonalSimilarMat_Part2.ipynb
xiuquan0418/MAT341
2fb7ec4e5f0771f10719cb5e4a00a7ab07c49b59
MIT
Jupyter_Notes/Lecture35_Sec7-2_DiagonalSimilarMat_Part2.ipynb
xiuquan0418/MAT341
2fb7ec4e5f0771f10719cb5e4a00a7ab07c49b59
MIT
Jupyter_Notes/Lecture35_Sec7-2_DiagonalSimilarMat_Part2.ipynb
xiuquan0418/MAT341
2fb7ec4e5f0771f10719cb5e4a00a7ab07c49b59
MIT
Qwen/Qwen-72B
1. YES
2. YES