PolynomialsUtils { public static PolynomialFunction createHermitePolynomial(final int degree) { return buildPolynomial(degree, HERMITE_COEFFICIENTS, new RecurrenceCoefficientsGenerator() { public BigFraction[] generate(int k) { return new BigFraction[] { BigFraction.ZERO, BigFraction.TWO, new BigFraction(2 * k)}; } }); } private  PolynomialsUtils(); static PolynomialFunction createChebyshevPolynomial(final int degree); static PolynomialFunction createHermitePolynomial(final int degree); static PolynomialFunction createLaguerrePolynomial(final int degree); static PolynomialFunction createLegendrePolynomial(final int degree); static PolynomialFunction createJacobiPolynomial(final int degree, final int v, final int w); static double[] shift(final double[] coefficients,
                                 final double shift);  }
@Test public void testFirstHermitePolynomials() { checkPolynomial(PolynomialsUtils.createHermitePolynomial(3), "-12 x + 8 x^3"); checkPolynomial(PolynomialsUtils.createHermitePolynomial(2), "-2 + 4 x^2"); checkPolynomial(PolynomialsUtils.createHermitePolynomial(1), "2 x"); checkPolynomial(PolynomialsUtils.createHermitePolynomial(0), "1"); checkPolynomial(PolynomialsUtils.createHermitePolynomial(7), "-1680 x + 3360 x^3 - 1344 x^5 + 128 x^7"); checkPolynomial(PolynomialsUtils.createHermitePolynomial(6), "-120 + 720 x^2 - 480 x^4 + 64 x^6"); checkPolynomial(PolynomialsUtils.createHermitePolynomial(5), "120 x - 160 x^3 + 32 x^5"); checkPolynomial(PolynomialsUtils.createHermitePolynomial(4), "12 - 48 x^2 + 16 x^4"); }
@Test public void testHermiteDifferentials() { for (int k = 0; k < 12; ++k) { PolynomialFunction Hk0 = PolynomialsUtils.createHermitePolynomial(k); PolynomialFunction Hk1 = Hk0.polynomialDerivative(); PolynomialFunction Hk2 = Hk1.polynomialDerivative(); PolynomialFunction g0 = new PolynomialFunction(new double[] { 2 * k }); PolynomialFunction g1 = new PolynomialFunction(new double[] { 0, -2 }); PolynomialFunction g2 = new PolynomialFunction(new double[] { 1 }); PolynomialFunction Hk0g0 = Hk0.multiply(g0); PolynomialFunction Hk1g1 = Hk1.multiply(g1); PolynomialFunction Hk2g2 = Hk2.multiply(g2); checkNullPolynomial(Hk0g0.add(Hk1g1.add(Hk2g2))); } }
@Test public void testHermiteOrthogonality() { UnivariateFunction weight = new UnivariateFunction() { public double value(double x) { return FastMath.exp(-x * x); } }; for (int i = 0; i < 10; ++i) { PolynomialFunction pi = PolynomialsUtils.createHermitePolynomial(i); for (int j = 0; j <= i; ++j) { PolynomialFunction pj = PolynomialsUtils.createHermitePolynomial(j); checkOrthogonality(pi, pj, weight, -50, 50, 1.5, 1.0e-8); } } }