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

Represents a polynomial that interpolates through a set of points. More...

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

Public Member Functions

 PolInterp (double[] x, double[] y)
 Constructs a new polynomial interpolating through the given points (x[0], y[0]), ..., (x[n], y[n]). More...
 
double [] getX ()
 Returns the \(x\) coordinates of the interpolated points. More...
 
double [] getY ()
 Returns the \(y\) coordinates of the interpolated points. More...
 
String toString ()
 Calls toString(double[], double[]) with the associated points. More...
 
PolInterp clone ()
 
- Public Member Functions inherited from Polynomial
 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 ()
 

Static Public Member Functions

static double [] getCoefficients (double[] x, double[] y)
 Computes and returns the coefficients the polynomial interpolating through the given points (x[0], y[0]), ..., (x[n], y[n]). More...
 
static String toString (double[] x, double[] y)
 Makes a string representation of a set of points. More...
 

Detailed Description

Represents a polynomial that interpolates through a set of points.

More specifically, let \((x_0,y_0), …, (x_n, y_n)\) be a set of points and \(p(x)\) the constructed polynomial of degree \(n\). Then, for \(i=0,…,n\), \(p(x_i)=y_i\).

Constructor & Destructor Documentation

◆ PolInterp()

PolInterp ( double []  x,
double []  y 
)

Constructs a new polynomial interpolating through the given points (x[0], y[0]), ..., (x[n], y[n]).

This constructs a polynomial of degree n from n+1 points.

Parameters
xthe \(x\) coordinates of the points.
ythe \(y\) coordinates of the points.
Exceptions
NullPointerExceptionif x or y are null.
IllegalArgumentExceptionif the lengths of x and y are different, or if less than two points are specified.

Member Function Documentation

◆ getCoefficients()

static double [] getCoefficients ( double []  x,
double []  y 
)
static

Computes and returns the coefficients the polynomial interpolating through the given points (x[0], y[0]), ..., (x[n], y[n]).

This polynomial has degree n and there are n+1 coefficients.

Parameters
xthe \(x\) coordinates of the points.
ythe \(y\) coordinates of the points.
Returns
the coefficients the interpolating polynomial.

◆ getX()

double [] getX ( )

Returns the \(x\) coordinates of the interpolated points.

Returns
the \(x\) coordinates of the interpolated points.

◆ getY()

double [] getY ( )

Returns the \(y\) coordinates of the interpolated points.

Returns
the \(y\) coordinates of the interpolated points.

◆ toString() [1/2]

static String toString ( double []  x,
double []  y 
)
static

Makes a string representation of a set of points.

Parameters
xthe \(x\) coordinates of the points.
ythe \(y\) coordinates of the points.
Returns
the string representing the points.

◆ toString() [2/2]

String toString ( )

Calls toString(double[], double[]) with the associated points.

Returns
a string containing the points.

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