def derivative(pts, x):
    """
    Slope of line between two points. (δy/δx).
    pts should be of the form ((x1,y1), (x2,y2), ..) of increasing x.
    """

    lastPt = pts[0]
    for pt in pts[1:]:
        t, v = pt
        if t >= x:
            lt, lv = lastPt
            return (v - lv)/(t - lt)
        lastPt = pt