Ask Your Question

Revision history [back]

I agree that many quarternion functionalities are missing. Here is simply the answer to the point 3) you have raised: a quaternion can be constructed directly from its coefficients by means of SageMath's standard element instanciation from the parent, i.e. H(...) where H is the quaternion algebra:

sage: H.<i,j,k> = QuaternionAlgebra(SR, -1, -1)
sage: var("t x y z", domain='real')
(t, x, y, z)
sage: q = H((t, x, y, z)); q
t + x*i + y*j + z*k
sage: q.conjugate()
t + (-x)*i + (-y)*j + (-z)*k
sage: q2 = H((2, 0, -3*x^2, 4)); q2
2 + (-3*x^2)*j + 4*k
sage: q2.conjugate()
2 + 3*x^2*j + (-4)*k

The reverse operation is provided by the method coefficient_tuple:

sage: q.coefficient_tuple()
(t, x, y, z)
sage: q2.coefficient_tuple()
(2, 0, -3*x^2, 4)