import math


def vectorfield(w, t):
    """
    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]
    """
    x1, y1, x2, y2, x3 = w

    # Create f = (x1',y1',x2',y2'):
    f = [2*math.pow(y1,2),
         y1*(x2-x1),
         -2*math.pow(y1,2)+2*math.pow(y2,2),
         y2*(x3-x2),
         -2*math.pow(y2,2)]
    return f