Class QuadraticRoot
- java.lang.Object
-
- dev.nm.analysis.function.polynomial.root.QuadraticRoot
-
- All Implemented Interfaces:
PolyRootSolver
public class QuadraticRoot extends Object implements PolyRootSolver
This is a solver for finding the roots of a quadratic equation, \(ax^2 + bx + c = 0\). The roots are: \[ \frac{-b}{2a} \pm \frac{\sqrt{b^2-4ac}}{2a} \]- See Also:
- Wikipedia: Quadratic equation
-
-
Constructor Summary
Constructors Constructor Description QuadraticRoot()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Number>
solve(Polynomial polynomial)
List<Number>
solve(Polynomial polynomial, double epsilon)
Solve \(ax^2 + bx + c = 0\).
-
-
-
Method Detail
-
solve
public List<Number> solve(Polynomial polynomial, double epsilon)
Solve \(ax^2 + bx + c = 0\).- Parameters:
polynomial
- a quadratic equation to be solvedepsilon
- a precision parameter: when a number |x| ≤ ε, it is considered 0- Returns:
- the roots of the quadratic equation
- Throws:
IllegalArgumentException
- if the polynomial degree is not 2
-
solve
public List<Number> solve(Polynomial polynomial)
- Specified by:
solve
in interfacePolyRootSolver
-
-