public static boolean check(DifferentiableFunction Func) {
int size = Func.dimension();
double p = size;
int attempts = 10;
while (attempts > 0) {
DoubleMatrix xMat = DoubleMatrix.rand(size);
// DoubleMatrix xMat = attempts != 10 ? DoubleMatrix.rand(size) : DoubleMatrix.ones(size).mul(0.1);
double[] x = xMat.data;
double ReturnedCost = Func.valueAt(x);
double[] ReturnedGradient = Func.derivativeAt(x);
double[] NumericalGradient = new double[size];
double PartCosts;
double Mean = 2e-6 * ((1 + xMat.norm2()) / p);
for (int i = 0; i < size; i++) {
double[] e = DoubleMatrix.zeros(size).data;
e[i] = 1;
DoubleArrays.scale(e, Mean);
double[] y = DoubleArrays.add(x, e);