code: def lookup_extrapolation(x, xs, ys):
      
      length = len(xs)
      if x < xs[0]:
          dx = xs[1] - xs[0]
          dy = ys[1] - ys[0]
          k = dy / dx
          return ys[0] + (x - xs[0]) * k
      if x > xs[length - 1]:
          dx = xs[length - 1] - xs[length - 2]
          dy = ys[length - 1] - ys[length - 2]
          k = dy / dx
          return ys[length - 1] + (x - xs[length - 1]) * k
      return np.interp(x, xs, ys)
docs: Intermediate values are calculated with linear interpolation between the intermediate points.
      Out-of-range values are calculated with linear extrapolation from the last two values at either end.