### Question:
VectorFieldSecondOrderDifferentiator implements Differentiator<DoubleArray, DoubleArray, DoubleMatrix[]> { public Function<DoubleArray, DoubleMatrix> differentiateNoCross(Function<DoubleArray, DoubleArray> function) { return new Function<DoubleArray, DoubleMatrix>() { @SuppressWarnings("synthetic-access") @Override public DoubleMatrix apply(DoubleArray x) { ArgChecker.notNull(x, "x"); DoubleArray y = function.apply(x); int n = x.size(); int m = y.size(); double[][] res = new double[m][n]; for (int j = 0; j < n; j++) { double xj = x.get(j); DoubleArray up = function.apply(x.with(j, xj + eps)); DoubleArray down = function.apply(x.with(j, xj - eps)); for (int i = 0; i < m; i++) { res[i][j] = (up.get(i) + down.get(i) - 2d * y.get(i)) / epsSqr; } } return DoubleMatrix.copyOf(res); } }; } VectorFieldSecondOrderDifferentiator(); @Override Function<DoubleArray, DoubleMatrix[]> differentiate(
      Function<DoubleArray, DoubleArray> function); @Override Function<DoubleArray, DoubleMatrix[]> differentiate(
      Function<DoubleArray, DoubleArray> function,
      Function<DoubleArray, Boolean> domain); Function<DoubleArray, DoubleMatrix[]> differentiateFull(
      Function<DoubleArray, DoubleArray> function); Function<DoubleArray, DoubleMatrix> differentiateNoCross(Function<DoubleArray, DoubleArray> function);  }### Answer:
@Test public void tes_differentiateNoCrosst() { Function<DoubleArray, DoubleArray> func = new Function<DoubleArray, DoubleArray>() { @Override public DoubleArray apply(DoubleArray x) { double x1 = x.get(0); double x2 = x.get(1); return DoubleArray.of(x1 * x1 * x1 + x2 * x2, Math.exp(1.5 * x1), Math.log(2d * x1) * Math.sin(x2)); } }; double[][] keys = new double[][] {{1.5, -2.1}, {2.3445, 0.5}}; Function<DoubleArray, DoubleMatrix> funcExp = new Function<DoubleArray, DoubleMatrix>() { @Override public DoubleMatrix apply(DoubleArray x) { double x1 = x.get(0); double x2 = x.get(1); double[][] mat = new double[][] { {6d * x1, 2.25 * Math.exp(1.5 * x1), -Math.sin(x2) / x1 / x1}, {2d, 0d, -Math.log(2d * x1) * Math.sin(x2)}}; return DoubleMatrix.ofUnsafe(mat); } }; VectorFieldSecondOrderDifferentiator fd = new VectorFieldSecondOrderDifferentiator(); Function<DoubleArray, DoubleMatrix> fdFuncs = fd.differentiateNoCross(func); for (double[] key : keys) { DoubleMatrix cmp = fdFuncs.apply(DoubleArray.ofUnsafe(key)); DoubleMatrix exp = funcExp.apply(DoubleArray.ofUnsafe(key)); assertThat(DoubleArrayMath.fuzzyEquals(cmp.column(0).toArray(), exp.row(0).toArray(), 1.0e-5)).isTrue(); assertThat(DoubleArrayMath.fuzzyEquals(cmp.column(1).toArray(), exp.row(1).toArray(), 1.0e-5)).isTrue(); } }