The approximated function should be smooth enough for Lagrange polynomial to work well. Otherwise, consider using splines instead.
| Modifier and Type | Field and Description |
|---|---|
| private double[] | coefficients
The coefficients of the polynomial, ordered by degree -- i.e. coefficients[0] is the constant term and coefficients[n] is the coefficient of x^n where n is the degree of the polynomial. |
| private boolean | coefficientsComputed
Whether the polynomial coefficients are available. |
| private final double[] | x
Interpolating points (abscissas). |
| private final double[] | y
Function values at interpolating points. |
| Access | Constructor and Description |
|---|---|
| public | PolynomialFunctionLagrangeForm(double[]
interpolating points x, double[] function values at interpolating points y)Construct a Lagrange polynomial with the given abscissas and function values. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | |
| public int | |
| public static double | Returns: the function value.Interpolating points array. x, double[] Interpolating values array. y, double Point at which the function value is to be computed. z)Evaluate the Lagrange polynomial using Neville's Algorithm. |
| private static double | Returns: the function value.Interpolating points array. x, double[] Interpolating values array. y, double Point at which the function value is to be computed. z)Evaluate the Lagrange polynomial using Neville's Algorithm. |
| public double[] | Returns: a fresh copy of the coefficients arrayReturns a copy of the coefficients array. |
| public double[] | Returns: a fresh copy of the interpolating points arrayReturns a copy of the interpolating points array. |
| public double[] | Returns: a fresh copy of the interpolating values arrayReturns a copy of the interpolating values array. |
| public double | Returns: the function value.Point at which the function value is to be computed. z)Implements org. Calculate the function value at the given point. |
| public static boolean | Returns: false if the x is not sorted in increasing order,
true otherwise.Interpolating points array. x, double[] Interpolating values array. y, boolean Whether to throw an exception if abort)x is not sorted.Check that the interpolation arrays are valid. |
| coefficients | back to summary |
|---|---|
| private double[] coefficients The coefficients of the polynomial, ordered by degree -- i.e. coefficients[0] is the constant term and coefficients[n] is the coefficient of x^n where n is the degree of the polynomial. | |
| coefficientsComputed | back to summary |
|---|---|
| private boolean coefficientsComputed Whether the polynomial coefficients are available. | |
| x | back to summary |
|---|---|
| private final double[] x Interpolating points (abscissas). | |
| y | back to summary |
|---|---|
| private final double[] y Function values at interpolating points. | |
| PolynomialFunctionLagrangeForm | back to summary |
|---|---|
| public PolynomialFunctionLagrangeForm(double[] x, double[] y) throws DimensionMismatchException, NumberIsTooSmallException, NonMonotonicSequenceException Construct a Lagrange polynomial with the given abscissas and function values. The order of interpolating points are not important. The constructor makes copy of the input arrays and assigns them.
| |
| computeCoefficients | back to summary |
|---|---|
| protected void computeCoefficients() Calculate the coefficients of Lagrange polynomial from the interpolation data. It takes O(n^2) time. Note that this computation can be ill-conditioned: Use with caution and only when it is necessary. | |
| degree | back to summary |
|---|---|
| public int degree() Returns the degree of the polynomial.
| |
| evaluate | back to summary |
|---|---|
| public static double evaluate(double[] x, double[] y, double z) throws DimensionMismatchException, NumberIsTooSmallException, NonMonotonicSequenceException Evaluate the Lagrange polynomial using Neville's Algorithm. It takes O(n^2) time.
| |
| evaluateInternal | back to summary |
|---|---|
| private static double evaluateInternal(double[] x, double[] y, double z) Evaluate the Lagrange polynomial using Neville's Algorithm. It takes O(n^2) time.
| |
| getCoefficients | back to summary |
|---|---|
| public double[] getCoefficients() Returns a copy of the coefficients array. Changes made to the returned copy will not affect the polynomial. Note that coefficients computation can be ill-conditioned. Use with caution and only when it is necessary.
| |
| getInterpolatingPoints | back to summary |
|---|---|
| public double[] getInterpolatingPoints() Returns a copy of the interpolating points array. Changes made to the returned copy will not affect the polynomial.
| |
| getInterpolatingValues | back to summary |
|---|---|
| public double[] getInterpolatingValues() Returns a copy of the interpolating values array. Changes made to the returned copy will not affect the polynomial.
| |
| value | back to summary |
|---|---|
| public double value(double z) Implements org. Calculate the function value at the given point.
| |
| verifyInterpolationArray | back to summary |
|---|---|
| public static boolean verifyInterpolationArray(double[] x, double[] y, boolean abort) throws DimensionMismatchException, NumberIsTooSmallException, NonMonotonicSequenceException Check that the interpolation arrays are valid. The arrays features checked by this method are that both arrays have the same length and this length is at least 2.
| |