An advanced simplification/expansion/comparison algorithm. To use
PolynomialCreator pc = new PolynomialCreator(jep); Node simp = pc.simplify(node); Node expand = pc.expand(node); boolean flag = pc.equals(node1,node2); int res = pc.compare(node1,node2); PNodeI poly = pc.createPoly(node);
The basic idea is to reduce each equation to a canonical form based on a total ordering of the terms.
For example a polynomial in x will always be in the form
a+b x+c x^2+d x^3.
This makes comparison of two polynomials easy as it is just necessary to compare term by term, whereas it is dificult
to compare x^2-1 with (x+1)*(x-1) without any simplification or reordering is tricky.
The precise total ordering is intentionally not defined as it may be later modified. As an illustration some of the rules for the ordering are 0<1<2, 5<x, x<x^2<x^3, x<y.
A polynomial is constructed from a set of monomials by arranging the monomials in order. Likewise a monomial is constructed from a set of variables by arranging the variables in name order.
The algorithm can also work with non-polynomial equations. Functions are order by the name of the function and the ordering of their arguments. Hence cos(x)<sin(x)<sin(y).