I'm trying to write code to do multivariate polynomial division modulo-2 (so no coefficients or degrees).
Say I have the polynomial $xyzw + yz$ and want to divide it by $xw + xwz$. IIUC, the usual approach is to take the leading terms $xyzw$ and $xw$ and divide to get $yz$. Then, as you would with integer long division, multiply $yz$ by the divisor to get $$yz(xw + xwz) = xyzw + xyzw = 0$$
Oops. This doesn't work modulo 2 as they cancel!
I presume I can just pick another divisor term and try again. Is that right?
$$xyzw \div xwz = y$$
$$y(xw + xwz) = xyzw + xyw$$
After subtracting this away we get a factor of 'y' and a remainder of $xyzw + yz + xyzw + xyw = xyw + yz$.
$$y \times (xw + xwz) + xyw + yz$$
$$ = xyw + xywz + xyw + yz = xywz + yz$$
This case was something I hadn't thought of but now I'm worried that it might occur after some leading coefficient has been removed. Does this mean that the correct way to do this division is to enumerate all divisor terms in the case that the leading term doesn't work, then revert back to using the leading term for subsequent reductions?