kredel / java-algebra-system

Java Algebra System (JAS) Project
GNU General Public License v2.0
44 stars 9 forks source link

GenPolynomial#quotientRemainder() #9

Closed axkr closed 5 years ago

axkr commented 5 years ago

Using JAS 2.6.5961

For symbolic expressions the a.multiply(ci) in GenPolynomial#quotientRemainder() could return 0 or a more complicated expression which must be tested for 0.

Example for a complicated 0 expression: (e/Sqrt[-e/d]+d*Sqrt(-e/d))/Sqrt(-e/d)

In this case the while loop in the code below will never stop. Could JAS somehow handle this case? For example with testing for a.isZERO()

        while (!r.isZERO()) {
            ExpVector f = r.leadingExpVector();
            if (f.multipleOf(e)) {
                C a = r.leadingBaseCoefficient();
                ExpVector g = f.subtract(e);
                a = a.multiply(ci);
                q = q.sum(a, g);
                h = S.multiply(a, g);
                r = r.subtract(h);
                assert (!f.equals(r.leadingExpVector())) : "leadingExpVector not descending: " + f;
            } else {
                break;
            }
       }
axkr commented 5 years ago

By changing my IExpr#isZERO() implementation for symbolic expressions this issue seemed to be solved.

kredel commented 5 years ago

To simplify such expressions one should construct an appropriate transcendent and algebraic extension field which is then used as coefficient ring of the polynomials. Otherwise expressions not identical to 0 are not considered to be zero.