def Ck(Y2d, H, Y, k):
    """
    Calculate Ck for Sk(x)

    Parameters
    ----------
        Y2d : list
            list of y values with the second derived
        H : list
            list of h values from spline
        Y : list
            list of y values
        k : int
            index from Y2d, Y, H

    Returns
    -------
        float
            Ck from cubic spline 
    """
    return (Y[k] - Y[k - 1]) / H[k - 1] + (2 * H[k - 1] * Y2d[k] + Y2d[k - 1] * H[k - 1]) / 6