Ask Your Question

Revision history [back]

You should define Q as a QuaternionAlgebra over the symbolic ring SR instead of over the rationals:

sage: Q.<i,j,k> = QuaternionAlgebra(SR, -1, -1)
sage: q = a*i + b*j + c*k
sage: q
a*i + b*j + c*k
sage: q^2
-a^2 - b^2 - c^2