{%hackmd 5xqeIJ7VRCGBfLtfMi0_IQ %}
# Find a good basis
## Problem
Run the SageMath code below or simply click [here](https://sagecell.sagemath.org/?q=ukoobs).
```python=
load("https://raw.githubusercontent.com/jephianlin/LA-notebook/main/lingeo.py")
### code
set_random_seed(None)
n = 2
spec = random_int_list(n, 2)
D = diagonal_matrix(spec)
Q = random_good_matrix(n,n,n,2)
A = Q * D * Q.inverse()
pretty_print(LatexExpr("A ="), A)
pretty_print(
LatexExpr(r"\beta = \Big\{"),
*[Q[:,i] for i in range(n)],
LatexExpr(r"\Big\}")
)
```
Replace `None` with your favorite number and run the code again. The outcome is a matrix $A$. Find a basis $\beta$ such that $[f_A]_\beta^\beta$ is diagonal and check your answer with the output. When you are familiar with the process enough, try `n = 3` .
*This note can be found at Course website > Learning resources.*