panthrMath/utils.js
function inferEndpoint(f, y, lower, e) {
      var comp; // comparison of f(e) and f(2*e)

      if (e != null) { return e; }

      e = lower ? -1 : 1;
      comp = f(e) < f(2 * e);

      while (f(e) > y !== comp) {
         e *= 2;
         if (-e > 1e200) {
            throw new Error('Binary search: Cannot find ' + (lower ? 'lower' : 'upper') + ' endpoint.');
         }
      }
      return e;
   }
function inferEndpoint(f, y, lower, e) {
      var comp; // comparison of f(e) and f(2*e)

      if (e != null) { return e; }

      e = lower ? -1 : 1;
      comp = f(e) < f(2 * e);

      while (f(e) > y !== comp) {
         e *= 2;
         if (-e > 1e200) {
            throw new Error('Binary search: Cannot find ' + (lower ? 'lower' : 'upper') + ' endpoint.');
         }
      }
      return e;
   }
function inferEndpoint ( f , y , lower , e ) { var comp ; // comparison of f(e) and f(2*e) if ( e != null ) { return e ; } e = lower ? - 1 : 1 ; comp = f ( e ) < f ( 2 * e ) ; while ( f ( e ) > y !== comp ) { e *= 2 ; if ( - e > 1e200 ) { throw new Error ( 'Binary search: Cannot find ' + ( lower ? 'lower' : 'upper' ) + ' endpoint.' ) ; } } return e ; }
lower = true means looking for lower endpoint = false means looking for upper endpoint if "e" is provided it is just returned
lower = true means looking for lower endpoint = false means looking for upper endpoint if e is provided it is just returned