Issue
Firstly, I am sure that the Wolfram answer is the correct one because the two sandwich matrices is the eigen vecors matrices so the answer has to to be in the form of eigne bases.
so, the question is, what did i do wrong in the python code? is it the square roots of 5? is there a way to write them correctly?
Wolfram (Correct Answer):
Python Code (Wrong Answer):
In python, I tried another three matrices, that does not contain any elements with square roots, it gave the correct answer, so I think my problem is how to write them correctly in the matrix?
Solution
Wolfram does symbolic computation. Numpy numerical.
If you want to compare comparable things, you need to use symbolic computation on python side as well
import sympy
A = sympy.matrices.Matrix([[2,2],[1+sympy.sqrt(5), 1-sympy.sqrt(5)]])
B = sympy.matrices.Matrix([[0,1],[1,1]])
C = A**-1
sympy.pretty_print(sympy.simplify(C @ B @ A))
→
⎡1 √5 ⎤
⎢─ + ── 0 ⎥
⎢2 2 ⎥
⎢ ⎥
⎢ 1 √5⎥
⎢ 0 ─ - ──⎥
⎣ 2 2 ⎦
Answered By - chrslg
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.