def coupled_springs_rhs(y, t, z):
    """
    Defines the differential equations for the coupled spring-mass system.

    Arguments:
    w :  vector of the state variables:
    w = [x1, y1, x2, y2]
    t :  time
    p :  vector of the parameters:
    p = [m1, m2, k1, k2, L1, L2, b1, b2

    m1 and m2 are the masses
    k1 and k2 are the spring constants
    L1 and L2 are the natural lengths
    b1 abd b2 are the friction coefficients
    x1 and x2 are the initial displacements;
    y1 and y2 are the initial velocities
    """
    x1, y1, x2, y2 = y
    m1, m2, k1, k2, L1, L2, b1, b2 = z[:8]
    return [y1, (-b1*y1-k1*(x1-L1)+k2*(x2-x1-L2))/m1,
            y2, (-b2*y2-k2*(x2-x1-L2))/m2]