code: public static double getGradDotDirApprox(Function fn, IntDoubleVector x, IntDoubleVector d, double c) {
          double dot = 0;
          {
              // L(\theta + c * d)
              IntDoubleVector d1 = d.copy();
              d1.scale(c);
              IntDoubleVector x1 = x.copy();
              x1.add(d1);
              dot += fn.getValue(x1);
          }
          {
              // - L(\theta - c * d)
              IntDoubleVector d1 = d.copy();
              d1.scale(-c);
              IntDoubleVector x1 = x.copy();
              x1.add(d1);        
              dot -= fn.getValue(x1);
          }
          dot /= (2.0 * c);
          return dot;
      }
docs: Compute f'(x)^T d = ( L(x + c * d) - L(x - c * d) ) / (2c)
  
  @param fn Function, f.
  @param x Point at which to evaluate the gradient, x.
  @param d Random direction, d.
  @param c Epsilon constant.
  @return