Question

Hi basic question in trying to use commons-math's PolynomialSolver classes.

According to the documentation here http://commons.apache.org/math/userguide/analysis.html as well as the API the solving methods typically take the form

double c = solver.solve(100, function, 1.0, 5.0, AllowedSolution.LEFT_SIDE);

I'm obviously missing something, but given that the fundamental theorem of algebra is that there are n roots for a polynomial of n degree, how do I get all the roots?

What good is a root solver returning one double?

I noticed in this thread Finding roots of polynomial in Java that the method offered in the solutions returns a complex array. This is what I'd expect, so could someone kindly explain why the commons-math polynomial solvers are returning one double root?

Was it helpful?

Solution

most of these numerical algorithms operate on generic functions (i.e. not necessarily polynomials) and make few assumptions about them. if we don't know what given function's nature exactly is, we can't even expect to infer how many roots it might have.

some algorithms there make additional assumptions that given functions are differentiable. this makes them faster but require you to provide some additional info like derivate value so you can't use them for any function anymore.

LaguerreSolver makes additional assumption that given function is a polynomial. is this case it is possible to find all roots, hence solveAllComplex() method. but it is the only algorithm there specialized in polynomials. all the other algorithms are far more generic.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top