private ArrayList<BigDec> getRoots(ConsCell equation) throws ParserException {
ArrayList<BigDec> roots = new ArrayList<BigDec>();
ArrayList<ConsCell> terms = getTerms(equation);
if (terms.size() < 1)
return roots;
BigDec highestCo = getCoefficient(terms.get(0)), lowestCo = getCoefficient(terms.get(terms.size() - 1));
if (!highestCo.isInt()) {
lowestCo = lowestCo.divide(highestCo);
highestCo = BigDec.ONE;
if (!lowestCo.isInt())
return roots;
}
if (!lowestCo.isInt()) {
highestCo = highestCo.divide(lowestCo);
lowestCo = BigDec.ONE;
if (!highestCo.isInt())
return roots;
}
ArrayList<BigDec> aN = findFactors(highestCo), a0 = findFactors(lowestCo);
for (BigDec i : a0)
for (BigDec a : aN) {
if (new BigDec(i).divide(new BigDec(a)).getInfinity() != 0)
continue;
roots.add(new BigDec(i).divide(new BigDec(a)));
roots.add(new BigDec(i).divide(new BigDec(a)).multiply(BigDec.MINUSONE));
}
return roots;
}