gov.sandia.cognition.learning.function.scalar
Class PolynomialFunction.Cubic

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.math.AbstractScalarFunction<Double>
          extended by gov.sandia.cognition.math.AbstractUnivariateScalarFunction
              extended by gov.sandia.cognition.math.AbstractDifferentiableUnivariateScalarFunction
                  extended by gov.sandia.cognition.learning.function.scalar.PolynomialFunction.Linear
                      extended by gov.sandia.cognition.learning.function.scalar.PolynomialFunction.Quadratic
                          extended by gov.sandia.cognition.learning.function.scalar.PolynomialFunction.Cubic
All Implemented Interfaces:
Evaluator<Double,Double>, PolynomialFunction.ClosedForm, DifferentiableEvaluator<Double,Double,Double>, DifferentiableUnivariateScalarFunction, ScalarFunction<Double>, UnivariateScalarFunction, CloneableSerializable, Serializable, Cloneable
Enclosing class:
PolynomialFunction

public static class PolynomialFunction.Cubic
extends PolynomialFunction.Quadratic
implements PolynomialFunction.ClosedForm

Algebraic treatment for a polynomial of the form y(x) = q0 + q1*x + q2*x^2 + q3*x^3

See Also:
Serialized Form

Field Summary
 
Fields inherited from class gov.sandia.cognition.learning.function.scalar.PolynomialFunction.Linear
COLLINEAR_TOLERANCE
 
Constructor Summary
PolynomialFunction.Cubic(double q0, double q1, double q2, double q3)
          Creates a new instance of Quadratic
PolynomialFunction.Cubic(PolynomialFunction.Cubic other)
          Copy constructor
 
Method Summary
 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
 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
 Double[] stationaryPoints()
          Finds the real-valued stationary points (zero-derivatives) of the quadratic.
static Double[] stationaryPoints(double q0, double q1, double q2, double q3)
          Finds the stationary point of the quadratic equation.
 String toString()
           
 
Methods inherited from class gov.sandia.cognition.learning.function.scalar.PolynomialFunction.Quadratic
evaluate, fit, fit, getQ2, roots, setQ2, stationaryPoints
 
Methods inherited from class gov.sandia.cognition.learning.function.scalar.PolynomialFunction.Linear
fit, fit, getQ0, getQ1, setQ0, setQ1
 
Methods inherited from class gov.sandia.cognition.math.AbstractDifferentiableUnivariateScalarFunction
differentiate
 
Methods inherited from class gov.sandia.cognition.math.AbstractUnivariateScalarFunction
evaluate, evaluateAsDouble
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.math.ScalarFunction
evaluateAsDouble
 
Methods inherited from interface gov.sandia.cognition.evaluator.Evaluator
evaluate
 
Methods inherited from interface gov.sandia.cognition.math.DifferentiableEvaluator
differentiate
 

Constructor Detail

PolynomialFunction.Cubic

public PolynomialFunction.Cubic(double q0,
                                double q1,
                                double q2,
                                double q3)
Creates a new instance of Quadratic

Parameters:
q0 - Constant (zeroth-order) coefficient
q1 - Linear (first-order) coefficient
q2 - Quadratic (second-order) coefficient
q3 - Cubic (third-order) coefficient

PolynomialFunction.Cubic

public PolynomialFunction.Cubic(PolynomialFunction.Cubic other)
Copy constructor

Parameters:
other - Cubic to copy
Method Detail

clone

public PolynomialFunction.Cubic clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the 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.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class PolynomialFunction.Quadratic
Returns:
A clone of this object.

toString

public String toString()
Overrides:
toString in class PolynomialFunction.Quadratic

evaluate

public double evaluate(double input)
Description copied from interface: UnivariateScalarFunction
Produces a double output for the given double input

Specified by:
evaluate in interface UnivariateScalarFunction
Overrides:
evaluate in class PolynomialFunction.Quadratic
Parameters:
input - Input to the Evaluator
Returns:
output at the given input

differentiate

public double differentiate(double input)
Description copied from interface: DifferentiableUnivariateScalarFunction
Differentiates the output of the function about the given input

Specified by:
differentiate in interface DifferentiableUnivariateScalarFunction
Overrides:
differentiate in class PolynomialFunction.Quadratic
Parameters:
input - Input about which to compute the derivative of the function output
Returns:
Derivative of the output with respect to the input

roots

public Double[] roots()
Description copied from class: PolynomialFunction.Quadratic
Finds the roots (zero-crossings) of the quadratic, which has at most two, but possibly one or zero

Specified by:
roots in interface PolynomialFunction.ClosedForm
Overrides:
roots in class PolynomialFunction.Quadratic
Returns:
Array of roots

stationaryPoints

public Double[] stationaryPoints()
Description copied from class: PolynomialFunction.Quadratic
Finds the real-valued stationary points (zero-derivatives) of the quadratic. A quadratic has at most one stationary point, it may be a minimum or maximum.

Specified by:
stationaryPoints in interface PolynomialFunction.ClosedForm
Overrides:
stationaryPoints in class PolynomialFunction.Quadratic
Returns:
Zero- or One-length array of stationary points

evaluate

public 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"

Parameters:
x - Value at which to evaluate the polynomial
q0 - Constant-term coefficient
q1 - Linear-term coefficient
q2 - Quadratic-term coefficient
q3 - Cubic-term coefficient
Returns:
Value of the polynomial at "x"

stationaryPoints

public static Double[] stationaryPoints(double q0,
                                        double q1,
                                        double q2,
                                        double q3)
Finds the stationary point of the quadratic equation. That is, the point when the derivative f'(x)=0.0

Parameters:
q0 - Constant-term coefficient
q1 - Linear-term coefficient
q2 - Quadratic-term coefficient
q3 - Cubic-term coefficient
Returns:
Value of "x" when the derivative is zero, null when none is found

getQ3

public double getQ3()
Getter for q3

Returns:
Cubic (third-order) coefficient

setQ3

public void setQ3(double q3)
Setter for q3

Parameters:
q3 - Cubic (third-order) coefficient

fit

public static PolynomialFunction.Cubic fit(InputOutputSlopeTriplet p0,
                                           InputOutputSlopeTriplet p1)
Fits a cubic to two InputOutputSlopeTriplets using a closed-form solution

Parameters:
p0 - First point
p1 - Second point
Returns:
Cubic fitting the points