Top Description Inners Fields Constructors Methods
org.apache.commons.math3.analysis.polynomials

public Class PolynomialsUtils

extends Object
Class Inheritance
Imports
java.util.ArrayList, .HashMap, .List, .Map, org.apache.commons.math3.fraction.BigFraction, org.apache.commons.math3.util.CombinatoricsUtils, .FastMath

A collection of static methods that operate on or return polynomials.
Since
2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
PolynomialsUtils.JacobiKey

Inner class for Jacobi polynomials keys.

private static interface
PolynomialsUtils.RecurrenceCoefficientsGenerator

Interface for recurrence coefficients generation.

Field Summary

Modifier and TypeField and Description
private static final List<BigFraction>
CHEBYSHEV_COEFFICIENTS

Coefficients for Chebyshev polynomials.

private static final List<BigFraction>
HERMITE_COEFFICIENTS

Coefficients for Hermite polynomials.

private static final Map<PolynomialsUtils.JacobiKey, List<BigFraction>>
JACOBI_COEFFICIENTS

Coefficients for Jacobi polynomials.

private static final List<BigFraction>
LAGUERRE_COEFFICIENTS

Coefficients for Laguerre polynomials.

private static final List<BigFraction>
LEGENDRE_COEFFICIENTS

Coefficients for Legendre polynomials.

Constructor Summary

AccessConstructor and Description
private
PolynomialsUtils()

Private constructor, to prevent instantiation.

Method Summary

Modifier and TypeMethod and Description
private static PolynomialFunction

Returns:

coefficients array
buildPolynomial
(final int
degree of the polynomial
degree
,
final List<BigFraction>
list where the computed coefficients are stored
coefficients
,
final PolynomialsUtils.RecurrenceCoefficientsGenerator
recurrence coefficients generator
generator
)
Deprecated as a consequence of PolynomialFunction being deprecated.

Get the coefficients array for a given degree.

private static void
computeUpToDegree(final int
maximal degree
degree
,
final int
current maximal degree
maxDegree
,
final PolynomialsUtils.RecurrenceCoefficientsGenerator
recurrence coefficients generator
generator
,
final List<BigFraction>
list where the computed coefficients should be appended
coefficients
)

Compute polynomial coefficients up to a given degree.

public static PolynomialFunction

Returns:

Chebyshev polynomial of specified degree
createChebyshevPolynomial
(final int
degree of the polynomial
degree
)
Deprecated as a consequence of PolynomialFunction being deprecated.

Create a Chebyshev polynomial of the first kind.

public static PolynomialFunction

Returns:

Hermite polynomial of specified degree
createHermitePolynomial
(final int
degree of the polynomial
degree
)
Deprecated as a consequence of PolynomialFunction being deprecated.

Create a Hermite polynomial.

public static PolynomialFunction

Returns:

Jacobi polynomial of specified degree
createJacobiPolynomial
(final int
degree of the polynomial
degree
,
final int
first exponent
v
,
final int
second exponent
w
)
Deprecated as a consequence of PolynomialFunction being deprecated.

Create a Jacobi polynomial.

public static PolynomialFunction

Returns:

Laguerre polynomial of specified degree
createLaguerrePolynomial
(final int
degree of the polynomial
degree
)
Deprecated as a consequence of PolynomialFunction being deprecated.

Create a Laguerre polynomial.

public static PolynomialFunction

Returns:

Legendre polynomial of specified degree
createLegendrePolynomial
(final int
degree of the polynomial
degree
)
Deprecated as a consequence of PolynomialFunction being deprecated.

Create a Legendre polynomial.

public static double[]

Returns:

the coefficients \(b_i\) of the shifted polynomial.
shift
(final double[]
Coefficients of the original polynomial.
coefficients
,
final double
Shift value.
shift
)

Compute the coefficients of the polynomial \(P_s(x)\) whose values at point x will be the same as the those from the original polynomial \(P(x)\) when computed at x + shift.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CHEBYSHEV_COEFFICIENTSback to summary
private static final List<BigFraction> CHEBYSHEV_COEFFICIENTS

Coefficients for Chebyshev polynomials.

HERMITE_COEFFICIENTSback to summary
private static final List<BigFraction> HERMITE_COEFFICIENTS

Coefficients for Hermite polynomials.

JACOBI_COEFFICIENTSback to summary
private static final Map<PolynomialsUtils.JacobiKey, List<BigFraction>> JACOBI_COEFFICIENTS

Coefficients for Jacobi polynomials.

LAGUERRE_COEFFICIENTSback to summary
private static final List<BigFraction> LAGUERRE_COEFFICIENTS

Coefficients for Laguerre polynomials.

LEGENDRE_COEFFICIENTSback to summary
private static final List<BigFraction> LEGENDRE_COEFFICIENTS

Coefficients for Legendre polynomials.

Constructor Detail

PolynomialsUtilsback to summary
private PolynomialsUtils()

Private constructor, to prevent instantiation.

Method Detail

buildPolynomialback to summary
private static PolynomialFunction buildPolynomial(final int degree, final List<BigFraction> coefficients, final PolynomialsUtils.RecurrenceCoefficientsGenerator generator)

Deprecated

as a consequence of PolynomialFunction being deprecated. See corresponding docs for further information.

Get the coefficients array for a given degree.

Parameters
degree:int

degree of the polynomial

coefficients:List<BigFraction>

list where the computed coefficients are stored

generator:PolynomialsUtils.RecurrenceCoefficientsGenerator

recurrence coefficients generator

Returns:PolynomialFunction

coefficients array

computeUpToDegreeback to summary
private static void computeUpToDegree(final int degree, final int maxDegree, final PolynomialsUtils.RecurrenceCoefficientsGenerator generator, final List<BigFraction> coefficients)

Compute polynomial coefficients up to a given degree.

Parameters
degree:int

maximal degree

maxDegree:int

current maximal degree

generator:PolynomialsUtils.RecurrenceCoefficientsGenerator

recurrence coefficients generator

coefficients:List<BigFraction>

list where the computed coefficients should be appended

createChebyshevPolynomialback to summary
public static PolynomialFunction createChebyshevPolynomial(final int degree)

Deprecated

as a consequence of PolynomialFunction being deprecated. See corresponding docs for further information.

Create a Chebyshev polynomial of the first kind.

Chebyshev polynomials of the first kind are orthogonal polynomials. They can be defined by the following recurrence relations:

\( T_0(x) = 1 \\ T_1(x) = x \\ T_{k+1}(x) = 2x T_k(x) - T_{k-1}(x) \)

Parameters
degree:int

degree of the polynomial

Returns:PolynomialFunction

Chebyshev polynomial of specified degree

createHermitePolynomialback to summary
public static PolynomialFunction createHermitePolynomial(final int degree)

Deprecated

as a consequence of PolynomialFunction being deprecated. See corresponding docs for further information.

Create a Hermite polynomial.

Hermite polynomials are orthogonal polynomials. They can be defined by the following recurrence relations:

\( H_0(x) = 1 \\ H_1(x) = 2x \\ H_{k+1}(x) = 2x H_k(X) - 2k H_{k-1}(x) \)

Parameters
degree:int

degree of the polynomial

Returns:PolynomialFunction

Hermite polynomial of specified degree

createJacobiPolynomialback to summary
public static PolynomialFunction createJacobiPolynomial(final int degree, final int v, final int w)

Deprecated

as a consequence of PolynomialFunction being deprecated. See corresponding docs for further information.

Create a Jacobi polynomial.

Jacobi polynomials are orthogonal polynomials. They can be defined by the following recurrence relations:

\( P_0^{vw}(x) = 1 \\ P_{-1}^{vw}(x) = 0 \\ 2k(k + v + w)(2k + v + w - 2) P_k^{vw}(x) = \\ (2k + v + w - 1)[(2k + v + w)(2k + v + w - 2) x + v^2 - w^2] P_{k-1}^{vw}(x) \\ - 2(k + v - 1)(k + w - 1)(2k + v + w) P_{k-2}^{vw}(x) \)

Parameters
degree:int

degree of the polynomial

v:int

first exponent

w:int

second exponent

Returns:PolynomialFunction

Jacobi polynomial of specified degree

createLaguerrePolynomialback to summary
public static PolynomialFunction createLaguerrePolynomial(final int degree)

Deprecated

as a consequence of PolynomialFunction being deprecated. See corresponding docs for further information.

Create a Laguerre polynomial.

Laguerre polynomials are orthogonal polynomials. They can be defined by the following recurrence relations:

\( L_0(x) = 1 \\ L_1(x) = 1 - x \\ (k+1) L_{k+1}(x) = (2k + 1 - x) L_k(x) - k L_{k-1}(x) \)

Parameters
degree:int

degree of the polynomial

Returns:PolynomialFunction

Laguerre polynomial of specified degree

createLegendrePolynomialback to summary
public static PolynomialFunction createLegendrePolynomial(final int degree)

Deprecated

as a consequence of PolynomialFunction being deprecated. See corresponding docs for further information.

Create a Legendre polynomial.

Legendre polynomials are orthogonal polynomials. They can be defined by the following recurrence relations:

\( P_0(x) = 1 \\ P_1(x) = x \\ (k+1) P_{k+1}(x) = (2k+1) x P_k(x) - k P_{k-1}(x) \)

Parameters
degree:int

degree of the polynomial

Returns:PolynomialFunction

Legendre polynomial of specified degree

shiftback to summary
public static double[] shift(final double[] coefficients, final double shift)

Compute the coefficients of the polynomial \(P_s(x)\) whose values at point x will be the same as the those from the original polynomial \(P(x)\) when computed at x + shift.

More precisely, let \(\Delta = \) shift and let \(P_s(x) = P(x + \Delta)\). The returned array consists of the coefficients of \(P_s\). So if \(a_0, ..., a_{n-1}\) are the coefficients of \(P\), then the returned array \(b_0, ..., b_{n-1}\) satisfies the identity \(\sum_{i=0}^{n-1} b_i x^i = \sum_{i=0}^{n-1} a_i (x + \Delta)^i\) for all \(x\).

Parameters
coefficients:double[]

Coefficients of the original polynomial.

shift:double

Shift value.

Returns:double[]

the coefficients \(b_i\) of the shifted polynomial.

org.apache.commons.math3.analysis.polynomials back to summary

private Class PolynomialsUtils.JacobiKey

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.analysis.polynomials.PolynomialsUtils.JacobiKey

Inner class for Jacobi polynomials keys.

Field Summary

Modifier and TypeField and Description
private final int
v

First exponent.

private final int
w

Second exponent.

Constructor Summary

AccessConstructor and Description
pack-priv
JacobiKey(final int
first exponent
v
,
final int
second exponent
w
)

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the instance and the other key refer to the same polynomial
equals
(final Object
other key
key
)

Overrides java.lang.Object.equals.

Check if the instance represent the same key as another instance.

public int

Returns:

hash code
hashCode
()

Overrides java.lang.Object.hashCode.

Get hash code.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

vback to summary
private final int v

First exponent.

wback to summary
private final int w

Second exponent.

Constructor Detail

JacobiKeyback to summary
pack-priv JacobiKey(final int v, final int w)

Simple constructor.

Parameters
v:int

first exponent

w:int

second exponent

Method Detail

equalsback to summary
public boolean equals(final Object key)

Overrides java.lang.Object.equals.

Check if the instance represent the same key as another instance.

Parameters
key:Object

other key

Returns:boolean

true if the instance and the other key refer to the same polynomial

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Get hash code.

Returns:int

hash code

Annotations
@Override
org.apache.commons.math3.analysis.polynomials back to summary

private Interface PolynomialsUtils.RecurrenceCoefficientsGenerator


Interface for recurrence coefficients generation.

Method Summary

Modifier and TypeMethod and Description
public BigFraction[]

Returns:

an array of three coefficients such that \( P_{k+1}(x) = (a[0] + a[1] x) P_k(x) - a[2] P_{k-1}(x) \)
generate
(int
highest degree of the polynomials used in the recurrence
k
)

Generate recurrence coefficients.

Method Detail

generateback to summary
public BigFraction[] generate(int k)

Generate recurrence coefficients.

Parameters
k:int

highest degree of the polynomials used in the recurrence

Returns:BigFraction[]

an array of three coefficients such that \( P_{k+1}(x) = (a[0] + a[1] x) P_k(x) - a[2] P_{k-1}(x) \)