} else if (expr instanceof Negation) { // P = -(Q)
if (matches(((Negation) expr).getChild())) {
return coeff.matches(new Negation(coeff.hit()).evaluate());
}
} else {
FunctionPattern f = new FunctionPattern(x);
Negation nf = new Negation(f);
if (nf.matches(expr) && matchesPower(f.hit())) {
return coeff.matches(Integers.getInstance().create(-1));
}
Multiplication ax = new Multiplication(coeff, f);
if (ax.matches(expr) && matchesPower(f.hit())) { // P = ax^n
return true;
}
Constant c = Numbers.constant("c");
Division xc = new Division(f, c);
if (xc.matches(expr) && matchesPower(f.hit())) { // P = x^n/c
return coeff.matches(new Division(Naturals.one(), c.hit()).evaluate());
}
}
value = null;