'Method to form Lagrange\'s equations of motion.
Returns a vector of equations of motion using Lagrange\'s equations of
the second kind.'

def form_lagranges_equations(self):

    qds = self._qdots
    qdd_zero = dict(((i, 0) for i in self._qdoubledots))
    n = len(self.q)
    self._term1 = self._L.jacobian(qds)
    self._term1 = self._term1.diff(dynamicsymbols._t).T
    self._term2 = self._L.jacobian(self.q).T
    if self.coneqs:
        coneqs = self.coneqs
        m = len(coneqs)
        self.lam_vec = Matrix(dynamicsymbols(('lam1:' + str((m + 1)))))
        self.lam_coeffs = (- coneqs.jacobian(qds))
        self._term3 = (self.lam_coeffs.T * self.lam_vec)
        diffconeqs = coneqs.diff(dynamicsymbols._t)
        self._m_cd = diffconeqs.jacobian(self._qdoubledots)
        self._f_cd = (- diffconeqs.subs(qdd_zero))
    else:
        self._term3 = zeros(n, 1)
    if self.forcelist:
        N = self.inertial
        self._term4 = zeros(n, 1)
        for (i, qd) in enumerate(qds):
            flist = zip(*_f_list_parser(self.forcelist, N))
            self._term4[i] = sum(((v.diff(qd, N) & f) for (v, f) in flist))
    else:
        self._term4 = zeros(n, 1)
    without_lam = ((self._term1 - self._term2) - self._term4)
    self._m_d = without_lam.jacobian(self._qdoubledots)
    self._f_d = (- without_lam.subs(qdd_zero))
    self.eom = (without_lam - self._term3)
    return self.eom
