Ask Your Question

Revision history [back]

If E denotes the difference;

sage: E = (M*N).inverse() - N.inverse()*M.inverse()
sage: E
[-sqrt(2/3)*sqrt(1/2) + 6/(6*sqrt(2/3)*sqrt(1/2) + 1) - 6*(3*sqrt(2/3) - sqrt(1/2))*(sqrt(2/3) - 2*sqrt(1/2))/((6*sqrt(2/3)*sqrt(1/2) + 1)^2*(sqrt(2/3)*sqrt(1/2) + (3*sqrt(2/3) - sqrt(1/2))*(sqrt(2/3) - 2*sqrt(1/2))/(6*sqrt(2/3)*sqrt(1/2) + 1) + 1)) - 1                                                           -1/2*sqrt(2/3) + sqrt(1/2) + 3*(sqrt(2/3) - 2*sqrt(1/2))/((6*sqrt(2/3)*sqrt(1/2) + 1)*(sqrt(2/3)*sqrt(1/2) + (3*sqrt(2/3) - sqrt(1/2))*(sqrt(2/3) - 2*sqrt(1/2))/(6*sqrt(2/3)*sqrt(1/2) + 1) + 1))]
[                                                           sqrt(2/3) - 1/3*sqrt(1/2) - 2*(3*sqrt(2/3) - sqrt(1/2))/((6*sqrt(2/3)*sqrt(1/2) + 1)*(sqrt(2/3)*sqrt(1/2) + (3*sqrt(2/3) - sqrt(1/2))*(sqrt(2/3) - 2*sqrt(1/2))/(6*sqrt(2/3)*sqrt(1/2) + 1) + 1))                                                                                                                   -sqrt(2/3)*sqrt(1/2) + 1/(sqrt(2/3)*sqrt(1/2) + (3*sqrt(2/3) - sqrt(1/2))*(sqrt(2/3) - 2*sqrt(1/2))/(6*sqrt(2/3)*sqrt(1/2) + 1) + 1) - 1/6]

You get a matrix whose entries are symbolic expressions. If we write:

sage: E == 0
False

We get false because the entries of E are not all zero, as symbolic expressions, but they are actually zero if we simplify all entries one by one:

sage: E[0][0]
-sqrt(2/3)*sqrt(1/2) + 6/(6*sqrt(2/3)*sqrt(1/2) + 1) - 6*(3*sqrt(2/3) - sqrt(1/2))*(sqrt(2/3) - 2*sqrt(1/2))/((6*sqrt(2/3)*sqrt(1/2) + 1)^2*(sqrt(2/3)*sqrt(1/2) + (3*sqrt(2/3) - sqrt(1/2))*(sqrt(2/3) - 2*sqrt(1/2))/(6*sqrt(2/3)*sqrt(1/2) + 1) + 1)) - 1
sage: E[0][0].full_simplify()
0
sage: E[0][1].full_simplify()
0
sage: E[1][1].full_simplify()
0
sage: E[1][0].full_simplify()
0

Note that checking whether a symbolic expression is equal to zero is undecidable in general (though we should admit that in the present case, this is just because symbolics is weak in Sage). Since your symbolic expressions represent algebraic numbers, you can change the ring over which E is defined to be the field of algebraic numbers. In this field, the equalty is decidable, and Sage knows how to handle it well:

sage: E.change_ring(QQbar) == 0
True