Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The reason is

TypeError: base ring of quaternion algebra must be a field

and the documentation of QuaternionAlgebra mentions it must be a field. To avoid the reason one may go to the source directly, this gives the short solution:

Short answer:

R.<e> = PolynomialRing(QQ, names='E').quotient( E^2 )
D, (i,j,k) = sage.algebras.free_algebra_quotient.hamilton_quatalg( R )

Test:

sage: (1+2*i+3*j+4*k+5*e)^6
(117480*e-12208) + (33360*e+8944)*i + (50040*e+13416)*j + (66720*e+17888)*k
sage: F.<I,J,K> = QuaternionAlgebra(QQ, -1,-1)
sage: (1+2*I+3*J+4*K)^6
-12208 + 8944*I + 13416*J + 17888*K

Explicit answer A more elaboarted way would be:

S.<E> = PolynomialRing( QQ )
R.<e> = S.quotient( E^2 )

A = FreeAlgebra(R, 3, 'u')
U = A.monoid()
I, J, K = U.gens()
mons = [ U(1), I, J, K, ]
M    = MatrixSpace(QQ, len(mons))

# columns for mats
#             1  I  J  K 
mats = [ M( [ 0, 1, 0, 0,    # 1*I
             -1, 0, 0, 0,    # I*I
              0, 0, 0,-1,    # J*I
              0, 0, 1, 0,    # K*I
              ] ),
         M( [ 0, 0, 1, 0,    # 1*J
              0, 0, 0, 1,    # I*J
             -1, 0, 0, 0,    # J*J
              0,-1, 0, 0,    # K*J
              ] ),
         M( [ 0, 0, 0, 1,    # 1*K
              0, 0,-1, 0,    # I*K
              0, 1, 0, 0,    # J*K
             -1, 0, 0, 0,    # K*K
              ] ),
         ]
D.<i,j,k> = FreeAlgebraQuotient(A, mons, mats)

(It would be maybe a good idea to mention in the documentation that the matrices correspond to the right multiplication with the generators, a while i was getting confused about this point.) Same test:

sage: (1+2*i+3*j+4*k+5*e)^6
(117480*e-12208) + (33360*e+8944)*i + (50040*e+13416)*j + (66720*e+17888)*k