Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## umontreal.iro.lecuyer.functions
Class Polynomial

    java.lang.Object
      umontreal.iro.lecuyer.functions.Polynomial

All Implemented Interfaces:
  Serializable, Cloneable, MathFunction, MathFunctionWithDerivative, MathFunctionWithFirstDerivative, MathFunctionWithIntegral

    public class Polynomial

extends Object
implements MathFunction, MathFunctionWithFirstDerivative, MathFunctionWithDerivative, MathFunctionWithIntegral, Serializable, Cloneable

Represents a polynomial of degree n in power form. Such a polynomial is of the form p(x) = c0 + c1x + ... + cnxn, where c0,…, cn are the coefficients of the polynomial.

See Also:
  Serialized Form

Constructor Summary
`Polynomial(double... coeff)` Constructs a new polynomial with coefficients `coeff`.

Method Summary
`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`.
`String` | `toString()`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Polynomial

    public Polynomial(double... coeff)

  Constructs a new polynomial with coefficients `coeff`. The value of `coeff[i]` in this array corresponds to ci.

  Parameters:
    `coeff` - the coefficients of the polynomial.
  Throws:
    `NullPointerException` - if `coeff` is `null`.
    `IllegalArgumentException` - if the length of `coeff` is 0.

Method Detail

### getDegree

    public int getDegree()

  Returns the degree of this polynomial.

  Returns:
    the degree of this polynomial.

### getCoefficients

    public double[] getCoefficients()

  Returns an array containing the coefficients of the polynomial.

  Returns:
    the array of coefficients.

### getCoefficient

    public double getCoefficient(int i)

  Returns the ith coefficient of the polynomial.

  Returns:
    the array of coefficients.

### setCoefficients

    public void setCoefficients(double... coeff)

  Sets the array of coefficients of this polynomial to `coeff`.

  Parameters:
    `coeff` - the new array of coefficients.
  Throws:
    `NullPointerException` - if `coeff` is `null`.
    `IllegalArgumentException` - if the length of `coeff` is 0.

### evaluate

    public double evaluate(double x)

  Description copied from interface: `MathFunction`
  Returns the value of the function evaluated at x.

  Specified by:
    `evaluate` in interface `MathFunction`
  Parameters:
    `x` - value at which the distribution function is evaluated
  Returns:
    function evaluated at `x`

### derivative

    public double derivative(double x)

  Description copied from interface: `MathFunctionWithFirstDerivative`
  Computes (or estimates) the first derivative of the function at point `x`.

  Specified by:
    `derivative` in interface `MathFunctionWithFirstDerivative`
  Parameters:
    `x` - the point to evaluate the derivative to.
  Returns:
    the value of the derivative.

### derivative

    public double derivative(double x,
                             int n)

  Description copied from interface: `MathFunctionWithDerivative`
  Computes (or estimates) the nth derivative of the function at point `x`. For n = 0, this returns the result of `evaluate`.

  Specified by:
    `derivative` in interface `MathFunctionWithDerivative`
  Parameters:
    `x` - the point to evaluate the derivate to.
    `n` - the order of the derivative.
  Returns:
    the resulting derivative.

### derivativePolynomial

    public Polynomial derivativePolynomial(int n)

  Returns a polynomial corresponding to the nth derivative of this polynomial.

  Parameters:
    `n` - the degree of the derivative.
  Returns:
    the derivative.

### integral

    public double integral(double a,
                           double b)

  Description copied from interface: `MathFunctionWithIntegral`
  Computes (or estimates) the integral of the function over the interval [a, b].

  Specified by:
    `integral` in interface `MathFunctionWithIntegral`
  Parameters:
    `a` - the starting point of the interval.
    `b` - the ending point of the interval.
  Returns:
    the value of the integral.

### integralPolynomial

    public Polynomial integralPolynomial(double c)

  Returns a polynomial representing the integral of this polynomial. This integral is of the form

  ∫p(x)dx = c + c0x + c1x2 + ... + cnxn+1,

  where c is a user-defined constant.

  Parameters:
    `c` - the constant for the integral.
  Returns:
    the polynomial representing the integral.

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### clone

    public Polynomial clone()

  Overrides:
    `clone` in class `Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
| SSJ V. 2.1.1.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

To submit a bug or ask questions, send an e-mail to Pierre L'Ecuyer.