Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

solving for the center of the real quaternions

I'm trying out Sage on quaternions, on the problem of finding the center of the real Hamiltonian quaternions $\mathbb{H}$. So what I tried was:

Q.<i,j,k> = QuaternionAlgebra(SR, -1, -1)

a1, b1, c1, d1 = SR.var('a1, b1, c1, d1', domain = RR)
a2, b2, c2, d2 = SR.var('a2, b2, c2, d2', domain = RR)

q1 = a1 + b1*i + c1*j + d1*k
q2 = a2 + b2*i + c2*j + d2*k

solve([q1*q2 - q2*q1], a1, b1, c1, d1)

which rewarded me with:

TypeError                                 Traceback (most recent call last)
<ipython-input-3-fa8574b079be> in <module>()
----> 1 solve([q1*q2 - q2*q1], a1, b1, c1, d1)

/usr/lib/python2.7/dist-packages/sage/symbolic/relation.pyc in solve(f, *args, **kwds)
   1039             raise TypeError("The first argument to solve() should be a"
   1040                     "symbolic expression or a list of symbolic expressions, "
-> 1041                     "cannot handle %s"%repr(type(f)))
   1042 
   1043     if is_Expression(f): # f is a single expression

TypeError: The first argument to solve() should be asymbolic expression or a list of symbolic expressions, cannot handle <type 'list'>

Well, OK, that's not a symbolic expression:

sage: type(q1*q2 - q2*q1)
<type 'sage.algebras.quatalg.quaternion_algebra_element.QuaternionAlgebraElement_generic'>

and oddly, it's always zero?:

sage: q1*q2 - q2*q1 == 0
True

even though it's not:

sage: q1*q2 - q2*q1
((c1 - d1)*(c2 + d2) - (c1 + d1)*(c2 - d2))*i + (2*b2*d1 - 2*b1*d2)*j + (-(a2 + b2)*(c1 + d1) + (a2 - b2)*(c1 + d1) + (a1 + b1)*(c2 + d2) - (a1 - b1)*(c2 + d2) + 2*b2*d1 - 2*b1*d2)*k

I can figure out the answer from the last line, but was hoping for something like $b_1 = c_1 = d_1 = 0$. Not sure how this works.

solving for the center of the real quaternions

I'm trying out Sage on quaternions, on the problem of finding the center of the real Hamiltonian quaternions $\mathbb{H}$. So what I tried was:

Q.<i,j,k> = QuaternionAlgebra(SR, -1, -1)

a1, b1, c1, d1 = SR.var('a1, b1, c1, d1', domain = RR)
a2, b2, c2, d2 = SR.var('a2, b2, c2, d2', domain = RR)

q1 = a1 + b1*i + c1*j + d1*k
q2 = a2 + b2*i + c2*j + d2*k

solve([q1*q2 - q2*q1], solve(q1*q2 - q2*q1, a1, b1, c1, d1)

which rewarded me with:

TypeError                                 Traceback (most recent call last)
<ipython-input-3-fa8574b079be> <ipython-input-6-8a6c0ff8f7d0> in <module>()
----> 1 solve([q1*q2 - q2*q1], a1,       9 q2 = a2 + b2*i + c2*j + d2*k
     10 
---> 11 solve(q1*q2 - q2*q1, [a1, b1, c1, d1)

/usr/lib/python2.7/dist-packages/sage/symbolic/relation.pyc d1])

/home/sage/sage/local/lib/python3.7/site-packages/sage/symbolic/relation.py in solve(f, *args, **kwds)
   1039     1045 
   1046     if not isinstance(f, (list, tuple)):
-> 1047         raise TypeError("The first argument to solve() should must be a"
   1040                     "symbolic a symbolic expression or a list of symbolic expressions, "
-> 1041                     "cannot handle %s"%repr(type(f)))
   1042 
   1043     if is_Expression(f): expressions.")
   1048 
   1049     # f is a single expression
list of such expressions or equations

TypeError: The first argument to solve() should must be asymbolic a symbolic expression or a list of symbolic expressions, cannot handle <type 'list'>
expressions.

Well, OK, that's not a symbolic expression:

sage: type(q1*q2 - q2*q1)
<type <class 'sage.algebras.quatalg.quaternion_algebra_element.QuaternionAlgebraElement_generic'>

and oddly, it's always zero?:

sage: q1*q2 - q2*q1 == 0
True

even though it's not:At least this looks right:

sage: q1*q2 - q2*q1
((c1 - d1)*(c2 + d2) - (c1 + d1)*(c2 - d2))*i + (2*b2*d1 - 2*b1*d2)*j + (-(a2 + b2)*(c1 + d1) + (a2 - b2)*(c1 + d1) + (a1 + b1)*(c2 + d2) - (a1 - b1)*(c2 + d2) + 2*b2*d1 - 2*b1*d2)*k

I can figure out the answer from the last line, but was hoping for something like $b_1 = c_1 = d_1 = 0$. Not sure how this works.

update: Updated to Sage 9.1.