public static class PolynomialFunction.Quadratic extends PolynomialFunction.Linear
COLLINEAR_TOLERANCE
Constructor and Description |
---|
Quadratic(double q0,
double q1,
double q2)
Creates a new instance of Quadratic
|
Quadratic(PolynomialFunction.Quadratic other)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
PolynomialFunction.Quadratic |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
double |
differentiate(double input)
Differentiates the output of the function about the given input
|
double |
evaluate(double input)
Produces a double output for the given double input
|
static double |
evaluate(double x,
double q0,
double q1,
double q2)
Evaluates a quadratic polynomial of the form
y(x) = q0 + q1*x + q2*x^2 for a given value of "x"
|
static PolynomialFunction.Quadratic |
fit(InputOutputPair<java.lang.Double,java.lang.Double> p0,
InputOutputPair<java.lang.Double,java.lang.Double> p1,
InputOutputPair<java.lang.Double,java.lang.Double> p2)
Fits a quadratic to three points
|
static PolynomialFunction.Quadratic |
fit(InputOutputSlopeTriplet p0,
InputOutputPair<java.lang.Double,java.lang.Double> p1)
Fits a quadratic to two points, one of which has slope information.
|
double |
getQ2()
Getter for q2
|
java.lang.Double[] |
roots()
Finds the roots (zero-crossings) of the quadratic, which has at most
two, but possibly one or zero
|
static java.lang.Double[] |
roots(double q0,
double q1,
double q2)
Finds the roots of the quadratic equation using the quadratic
formula.
|
void |
setQ2(double q2)
Setter for q2
|
java.lang.Double[] |
stationaryPoints()
Finds the real-valued stationary points (zero-derivatives) of the
quadratic.
|
static java.lang.Double[] |
stationaryPoints(double q0,
double q1,
double q2)
Finds the stationary point of the quadratic equation.
|
java.lang.String |
toString() |
fit, fit, getQ0, getQ1, setQ0, setQ1
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
differentiate
evaluate, evaluateAsDouble
public Quadratic(double q0, double q1, double q2)
q0
- Constant (zeroth-order) coefficientq1
- Linear (first-order) coefficientq2
- Quadratic (second-order) coefficientpublic Quadratic(PolynomialFunction.Quadratic other)
other
- Quadratic to copypublic PolynomialFunction.Quadratic clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CloneableSerializable
clone
in class PolynomialFunction.Linear
public java.lang.String toString()
toString
in class PolynomialFunction.Linear
public double evaluate(double input)
UnivariateScalarFunction
evaluate
in interface UnivariateScalarFunction
evaluate
in class PolynomialFunction.Linear
input
- Input to the Evaluatorpublic double differentiate(double input)
DifferentiableUnivariateScalarFunction
differentiate
in interface DifferentiableUnivariateScalarFunction
differentiate
in class PolynomialFunction.Linear
input
- Input about which to compute the derivative of the function outputpublic java.lang.Double[] roots()
roots
in interface PolynomialFunction.ClosedForm
roots
in class PolynomialFunction.Linear
public java.lang.Double[] stationaryPoints()
stationaryPoints
in interface PolynomialFunction.ClosedForm
stationaryPoints
in class PolynomialFunction.Linear
public static double evaluate(double x, double q0, double q1, double q2)
x
- Value at which to evaluate the polynomialq0
- Constant-term coefficientq1
- Linear-term coefficientq2
- Quadratic-term coefficientpublic static PolynomialFunction.Quadratic fit(InputOutputPair<java.lang.Double,java.lang.Double> p0, InputOutputPair<java.lang.Double,java.lang.Double> p1, InputOutputPair<java.lang.Double,java.lang.Double> p2)
p0
- First pointp1
- Second pointp2
- Third pointpublic static PolynomialFunction.Quadratic fit(InputOutputSlopeTriplet p0, InputOutputPair<java.lang.Double,java.lang.Double> p1)
p0
- p1
- @PublicationReference(author="Wikipedia", title="Quadratic formula", type=WebPage, year=2008, url="http://en.wikipedia.org/wiki/Quadratic_formula#Quadratic_formula") public static java.lang.Double[] roots(double q0, double q1, double q2)
q0
- Constant-term coefficientq1
- Linear-term coefficientq2
- Quadratic-term coefficientpublic static java.lang.Double[] stationaryPoints(double q0, double q1, double q2)
q0
- Constant-term coefficientq1
- Linear-term coefficientq2
- Quadratic-term coefficientpublic double getQ2()
public void setQ2(double q2)
q2
- Second-order coefficient