code: private static int interpolate(
          double y_minus, // = f(-1)
          double y_0, // = f(0)
          double y_plus, // = f(+1)
          double[] result // xe, ye, root1, root2
      ) {
  
          double a = 0.5 * (y_plus + y_minus) - y_0;
          double b = 0.5 * (y_plus - y_minus);
  
          double xe = -b / (2.0 * a);
          double ye = (a * xe + b) * xe + y_0;
          double dis = b * b - 4 * a * y_0;
  
          double root1 = Double.NaN;
          double root2 = Double.NaN;
          int count = 0;
  
          if (dis >= 0) {
              double dx = 0.5 * Math.sqrt(dis) / Math.abs(a);
              if (Math.abs(xe - dx) <= 1.0) {
                  root1 = xe - dx;
                  count++;
              }
              if (Math.abs(xe + dx) <= 1.0) {
                  root2 = xe + dx;
                  count++;
              }
          }
  
          result[0] = xe;
          result[1] = ye;
          result[2] = root1;
          result[3] = root2;
  
          return count;
  
      }
docs: quadratic interpolation