SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.analysis.function.polynomial.root
Class Polyroot

java.lang.Object
  extended by com.numericalmethod.suanshu.analysis.function.polynomial.root.Polyroot
All Implemented Interfaces:
Solver

public class Polyroot
extends java.lang.Object
implements Solver

A solver for polynomial equations.

A root (or a zero) of a function f is a member x in the domain of f such that f(x) vanishes at x. That is

f(x) = 0

This is a wrapper class that solves for a Polynomial equation with non-negative, whole number exponents, e.g.,

ax4 + bx3 + cx2 + dx + e = 0

By the fundamental theorem of algebra, every polynomial of degree n has n roots. The roots can be both real (in double) or Complex.

By default, all polynomial equations are solved using Jenkins-Traub algorithm. Customized solvers of various types, such as Linear, Quadratic, Cubic, Quartic, can be registered via the constructor.

By Abel–Ruffini theorem, we have analytical solution for polynomials of degree up to 4.

See Also:

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.numericalmethod.suanshu.analysis.function.polynomial.root.Solver
Solver.RootFindingException, Solver.Type
 
Constructor Summary
Polyroot(Solver... solvers)
          Construct a Polyroot instance to solve polynomial equations.
 
Method Summary
 NumberList solve(Polynomial polynomial)
          Call the appropriate solver to find roots/zeros for the polynomial.
 Solver.Type type()
          Get the type of the solver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Polyroot

public Polyroot(Solver... solvers)
Construct a Polyroot instance to solve polynomial equations.

Customized solver for a particular type of polynomial can be registered via the solvers argument. For example,

Polyroot solver = new Polyroot(new Cubic(), new Quartic());
The default polynomial solver, JenkinsTraubReal, can be used to solve any polynomial equations.

Parameters:
solvers - customized solver implementations
Method Detail

type

public Solver.Type type()
Description copied from interface: Solver
Get the type of the solver.

Specified by:
type in interface Solver
Returns:
the solver type

solve

public NumberList solve(Polynomial polynomial)
Call the appropriate solver to find roots/zeros for the polynomial.

Specified by:
solve in interface Solver
Parameters:
polynomial - the polynomial to be solved
Returns:
the roots of the polynomial
Throws:
java.lang.IllegalArgumentException - if the polynomial is a constant, hence no variable

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.