public class Polynomial extends java.lang.Object implements MathFunction, MathFunctionWithFirstDerivative, MathFunctionWithDerivative, MathFunctionWithIntegral, java.io.Serializable, java.lang.Cloneable
| Constructor and Description |
|---|
Polynomial(double... coeff)
Constructs a new polynomial with coefficients coeff.
|
| Modifier and Type | Method and Description |
|---|---|
Polynomial |
clone() |
double |
derivative(double x)
Computes (or estimates) the first derivative
of the function at point x.
|
double |
derivative(double x,
int n)
Computes (or estimates) the nth derivative
of the function at point x.
|
Polynomial |
derivativePolynomial(int n)
Returns a polynomial corresponding to the nth derivative of
this polynomial.
|
double |
evaluate(double x)
Returns the value of the function evaluated at x.
|
double |
getCoefficient(int i)
Returns the ith coefficient of the polynomial.
|
double[] |
getCoefficients()
Returns an array containing the coefficients of the polynomial.
|
int |
getDegree()
Returns the degree of this polynomial.
|
double |
integral(double a,
double b)
Computes (or estimates) the integral of the
function over the interval [a, b].
|
Polynomial |
integralPolynomial(double c)
Returns a polynomial representing the integral of this polynomial.
|
void |
setCoefficients(double... coeff)
Sets the array of coefficients of this polynomial to coeff.
|
java.lang.String |
toString() |
public Polynomial(double... coeff)
coeff - the coefficients of the polynomial.java.lang.NullPointerException - if coeff is null.java.lang.IllegalArgumentException - if the length of coeff is 0.public int getDegree()
public double[] getCoefficients()
public double getCoefficient(int i)
public void setCoefficients(double... coeff)
coeff - the new array of coefficients.java.lang.NullPointerException - if coeff is null.java.lang.IllegalArgumentException - if the length of coeff is 0.public double evaluate(double x)
MathFunctionevaluate in interface MathFunctionx - value at which the distribution function is evaluatedpublic double derivative(double x)
MathFunctionWithFirstDerivativederivative in interface MathFunctionWithFirstDerivativex - the point to evaluate the derivative to.public double derivative(double x,
int n)
MathFunctionWithDerivativeevaluate.derivative in interface MathFunctionWithDerivativex - the point to evaluate the derivate to.n - the order of the derivative.public Polynomial derivativePolynomial(int n)
n - the degree of the derivative.public double integral(double a,
double b)
MathFunctionWithIntegralintegral in interface MathFunctionWithIntegrala - the starting point of the interval.b - the ending point of the interval.public Polynomial integralPolynomial(double c)
+ ... +
,
c - the constant for the integral.public java.lang.String toString()
toString in class java.lang.Objectpublic Polynomial clone()
clone in class java.lang.ObjectTo submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.