Exercise 4.2.1.
Hint.
If this condition is true for all then it is true in particular for the vectors in the standard basis for
xxxxxxxxxx
from sympy import Matrix,init_printing,factor
init_printing()
A = Matrix(3,3,[5,-2,-4,-2,8,-2,-4,-2,5])
p=A.charpoly().as_expr()
factor(p)
xxxxxxxxxx
A.nullspace()
xxxxxxxxxx
from sympy import eye
B=A-9*eye(3)
B.nullspace()
xxxxxxxxxx
A.eigenvects()
xxxxxxxxxx
from sympy import GramSchmidt
L=B.nullspace()
GramSchmidt(L)
xxxxxxxxxx
L=[Matrix(3,1,[-1,0,1]),Matrix(3,1,[-1,2,0])]
GramSchmidt(L)
xxxxxxxxxx
P=Matrix(3,3,[2/3, -1/sqrt(2),1/sqrt(18), 1/3,0,-4/sqrt(18),2/3,1/sqrt(2),1/sqrt(18)])
P,P*P.transpose()
xxxxxxxxxx
Q=P.transpose()
Q*A*P
xxxxxxxxxx
A.diagonalize()