### Question:
GaussLegendreWeightAndAbscissaFunction implements QuadratureWeightAndAbscissaFunction { @Override public GaussianQuadratureData generate(int n) { ArgChecker.isTrue(n > 0); int mid = (n + 1) / 2; double[] x = new double[n]; double[] w = new double[n]; Pair<DoubleFunction1D, DoubleFunction1D>[] polynomials = LEGENDRE.getPolynomialsAndFirstDerivative(n); Pair<DoubleFunction1D, DoubleFunction1D> pair = polynomials[n]; DoubleFunction1D function = pair.getFirst(); DoubleFunction1D derivative = pair.getSecond(); for (int i = 0; i < mid; i++) { double root = ROOT_FINDER.getRoot(function, derivative, getInitialRootGuess(i, n)); x[i] = -root; x[n - i - 1] = root; double dp = derivative.applyAsDouble(root); w[i] = 2 / ((1 - root * root) * dp * dp); w[n - i - 1] = w[i]; } return new GaussianQuadratureData(x, w); }  @Override GaussianQuadratureData generate(int n);  }### Answer:
@Test public void test() { assertResults(F.generate(2), X2, W2); assertResults(F.generate(3), X3, W3); assertResults(F.generate(4), X4, W4); assertResults(F.generate(5), X5, W5); }