Hi
I've been facing an issue diagonalizing a particular matrix. Through Sympy
the resulting eigVecs do not form the diagonalizing transform. A further
45deg rotation is required to get the matrix diagonal.
What is the source of this error?
numpy ver: 1.26.4
sympy ver: 1.13.2
I've included the snippet below.
import sympy as sp
import numpy as np
from IPython.display import display, Math, HTML
delta, J, g = sp.symbols('delta J g')
A_1 = sp.Matrix([[J, 0, 0, g],
[0, J, 0, g],
[0, 0, J, g],
[g, g, g, 0]])
eigVals = A_1.eigenvals()
eigVecs = A_1.eigenvects()
P = sp.Matrix.hstack(*[vec for eig in eigVecs for vec in eig[2]])
display(Math(sp.latex(P)))
rows, cols = P.shape
# normalized transformation
normalized_columns = []
for i in range(cols):
col_new = P[:, i] / sp.sqrt(P[:, i].dot(P[:, i]))
# print(col_new)
normalized_columns.append(col_new)
P_norm = sp.Matrix.hstack(*normalized_columns)
display(Math(sp.latex(P_norm)))
A_1_val = A_1.subs({J: 66.14, g: 20 * np.sqrt(2)})
U_chk = P_norm.subs({J: 66.14, g: 20 * np.sqrt(2)})
res_mat = U_chk.transpose() @ A_1_val @ U_chk
display(Math(sp.latex(res_mat)))
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/sympy/d92c066c-b7e5-41ed-81e1-d898f17ded69n%40googlegroups.com.