public class QuadraticSolver
extends java.lang.Object
| Constructor and Description |
|---|
QuadraticSolver() |
| Modifier and Type | Method and Description |
|---|---|
static int |
getRoots(double[] roots,
double a,
double b,
double c)
Find the real roots of the quadratic equation
|
static int |
getRoots(double[] roots,
double a,
double b,
double c,
double xlo,
double xhi)
Find the real roots of the quadratic equation
|
public static int getRoots(double[] roots,
double a,
double b,
double c)
a x^2 + b x + c = 0
There will be either 0, 1, or 2 roots, where the single
root case occurs when a = 0 or when there is a repeated root.
When there are two roots, they are sorted in increasing order.roots - returns the roots, must have length >= 2a - first coefficientb - second coefficientc - third coefficientpublic static int getRoots(double[] roots,
double a,
double b,
double c,
double xlo,
double xhi)
a x^2 + b x + c = 0
that lie within the interval [xlo, xhi].
There will be either 0, 1, or 2 roots, where the single
root case occurs when a = 0 or when there is a repeated root.
When there are two roots, they are sorted in increasing order.roots - returns the roots, must have length >= 2a - first coefficientb - second coefficientc - third coefficientxlo - lower bound on xxhi - upper bound on x