org.apache.commons.math.analysis
Class PolynomialFunction

java.lang.Object
  extended byorg.apache.commons.math.analysis.PolynomialFunction
All Implemented Interfaces:
Serializable, UnivariateRealFunction

public class PolynomialFunction
extends Object
implements UnivariateRealFunction, Serializable

Represents a Polynomial function. Spline functions map a certain interval of real numbers to real numbers. A cubic spline consists of segments of cubic functions. For this class, polynominal coefficents are used. Arguments outside of the domain cause an IllegalArgumentException.

Version:
$Revision: 1.2 $ $Date: 2003/11/19 03:28:23 $
See Also:
Serialized Form

Constructor Summary
PolynomialFunction(double[] c)
          Construct a function with the given segment delimiters and polynomial coefficients.
 
Method Summary
 double firstDerivative(double x)
          Compute the value for the first derivative of the function.
 double secondDerivative(double x)
          Compute the value for the second derivative of the function.
 double value(double x)
          Compute the value for the function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolynomialFunction

public PolynomialFunction(double[] c)
Construct a function with the given segment delimiters and polynomial coefficients.

Parameters:
c - polynominal coefficients
Method Detail

value

public double value(double x)
             throws MathException
Compute the value for the function.

This can be explicitly determined by c_n * x^n + ... + c_1 * x + c_0

Specified by:
value in interface UnivariateRealFunction
Parameters:
x - the point for which the function value should be computed
Returns:
the value
Throws:
MathException - if the function couldn't be computed due to missing additional data or other environmental problems.
See Also:
UnivariateRealFunction.value(double)

firstDerivative

public double firstDerivative(double x)
                       throws MathException
Compute the value for the first derivative of the function.

This can be explicitly determined by n * c_n * x^(n-1) + ... + 2 * c_2 * x + c_1

Parameters:
x - the point for which the first derivative should be computed
Returns:
the value
Throws:
MathException - if the derivative couldn't be computed.

secondDerivative

public double secondDerivative(double x)
                        throws MathException
Compute the value for the second derivative of the function.

This can be explicitly determined by n * (n-1) * c_n * x^(n-2) + ... + 3 * 2 * c_3 * x + 2 * c_2

Parameters:
x - the point for which the first derivative should be computed
Returns:
the value
Throws:
MathException - if the second derivative couldn't be computed.


Copyright © 2003-2004 Apache Software Foundation. All Rights Reserved.