What I want to do: Check out the Trace proposition of linear algebra
{\rm Tr}(PAP^{-1})={\rm Tr}(A)
$ n $ Square matrix $ A = (a_ {ij}) $ plus the sum of diagonal components:
{\rm Tr}(A):=\sum_{i=1}^na_{ii}
A=\left(
\begin{matrix}
1 & 2 \\
3 & 4
\end{matrix}
\right),
P=\left(
\begin{matrix}
2 & 3 \\
4 & 5
\end{matrix}
\right)
will do. In the implementation it looks like this:
> import numpy as np
> A = np.array([[1,2],[3,4]])
> P = np.array([[2,3],[4,5]])
> A
array([[1, 2],
[3, 4]])
> P
array([[2, 3],
[4, 5]])
If the determinant is 0, there is no inverse matrix.
> np.linalg.det(P)
-2.0
→ It looks okay!
> np.trace(np.dot(np.dot(P,A),inv_P))
5.0
> np.trace(A)
5
Well, the result is that it seems to be so, but w
Of course, this cannot be a mathematical proof, but as a practice material for Python.
Recommended Posts