1 | initial version |
From your question and comments I understand you are interested in defining functions from the "quaternion algebra"
sage: K.<d> = NumberField(x^2 + 1)
sage: A.<i,j,k> = QuaternionAlgebra(K,-1,-1)
(note that -1 is a square in K, so this algebra is split: it's isomorphic to GL(2,K)) For instance, you might be interested in the function that sends the quaternion algebra element w+xi+yj+z*k to the 2x2 matrix with rows [w+x,y+z] and [y-z,w-x]. The following is a way of defining such a function.
sage: def C(u):
....: w,x,y,z=list(u)
....: return matrix(2,2,[w+x,y+z,y-z,w-x])
with the above commands you can do things like:
sage: C(2*i+i*j)
[ 2 1]
[-1 -2]
sage: C(3+5*i+d*j+11*k)
[ 8 d + 11]
[d - 11 -2]
Note that w+x*i+y*j+z*k
is not an element of A:
sage: w+x*i+y*j+z*k
NameError: name 'w' is not defined
You can't even construct the element, let alone apply C to it. If you want quaternions with w,x,y,z
in the coefficients, you'll have to declare a quaternion algebra over a ring that contains these elements, e.g., a multivariate function field. The "function" C is really only a "function" in the python/programming language sense, not a mathematical construct. You may notice that the definition of C never referenced the fact that our original A is defined over K, or in fact A at all. It only depends on the fact that its parameter u can be taken apart by list
into 4 coefficients that can be stuffed into a matrix. So we don't even have to change the definition of C.
sage: P.<w,x,y,z>=QQ[]
sage: L=P.fraction_field()
sage: A.<i,j,k> = QuaternionAlgebra(L,-1,-1)
sage: C(w+x*i+y*j+z*k)
[w + x y + z]
[y - z w - x]