public static class PolynomialFunction.Cubic extends PolynomialFunction.Quadratic implements PolynomialFunction.ClosedForm
COLLINEAR_TOLERANCE
Constructor and Description |
---|
Cubic(double q0,
double q1,
double q2,
double q3)
Creates a new instance of Quadratic
|
Cubic(PolynomialFunction.Cubic other)
Copy constructor
|
Modifier and Type | Method and Description |
---|---|
PolynomialFunction.Cubic |
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,
double q3)
Evaluates a quadratic polynomial of the form
y(x) = q0 + q1*x + q2*x^2 + q3*x^3 for a given value of "x"
|
static PolynomialFunction.Cubic |
fit(InputOutputSlopeTriplet p0,
InputOutputSlopeTriplet p1)
Fits a cubic to two InputOutputSlopeTriplets using a closed-form
solution
|
double |
getQ3()
Getter for q3
|
java.lang.Double[] |
roots()
Finds the roots (zero-crossings) of the quadratic, which has at most
two, but possibly one or zero
|
void |
setQ3(double q3)
Setter for q3
|
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,
double q3)
Finds the stationary point of the quadratic equation.
|
java.lang.String |
toString() |
evaluate, fit, fit, getQ2, roots, setQ2, stationaryPoints
fit, fit, getQ0, getQ1, setQ0, setQ1
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
differentiate
evaluate, evaluateAsDouble
public Cubic(double q0, double q1, double q2, double q3)
q0
- Constant (zeroth-order) coefficientq1
- Linear (first-order) coefficientq2
- Quadratic (second-order) coefficientq3
- Cubic (third-order) coefficientpublic Cubic(PolynomialFunction.Cubic other)
other
- Cubic to copypublic PolynomialFunction.Cubic 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.Quadratic
public java.lang.String toString()
toString
in class PolynomialFunction.Quadratic
public double evaluate(double input)
UnivariateScalarFunction
evaluate
in interface UnivariateScalarFunction
evaluate
in class PolynomialFunction.Quadratic
input
- Input to the Evaluatorpublic double differentiate(double input)
DifferentiableUnivariateScalarFunction
differentiate
in interface DifferentiableUnivariateScalarFunction
differentiate
in class PolynomialFunction.Quadratic
input
- Input about which to compute the derivative of the function outputpublic java.lang.Double[] roots()
PolynomialFunction.Quadratic
roots
in interface PolynomialFunction.ClosedForm
roots
in class PolynomialFunction.Quadratic
public java.lang.Double[] stationaryPoints()
PolynomialFunction.Quadratic
stationaryPoints
in interface PolynomialFunction.ClosedForm
stationaryPoints
in class PolynomialFunction.Quadratic
public static double evaluate(double x, double q0, double q1, double q2, double q3)
x
- Value at which to evaluate the polynomialq0
- Constant-term coefficientq1
- Linear-term coefficientq2
- Quadratic-term coefficientq3
- Cubic-term coefficientpublic static java.lang.Double[] stationaryPoints(double q0, double q1, double q2, double q3)
q0
- Constant-term coefficientq1
- Linear-term coefficientq2
- Quadratic-term coefficientq3
- Cubic-term coefficientpublic double getQ3()
public void setQ3(double q3)
q3
- Cubic (third-order) coefficientpublic static PolynomialFunction.Cubic fit(InputOutputSlopeTriplet p0, InputOutputSlopeTriplet p1)
p0
- First pointp1
- Second point