def Sk(X, Y, k):
    """
    Create Sk function

    Parameters
    ----------
        X : list
            list of x values
        Y : list
            list of y values
        k : int
            index from X and Y
    
    Returns
    -------
        function
            Sk from linear spline
    """

    def f(x):
        if(X[k + 1] != X[k]):
            return Y[k] * ((X[k + 1] - x)/(X[k + 1] - X[k])) + Y[k + 1] * ((x - X[k])/(X[k + 1] - X[k]))
    
    return f