I would like to find the particular representation of an element in a quaternion order in terms of a specific basis in Sagemath. I can check whether the element is contained in the order, but I don't know how to find the specific representation without writing out the matrix and then asking Sage to solve the linear system over the integers. Obviously, this is not ideal and not very reproducible. An example is below (in this case the expression is truly trivial, but I want to be able to do this dynamically in cases where it is not trivial):
sage: Bpinf.<i,j,k> = QuaternionAlgebra(-39, -53)
sage: O = Bpinf.maximal_order()
sage: j in O
True
sage: O.basis()
(1, 1/2 + 1/2*i, j, 1/2 + 31/78*i + 1/2*j + 1/78*k)
sage: O(j).coefficients()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In [105], line 1
----> 1 O(j).coefficients()
File ~/sage/sage/src/sage/structure/element.pyx:494, in sage.structure.element.Element.__getattr__()
492 AttributeError: 'LeftZeroSemigroup_with_category.element_class' object has no attribute 'blah_blah'
493 """
--> 494 return self.getattr_from_category(name)
495
496 cdef getattr_from_category(self, name):
File ~/sage/sage/src/sage/structure/element.pyx:507, in sage.structure.element.Element.getattr_from_category()
505 else:
506 cls = P._abstract_element_class
--> 507 return getattr_from_other_class(self, cls, name)
508
509 def __dir__(self):
File ~/sage/sage/src/sage/cpython/getattr.pyx:361, in sage.cpython.getattr.getattr_from_other_class()
359 dummy_error_message.cls = type(self)
360 dummy_error_message.name = name
--> 361 raise AttributeError(dummy_error_message)
362 attribute = <object>attr
363 # Check for a descriptor (__get__ in Python)
AttributeError: 'sage.algebras.quatalg.quaternion_algebra_element.QuaternionAlgebraElement_rational_field' object has no attribute 'coefficients'
I attempted to use .coefficients()
here because that method appears in the Modules with Basis category, and does what I would like, but it appears that quaternion orders do not inherit from this category. Does anyone know a built-in way to do this?
This is not exactly "built in," but I think it does what you want:
sage: Bpinf.<i,j,k> = QuaternionAlgebra(-39, -53)
sage: O = Bpinf.maximal_order()
sage: B = [vector(v) for v in O.basis()]
sage: V = QQ**4
Now define a "submodule" (really just V
again) with a specified basis, to force the use of that basis when determining coefficients:
sage: W = V.submodule_with_basis(B)
sage: W.coordinate_vector(i.coefficient_tuple())
(-1, 2, 0, 0)
sage: W.coordinate_vector(j.coefficient_tuple())
(0, 0, 1, 0)
sage: W.coordinate_vector(k.coefficient_tuple())
(-8, -62, -39, 78)