### Question:
OrthonormalHermitePolynomialFunction extends OrthogonalPolynomialFunctionGenerator { @Override public DoubleFunction1D[] getPolynomials(int n) { ArgChecker.isTrue(n >= 0); DoubleFunction1D[] polynomials = new DoubleFunction1D[n + 1]; for (int i = 0; i <= n; i++) { if (i == 0) { polynomials[i] = F0; } else if (i == 1) { polynomials[i] = polynomials[0].multiply(Math.sqrt(2)).multiply(getX()); } else { polynomials[i] = polynomials[i - 1].multiply(getX()).multiply(Math.sqrt(2. / i)) .subtract(polynomials[i - 2].multiply(Math.sqrt((i - 1.) / i))); } } return polynomials; }  @Override DoubleFunction1D[] getPolynomials(int n); @Override Pair<DoubleFunction1D, DoubleFunction1D>[] getPolynomialsAndFirstDerivative(int n);  }### Answer:
@Test public void testBadN() { assertThatIllegalArgumentException() .isThrownBy(() -> ORTHONORMAL.getPolynomials(-3)); }
@Test public void test() { final int n = 15; final DoubleFunction1D[] f1 = HERMITE.getPolynomials(n); final DoubleFunction1D[] f2 = ORTHONORMAL.getPolynomials(n); final double x = 3.4; for (int i = 0; i < f1.length; i++) { assertThat(f1[i].applyAsDouble(x) / Math.sqrt(CombinatoricsUtils.factorialDouble(i) * Math.pow(2, i) * Math.sqrt(Math.PI))) .isCloseTo(f2[i].applyAsDouble(x), offset(EPS)); } }