this.accuracy = accuracy;
this.vars = new ArrayList<String>(vars);
this.range = range;
ArrayList<ConsCell> equationParts = equation.splitOnIdentifier("=");
if (equationParts.size() == 1)
equationParts.add(new ConsCell(BigDec.ZERO, ConsType.NUMBER));
if (parser.containsVariables(equationParts.get(0), vars) && parser.containsVariables(equationParts.get(1), vars))
equation = equationParts.get(0).append(parser.getCAS().invertSign(equation));
else {
if (parser.containsVariables(equationParts.get(0), vars)) {
equation = equationParts.get(0);
ConsCell temp = parser.run(parser.preProcess(equationParts.get(1)));
if (temp.getCarType() != ConsType.NUMBER || temp.length() != 1)
throw new UndefinedResultException("The NumericalSolver requires that the equation contain only one variable.", null);
answer = (BigDec) temp.getCar();
}
if (parser.containsVariables(equationParts.get(1), vars)) {
equation = equationParts.get(1);
ConsCell temp = parser.run(parser.preProcess(equationParts.get(0)));
if (temp.getCarType() != ConsType.NUMBER || temp.length() != 1)
throw new UndefinedResultException("The NumericalSolver requires that the equation contain only one variable.", null);
answer = (BigDec) temp.getCar();
}
}
this.equation = parser.preProcess(equation).clone();
variableCells = new ArrayList<ConsCell>();
containsFactorial = this.equation.containsIdentifier("factorial");