code: func bisect(f func(float64) float64, low, high, tolerance float64) (float64, bool) {
  	flow, fhigh := f(low), f(high)
  	if -tolerance <= flow && flow <= tolerance {
  		return low, true
  	}
  	if -tolerance <= fhigh && fhigh <= tolerance {
  		return high, true
  	}
  	if mathx.Sign(flow) == mathx.Sign(fhigh) {
  		panic(fmt.Sprintf("root of f is not bracketed by [low, high]; f(%g)=%g f(%g)=%g", low, flow, high, fhigh))
  	}
  	for {
  		mid := (high + low) / 2
  		fmid := f(mid)
  		if -tolerance <= fmid && fmid <= tolerance {
  			return mid, true
  		}
  		if mid == high || mid == low {
  			return mid, false
  		}
  		if mathx.Sign(fmid) == mathx.Sign(flow) {
  			low = mid
  			flow = fmid
  		} else {
  			high = mid
  			fhigh = fmid
  		}
  	}
  }
docs: // bisect returns an x in [low, high] such that |f(x)| <= tolerance
  // using the bisection method.
  //
  // f(low) and f(high) must have opposite signs.
  //
  // If f does not have a root in this interval (e.g., it is
  // discontiguous), this returns the X of the apparent discontinuity
  // and false.