code: def _limits_helper(x1, x2, a, b, snap=False):
      
      if x2 < x1:
          raise ValueError("x2 < x1")
      if a + b >= 1:
          raise ValueError("a + b >= 1")
      if a < 0:
          raise ValueError("a < 0")
      if b < 0:
          raise ValueError("b < 0")
      if snap:
          if x1 >= 0:
              x1 = 0
              a = 0
          elif x2 <= 0:
              x2 = 0
              b = 0
          if x1 == x2 == 0:
              # garbage in garbage out
              return 0., 1.
      elif x1 == x2:
          # garbage in garbage out
          return x1 - 1., x1 + 1.
      if a == 0 and b == 0:
          return x1, x2
      elif a == 0:
          return x1, (x2 - b * x1) / (1 - b)
      elif b == 0:
          return (x1 - a * x2) / (1 - a), x2
      x0 = ((b / a) * x1 + x2 - (x2 - x1) / (1 - a - b)) / (1 + b / a)
      x3 = (x2 - x1) / (1 - a - b) + x0
      return x0, x3
docs: Given x1, x2, a, b, where:
  
          x1 - x0         x3 - x2
      a = ------- ,   b = -------
          x3 - x0         x3 - x0
  
      determine the points x0 and x3:
  
      x0         x1                x2       x3
      |----------|-----------------|--------|