Ask Your Question

Revision history [back]

A direct approach (not using symbolic solving) could be:

sage: A = matrix(QQ,[[3,1],[2,4]]) ; A
[3 1]
[2 4]
sage: B = matrix(QQ,[[2,4],[0,5]]) ; B
[2 4]
[0 5]
sage: A.is_similar(B)                       
True
sage: T = A.is_similar(B,transformation=True)[1] ; T
[ 1.000000000000000?             0.?e-18]
[0.2500000000000000? 0.2500000000000000?]
sage: T.change_ring(QQ)
[  1   0]
[1/4 1/4]
sage: G = T.change_ring(QQ)/det(T) ; G
[4 0]
[1 1]
sage: G * A * G^(-1) == B
True

See A.is_similar? for details.