### Question:
HermitePolynomialFunction 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] = getOne(); } else if (i == 1) { polynomials[i] = TWO_X; } else { polynomials[i] = polynomials[i - 1] .multiply(2) .multiply(getX()) .subtract(polynomials[i - 2].multiply(2 * i - 2)); } } return polynomials; }  @Override DoubleFunction1D[] getPolynomials(int n); @Override Pair<DoubleFunction1D, DoubleFunction1D>[] getPolynomialsAndFirstDerivative(int n);  }### Answer:
@Test public void testBadN() { assertThatIllegalArgumentException() .isThrownBy(() -> HERMITE.getPolynomials(-3)); }
@Test public void testGetPolynomials() { assertThatExceptionOfType(UnsupportedOperationException.class) .isThrownBy(() -> HERMITE.getPolynomialsAndFirstDerivative(3)); }
@Test public void test() { DoubleFunction1D[] h = HERMITE.getPolynomials(0); assertThat(h.length).isEqualTo(1); final double x = 1.23; assertThat(h[0].applyAsDouble(x)).isCloseTo(1, offset(EPS)); h = HERMITE.getPolynomials(1); assertThat(h.length).isEqualTo(2); assertThat(h[1].applyAsDouble(x)).isCloseTo(2 * x, offset(EPS)); for (int i = 0; i <= 10; i++) { h = HERMITE.getPolynomials(i); for (int j = 0; j <= i; j++) { assertThat(H[j].applyAsDouble(x)).isCloseTo(h[j].applyAsDouble(x), offset(EPS)); } } }