1 | initial version |
I do not know well the quaternion algebra implementation, so I may miss a better answer ; hence a workaround :
sage: Q.<i,j,k> = QuaternionAlgebra(SR, -1, -1)
sage: a1, b1, c1, d1 = SR.var('a1, b1, c1, d1', domain = "real") # Note : RR is a numerical approximation ring...
sage: a2, b2, c2, d2 = SR.var('a2, b2, c2, d2', domain = "real")
sage: q1 = a1 + b1*i + c1*j + d1*k
sage: q2 = a2 + b2*i + c2*j + d2*k
sage: solve((q1*q2-q2*q1).coefficient_tuple(), [a1, b1, c1, d1])
[[a1 == r3, b1 == r3*r4/b2, c1 == r4, d1 == c2*r4/b2]]
This answer can be obtained in a form slightly easier to use :
sage: Sol2 = solve((q1*q2-q2*q1).coefficient_tuple(), [a1, b1, c1, d1], algorithm="sympy") ; Sol2
[{b1: b2*d1/d2, c1: c2*d1/d2}]
which do not involve new arbitrary variables.
HTH,
2 | No.2 Revision |
I do not know well the quaternion algebra implementation, so I may miss a better answer ; hence a workaround :
sage: Q.<i,j,k> = QuaternionAlgebra(SR, -1, -1)
sage: a1, b1, c1, d1 = SR.var('a1, b1, c1, d1', domain = "real") # Note : RR is a numerical approximation ring...
sage: a2, b2, c2, d2 = SR.var('a2, b2, c2, d2', domain = "real")
sage: q1 = a1 + b1*i + c1*j + d1*k
sage: q2 = a2 + b2*i + c2*j + d2*k
sage: solve((q1*q2-q2*q1).coefficient_tuple(), [a1, b1, c1, d1])
[[a1 == r3, b1 == r3*r4/b2, c1 == r4, d1 == c2*r4/b2]]
This answer can be obtained in a form slightly easier to use :
sage: Sol2 = solve((q1*q2-q2*q1).coefficient_tuple(), [a1, b1, c1, d1], algorithm="sympy") ; Sol2
[{b1: b2*d1/d2, c1: c2*d1/d2}]
which (which do not involve new arbitrary variables.variables.) or, shorter :
sage: solve((q1*q2-q2*q1).coefficient_tuple(), [a1, b1, c1, d1], algorithm="sympy")
[{b1: b2*d1/d2, c1: c2*d1/d2}]
HTH,