use of org.matheclipse.core.polynomials.longexponent.ExprPolynomial in project symja_android_library by axkr.
the class RootsFunctions method rootsOfQuadraticExprPolynomial.
/**
* Solve a polynomial with degree <= 2.
*
* @param expr
* @param varList
* @return <code>F.NIL</code> if no evaluation was possible.
*/
private static IAST rootsOfQuadraticExprPolynomial(final IExpr expr, IAST varList) {
IASTMutable result = F.NIL;
try {
// try to generate a common expression polynomial
ExprPolynomialRing ring = new ExprPolynomialRing(ExprRingFactory.CONST, varList);
ExprPolynomial ePoly = ring.create(expr, false, false, false);
ePoly = ePoly.multiplyByMinimumNegativeExponents();
result = rootsOfQuadraticPolynomial(ePoly);
if (result.isPresent() && expr.isNumericMode()) {
for (int i = 1; i < result.size(); i++) {
result.set(i, F.chopExpr(result.get(i), Config.DEFAULT_ROOTS_CHOP_DELTA));
}
}
result = QuarticSolver.sortASTArguments(result);
return result;
} catch (JASConversionException e2) {
LOGGER.debug("RootsFunctions.rootsOfQuadraticExprPolynomial() failed", e2);
}
return result;
}
Aggregations