Package com.polytechnik.utils
Class HermiteE
java.lang.Object
com.polytechnik.utils.HermiteE
- All Implemented Interfaces:
BasisFunctionsCalculatable
,BasisFunctionsMultipliable
,BasisPolynomials
,ConfederateMatrixCalculatable
,SimpleBasisPolynomials
Hermite(E) polynomials basis,
using \( H_k=x*H_{k-1}-(k-1)H_{k-2} \).
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
calculate
(int n, double x) Calculation of the value of n-Hermite polynomial at given x.double[]
getaxbP
(double[] p, double ma, double mb) Multiply p by ma*x+mb.double[][]
getBasisFunctionsOnPolynomialArgument
(int numQl, double[] pol, BasisFunctionsCalculatable PBASIS) This method calculates \( Q_l(pol(x))\), where pol(x) is a given polynomial and \( Q_l \) is basis finction of this (notPBASIS
!) basis.double[]
getConfederateMatrix
(double[] coefs) Calculates confederate matrix to solve polynomial equations in Hermite basis directly.double
getD0
(double[] Hcoefs, double x) Calculates \( sum_k H_k(x) Hcoefs[k] \).double
getD1
(double[] Hcoefs, double x) Calculates \( d/dx \sum_k H_k(x) Hcoefs[k] \).double
getD2
(double[] Hcoefs, double x) Calculates \( d^2/dx^2 \sum_k H_k(x) Hcoefs[k] \).double[]
getDifferentiated
(double[] Hcoefs) Differentiate a function in Hermite basis, F(x) - a polynomial of n-th order.double[]
getIntegrated
(double[] Hcoefs) Integrate in Hermite basis, See Gradstein Ryzik, 1963, formulae 8.952, page 1047.double[]
getMomentsFromSample
(int nmoments, double[] x, double[] w, int nelsinsample) Given observations x and weights w calculate the 0..nmoms-1 moments in the basis.double[]
getNext
(int n, double[] Hnm1, double[] Hnm2, boolean flag_type2, BasisFunctionsCalculatable PBASIS) Calculates n-th HermiteE polynomial using \( H_n=x*H_{n-1}-(n-1)H_{n-2} \).double[]
getXQkMomentsFromQkMoments
(double[] moments) Calculate <F|xHk> moments for k=0..n-1 from <F|Hk>, k=0..nstatic void
A unit test.sdiv1
(double[] p, double x0) Divide p by (x-x0), returns quotient and remainder.void
setNewtonBinomialLikeCoefs
(int n, double[] b, double[] q, double a, double x0) Calculates H_n(a(x+x0)) using 3 term recurrence.void
setQlQmExpansionCoefs
(int l, int m, double[] s) Expand \( H_l(z)H_m(z)=\sum_{k=0}^{l+m} s_k H_k(z) \), formulae from L.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.polytechnik.utils.BasisFunctionsCalculatable
convertFunctionTo_Basis_from_Monomials, convertFunctionTo_Basis_from_PBASIS, convertFunctionTo_Monomials_from_Basis, getMomentsFromSample, getMomentsFromSample, getONE, getX0Moments
Methods inherited from interface com.polytechnik.utils.BasisFunctionsMultipliable
getBasisFunctionsMultipliedByPolynomial, getKK, getMomentsOfMeasureProducingPolynomialInKK, getMomentsOfMeasureProducingPolynomialInKK_MQQM, getPQkMomentsFromQkMoments, getQQMatr, getTwoQuadraticFormsProductAsQuadraticForm, mult2Pol, sdiv
Methods inherited from interface com.polytechnik.utils.BasisPolynomials
getNext
Methods inherited from interface com.polytechnik.utils.SimpleBasisPolynomials
convertBasisToPBASIS, convertFunctionTo_PBASIS_from_Basis, getBasisFunctionsMultipliedByPolynomial, getBasisFunctionsOnPolynomialArgument
-
Constructor Details
-
HermiteE
public HermiteE()
-
-
Method Details
-
getNext
public double[] getNext(int n, double[] Hnm1, double[] Hnm2, boolean flag_type2, BasisFunctionsCalculatable PBASIS) Calculates n-th HermiteE polynomial using \( H_n=x*H_{n-1}-(n-1)H_{n-2} \).- Specified by:
getNext
in interfaceBasisPolynomials
- Parameters:
n
- H index.Hnm1
- Input \( H_{n-1} \).Hnm2
- Input \( H_{n-2} \).flag_type2
- Whether to use type 2 polynomials.PBASIS
- The basis in which to calculte.- Returns:
- \( H_{n} \) polynomial, array dimension n+1.
-
getBasisFunctionsOnPolynomialArgument
public double[][] getBasisFunctionsOnPolynomialArgument(int numQl, double[] pol, BasisFunctionsCalculatable PBASIS) Description copied from interface:SimpleBasisPolynomials
This method calculates \( Q_l(pol(x))\), where pol(x) is a given polynomial and \( Q_l \) is basis finction of this (notPBASIS
!) basis. This method may not be stable for a large dimensions ofpol.length
. Equivalent to numQl applications ofSimpleBasisPolynomials.getNext(int, double[], double[], com.polytechnik.utils.BasisFunctionsCalculatable)
topol
array. The method can be used to calculate e.g. \( T_n(P_k(x)) \) or \( T_n(P_k(L_m(x^j))) \). For example
meansnew Legendre().getBasisFunctionsOnPolynomialArgument(4,new double []{0,0,0,0,1},new Chebyshev()) ={ { 1.0 }, { 0.0, 0.0, 0.0, 0.0, 1.0 }, { 0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75 }, { 0.0, 0.0, 0.0, 0.0, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.625 } }
\( P_0(T_4(x))=T_0 \)
\( P_1(T_4(x))=T_4(x) \)
\( P_2(T_4(x))=0.25*T_0+0.75*T_8(x) \)
\( P_3(T_4(x))=0.375*T_4(x)+0.625*T_{12}(x) \).- Specified by:
getBasisFunctionsOnPolynomialArgument
in interfaceSimpleBasisPolynomials
- Parameters:
numQl
- The number of basis functions to calculate.pol
- The polynomial to use in \( Q_l(pol(x))\), it is given in thePBASIS
basis.PBASIS
- the basis in whichpol
is given and the result is returned.- Returns:
- An array of numQl dimension, elements: \( Q_0(pol(x)) \),
\( Q_1(pol(x)) \), ... \( Q_{numQl-1}(pol(x)) \) in the basis
PBASIS
.
-
calculate
public double calculate(int n, double x) Calculation of the value of n-Hermite polynomial at given x.- Specified by:
calculate
in interfaceBasisFunctionsCalculatable
- Parameters:
n
- H index.x
- Argument.- Returns:
- The value of the Hermite polynomial Hn at x.
-
getMomentsFromSample
public double[] getMomentsFromSample(int nmoments, double[] x, double[] w, int nelsinsample) Description copied from interface:BasisFunctionsCalculatable
Given observations x and weights w calculate the 0..nmoms-1 moments in the basis.- Specified by:
getMomentsFromSample
in interfaceBasisFunctionsCalculatable
- Parameters:
nmoments
- The number of moments to calculate.x
- observation samples.w
- weights.nelsinsample
- How many elements to sample.- Returns:
- nelsinsample generalzied moments, \( k=0\dots nmoms-1 \): \( \sum_{j=0}^{nelsinsample-1} Q_k(x[j])*w[j] \).
-
getD0
public double getD0(double[] Hcoefs, double x) Calculates \( sum_k H_k(x) Hcoefs[k] \). This version is copied from http://www.alglib.net/.- Specified by:
getD0
in interfaceBasisFunctionsCalculatable
- Parameters:
Hcoefs
- Coefficients.x
- Point to estimate the sum.- Returns:
- The sum.
-
getD1
public double getD1(double[] Hcoefs, double x) Calculates \( d/dx \sum_k H_k(x) Hcoefs[k] \).- Specified by:
getD1
in interfaceBasisFunctionsCalculatable
- Parameters:
Hcoefs
- Coefficients.x
- Pont to estimate the sum.- Returns:
- The derivative.
-
getD2
public double getD2(double[] Hcoefs, double x) Calculates \( d^2/dx^2 \sum_k H_k(x) Hcoefs[k] \).- Specified by:
getD2
in interfaceBasisFunctionsCalculatable
- Parameters:
Hcoefs
- Coefficients.x
- Pont to estimate the sum.- Returns:
- The second derivative.
-
getDifferentiated
public double[] getDifferentiated(double[] Hcoefs) Differentiate a function in Hermite basis, F(x) - a polynomial of n-th order. See Gradstein Ryzik, 1963, formulae 8.952, page 1047.- Specified by:
getDifferentiated
in interfaceBasisFunctionsCalculatable
- Parameters:
Hcoefs
- Input \( F(x)=\sum_k H_k(x)*Hcoefs[k] \).- Returns:
- \( dF/dx=\sum_k H'_k(x)*Hcoefs[k] \).
-
getIntegrated
public double[] getIntegrated(double[] Hcoefs) Integrate in Hermite basis, See Gradstein Ryzik, 1963, formulae 8.952, page 1047.- Specified by:
getIntegrated
in interfaceBasisFunctionsCalculatable
- Parameters:
Hcoefs
- : \( F(x)=\sum_k Q_k(x) Qcoefs[k] \).- Returns:
- \( \int F(x)dx=\sum_k Qcoefs[k] \int Q_k(x) dx \). The integral is typically normalized as I(0)=0.
-
setQlQmExpansionCoefs
public void setQlQmExpansionCoefs(int l, int m, double[] s) Expand \( H_l(z)H_m(z)=\sum_{k=0}^{l+m} s_k H_k(z) \), formulae from L. Carlitz. Monatshefte fur Mathematik. Volume 66 issue 5 1962. The product of several Hermite or Laguerre polynomials. And see the refences to original work by N. Nielsen therein. This formulae is also available from Prudnikov, Brychkov, Marichev, volume 2, 2003, formulae 4.5.1.11 page 569.- Specified by:
setQlQmExpansionCoefs
in interfaceBasisFunctionsMultipliable
- Parameters:
l
- l.m
- m.s
- coefs.
-
getaxbP
public double[] getaxbP(double[] p, double ma, double mb) Multiply p by ma*x+mb. Calculations in Hermite basis. Do not mistake with a and b recurrence coefficiemts ofgetAB()
.- Specified by:
getaxbP
in interfaceBasisFunctionsCalculatable
- Parameters:
p
- Input polynomial.- Returns:
- p*(ma*x+mb), an array of the length 1+p.length.
-
sdiv1
Divide p by (x-x0), returns quotient and remainder. Calculations in Hermite basis.- Specified by:
sdiv1
in interfaceBasisFunctionsCalculatable
- Parameters:
p
- Input polynomial.x0
- To divide on (x-x0)- Returns:
- Quotient and remainder.
-
setNewtonBinomialLikeCoefs
public void setNewtonBinomialLikeCoefs(int n, double[] b, double[] q, double a, double x0) Calculates H_n(a(x+x0)) using 3 term recurrence. Calculations in Hermite basis. The \( b_k^{n} \) are defined as: \( H_n(a(x+x0))=\sum_{k=0}^{k=n}b_k^{n} H_k(x) \) The method should be applied consequently to get \( b_k^{n} \) for n=0,1,2,3,...- Specified by:
setNewtonBinomialLikeCoefs
in interfaceBasisPolynomials
- Parameters:
n
- The max dimension of b.b
- On input: \( b_k^{n-1} \), on output \( b_k^{n} \).q
- On input: \( b_k^{n-2} \), on output: \( b_k^{n-1} \).
-
getXQkMomentsFromQkMoments
public double[] getXQkMomentsFromQkMoments(double[] moments) Calculate <F|xHk> moments for k=0..n-1 from <F|Hk>, k=0..n- Specified by:
getXQkMomentsFromQkMoments
in interfaceBasisFunctionsCalculatable
- Parameters:
moments
- <F|Hk>.- Returns:
- <F|xHk>.
-
getConfederateMatrix
public double[] getConfederateMatrix(double[] coefs) Calculates confederate matrix to solve polynomial equations in Hermite basis directly. We use the three term recurrence: \[ H_k=x*H_{k-1}-(k-1)H_{k-2} \] UseABASISHERMITEE
to calculate roots.- Specified by:
getConfederateMatrix
in interfaceConfederateMatrixCalculatable
-
main
A unit test.
-