Hello everyone,
I just discovered a bug in the polynomial division over quaternion algebras. I don't see it discussed anywhere on the internet, so I believe this is a proper place to report it.
Bug description: the quo_rem method for polynomials with quaternionic coefficients outputs incorrect results. Moreover, there is no way to specify whether we want a right or left division. Here is a specific example.
# Take the quaternion algebra (-1, -1)_QQ and the ring of polynomials over it:
HH = QuaternionAlgebra(QQ, -1, -1)
P.<x> = HH[]
# Take two polynomials
f = x^3 + HH.0*x + (HH.1 + 2*HH.2); print("f =", f)
g = HH.2*x + HH.1 + 3; print("g =", g)
# Try to compute the quotient and remainder
q, r = f.quo_rem(g)
# Check the correctness of the result assuming that this is RIGHT division
print(q*g + r == f)
# Check the correctness of the result assuming that this is LEFT division
print(g*q + r == f)
Both tests output False. Tested on Sage 9.5.
Mathematical background: the division with the remainder for polynomials over division rings is well known and fully described e.g. in [1] even in a more general setting when the variable does not commute with the coefficients (in our case it does commute). So it is just a matter of proper implementation.
[1] Ore, Oystein. Theory of non-commutative polynomials.
Ann. of Math. (2) 34 (1933), no. 3, 480--508.
MR1503119