static Polynomial[] linearize(Polynomial polynomial, Variable variable) {
   List l = new ArrayList();
   Generic x = variable.expressionValue();
   Polynomial s = polynomial;
   try {
     Polynomial r = s.valueOf(x);
     s = s.divide(r);
     l.add(r);
     while (true) s = s.divide(r);
   } catch (NotDivisibleException e) {
   }
   IntegerDivisor d[] = new IntegerDivisor[2];
   Generic p[] = new Generic[2];
   Generic q[] = new Generic[2];
   d[1] = IntegerDivisor.create(JsclInteger.valueOf(1));
   loop:
   while (d[1].hasNext()) {
     p[1] = (Generic) d[1].next();
     q[1] = d[1].integer(d[1].complementary());
     d[0] = IntegerDivisor.create(s.tail().coef().integerValue());
     while (d[0].hasNext()) {
       p[0] = (Generic) d[0].next();
       q[0] = d[0].integer(d[0].complementary());
       if (ArrayComparator.comparator.compare(q, p) < 0) break loop;
       for (int i = 0; i < 2; i++) {
         Polynomial r =
             s.valueOf(i == 0 ? p[1].multiply(x).subtract(p[0]) : p[1].multiply(x).add(p[0]));
         for (boolean flag = true; true; flag = false) {
           try {
             s = s.divide(r);
           } catch (NotDivisibleException e) {
             break;
           }
           d[1].divide();
           d[0].divide();
           if (flag) l.add(r);
         }
       }
     }
   }
   return (Polynomial[]) ArrayUtils.toArray(l, new Polynomial[l.size()]);
 }
 static Polynomial[] remainder(Polynomial s, Polynomial p, Generic t[]) {
   Polynomial zero = s.valueOf(JsclInteger.valueOf(0));
   Generic a[] = Basis.augment(t, s.remainderUpToCoefficient(p).elements());
   Variable unk[] = Basis.augmentUnknown(new Variable[] {}, p.elements());
   {
     Variable u = unk[unk.length - 1];
     System.arraycopy(unk, 0, unk, 1, unk.length - 1);
     unk[0] = u;
   }
   Generic be[][] =
       Linearization.compute(
           Basis.compute(a, unk, Monomial.lexicographic, 0, Basis.DEGREE).elements(), unk);
   for (int i = 0; i < be.length; i++) {
     Polynomial r = substitute(p, be[i], unk);
     try {
       return new Polynomial[] {zero, r, s.divide(r)};
     } catch (NotDivisibleException e) {
     }
   }
   return new Polynomial[] {s, zero, zero};
 }