SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | List of all members
Polynomial Class Reference

Represents a polynomial of degree \(n\) in power form. More...

Inheritance diagram for Polynomial:
[legend]
Collaboration diagram for Polynomial:
[legend]

Public Member Functions

 Polynomial (double... coeff)
 Constructs a new polynomial with coefficients coeff. More...
 
int getDegree ()
 Returns the degree of this polynomial. More...
 
double [] getCoefficients ()
 Returns an array containing the coefficients of the polynomial. More...
 
double getCoefficient (int i)
 Returns the \(i\)th coefficient of the polynomial. More...
 
void setCoefficients (double... coeff)
 Sets the array of coefficients of this polynomial to coeff. More...
 
double evaluate (double x)
 Returns the value of the function evaluated at \(x\). More...
 
double derivative (double x)
 Computes (or estimates) the first derivative of the function at point x. More...
 
double derivative (double x, int n)
 Computes (or estimates) the \(n\)th derivative of the function at point x. More...
 
Polynomial derivativePolynomial (int n)
 Returns a polynomial corresponding to the \(n\)th derivative of this polynomial. More...
 
double integral (double a, double b)
 Computes (or estimates) the integral of the function over the interval \([a, b]\). More...
 
Polynomial integralPolynomial (double c)
 Returns a polynomial representing the integral of this polynomial. More...
 
String toString ()
 
Polynomial clone ()
 

Detailed Description

Represents a polynomial of degree \(n\) in power form.

Such a polynomial is of the form

\[ p(x) = c_0 + c_1x + \cdots+ c_nx^n, \]

where \(c_0, …, c_n\) are the coefficients of the polynomial.

Constructor & Destructor Documentation

◆ Polynomial()

Polynomial ( double...  coeff)

Constructs a new polynomial with coefficients coeff.

The value of coeff[i] in this array corresponds to \(c_i\).

Parameters
coeffthe coefficients of the polynomial.
Exceptions
NullPointerExceptionif coeff is null.
IllegalArgumentExceptionif the length of coeff is 0.

Member Function Documentation

◆ derivative() [1/2]

double derivative ( double  x)

Computes (or estimates) the first derivative of the function at point x.

Parameters
xthe point to evaluate the derivative to.
Returns
the value of the derivative.

Implements MathFunctionWithFirstDerivative.

◆ derivative() [2/2]

double derivative ( double  x,
int  n 
)

Computes (or estimates) the \(n\)th derivative of the function at point x.

For \(n=0\), this returns the result of umontreal.ssj.functions.MathFunction.evaluate(double).

Parameters
xthe point to evaluate the derivate to.
nthe order of the derivative.
Returns
the resulting derivative.
Exceptions
IllegalArgumentExceptionif n is negative or 0.

Implements MathFunctionWithDerivative.

◆ derivativePolynomial()

Polynomial derivativePolynomial ( int  n)

Returns a polynomial corresponding to the \(n\)th derivative of this polynomial.

Parameters
nthe degree of the derivative.
Returns
the derivative.

◆ evaluate()

double evaluate ( double  x)

Returns the value of the function evaluated at \(x\).

Parameters
xvalue at which the function is evaluated
Returns
function evaluated at x

Implements MathFunction.

◆ getCoefficient()

double getCoefficient ( int  i)

Returns the \(i\)th coefficient of the polynomial.

Returns
the array of coefficients.

◆ getCoefficients()

double [] getCoefficients ( )

Returns an array containing the coefficients of the polynomial.

Returns
the array of coefficients.

◆ getDegree()

int getDegree ( )

Returns the degree of this polynomial.

Returns
the degree of this polynomial.

◆ integral()

double integral ( double  a,
double  b 
)

Computes (or estimates) the integral of the function over the interval \([a, b]\).

Parameters
athe starting point of the interval.
bthe ending point of the interval.
Returns
the value of the integral.

Implements MathFunctionWithIntegral.

◆ integralPolynomial()

Polynomial integralPolynomial ( double  c)

Returns a polynomial representing the integral of this polynomial.

This integral is of the form

\[ \int p(x)dx = c + c_0x + \frac{c_1 x^2}{2} + \cdots+ \frac{c_n x^{n+1}}{n+1}, \]

where \(c\) is a user-defined constant.

Parameters
cthe constant for the integral.
Returns
the polynomial representing the integral.

◆ setCoefficients()

void setCoefficients ( double...  coeff)

Sets the array of coefficients of this polynomial to coeff.

Parameters
coeffthe new array of coefficients.
Exceptions
NullPointerExceptionif coeff is null.
IllegalArgumentExceptionif the length of coeff is 0.

The documentation for this class was generated from the following file: