code: function (f, a, b, fa, fc, fb, options) {
      var h = b - a, c = (a + b) / 2, fd = f((a + c) / 2), fe = f((c + b) / 2), Q1 = (h / 6) * (fa + 4 * fc + fb), Q2 = (h / 12) * (fa + 4 * fd + 2 * fc + 4 * fe + fb), Q = Q2 + (Q2 - Q1) / 15;
  
      options.calls = options.calls + 2;
  
      // Infinite or Not-a-Number function value encountered
      if (!isFinite(Q)) {
          options.warn = Math.max(options.warn, 3);
          return Q;
      }
  
      // Maximum function count exceeded; singularity likely
      if (options.calls > options.maxCalls) {
          options.warn = Math.max(options.warn, 2);
          return Q;
      }
  
      // Accuracy over this subinterval is acceptable
      if (Math.abs(Q2 - Q) <= options.tolerance) {
          return Q;
      }
  
      // Minimum step size reached; singularity possible
      if (Math.abs(h) < options.minStep || c === a || c === b) {
          options.warn = Math.max(options.warn, 1);
          return Q;
      }
  
      // Otherwise, divide the interval into two subintervals
      return quadstep(f, a, c, fa, fd, fc, options) + quadstep(f, c, b, fc, fe, fb, options);
  }
docs: Recursive function for the quad method