public static void TestMultiVariatePolynomialDivision() { Monomial m1 = new Monomial(new int[] { 3, 0, 0 }); Monomial m2 = new Monomial(new int[] { 2, 1, 0 }); Monomial m3 = new Monomial(new int[] { 2, 0, 1 }); Monomial m4 = new Monomial(new int[] { 1, 0, 0 }); Polynomial dividend = new Polynomial(m1); dividend.AddMonomial(m2, -1); dividend.AddMonomial(m3, -1); dividend.AddMonomial(m4); dividend = new Polynomial(new Monomial(new int[] { 1, 0, 0 })); dividend.AddMonomial(new Monomial(new int[] { 0, 0, 1 }), -1); Polynomial divisor1 = new Polynomial(new Monomial(new int[] { 2, 1, 0 })); // (y^2 - 1) divisor1.AddMonomial(new Monomial(new int[] { 0, 0, 1 }), -1); Polynomial divisor2 = new Polynomial(new Monomial(new int[] { 1, 1, 0 })); // (xy - 1) divisor2.AddMonomial(new Monomial(new int[] { 0, 0, 0 }), -1); List <Polynomial> quotients = dividend.DivideBy(divisor1, divisor2); foreach (Monomial m in quotients.LastOrDefault().monomialData.Keys) { System.Console.WriteLine(string.Join(",", m.powers) + " coefficient: " + quotients.LastOrDefault().monomialData[m].ToString()); } }