For systems for which the generalized forces can be derived from a generalized potential \(U\), the Lagrangian can be defined as \(L=T-U\) and the Euler Lagrange equations take the form \begin{equation*} \frac{d}{dt}\frac{\partial{L}}{\partial\dot{q_k}}-\frac{\partial{L}}{\partial{ q_k}}=0. \end{equation*}
Generalized Force
The Newton's equations of motion for a system of point particles acted upon by forces \(\vec F_\alpha\) can be cast into the form
\begin{equation}\label{EQ23} \Big(\frac{d}{dt}\frac{\partial{T}}{\partial\dot{q_k}}-\frac{\partial{T}}{ \partial{q_k}}\Big)=Q_k \end{equation}
where \(T\) is the kinetic energy, \(q_k, k=1,2,..,N\) are generalized coordinates. \(Q_k\) are generalized forces given by
\begin{equation}\label{EQ21A} \sum_\alpha{F_\alpha}^{(e)}\cdot\frac{ \partial\vec{r}_\alpha}{\partial{q_k}}\equiv Q_k \end{equation}
Velocity dependent forces and generalized potential
We assume that the forces depend on coordinates and velocities both and are such that they can be derived from a generalized potential \(U\) satisfying \begin{equation}\label{Eq29} \sum_{\alpha}\vec{F}_{\alpha}^{(e)}\frac{\partial\vec{r}_\alpha}{\partial{q_j}} =-\frac{\partial{U}}{\partial{q_j}}+\frac{d}{dt}\frac{\partial{U}}{\partial\dot{ q_j}} \end{equation}
where \(U\) is a function of $q,\dot{q},t$
Then again \eqref{EQ23} can be written in the Lagrangian form.
\begin{equation}\label{Eq31} L=\frac{d}{dt}\Big(\frac{\partial{L}}{\partial\dot{q_j}}\Big)-\frac{\partial{L}} {\partial{q_j}}=0 \end{equation}
where we again have
\begin{equation}\label{Eq32} L=T-U \end{equation}
We leave verification of \eqref{Eq31} as a simple exercise for the reader. $L$ is called Lagrangian and is a function of generalized coordinates $q_j$, generalized velocities $\dot{q_j}$ and $t$
\begin{equation}\label{Eq33} L=L(q,\dot{q},t) \end{equation}
We shall see that a description of motion of charges in electric and magnetic field requires use of a velocity dependent generalized potential recall that the magnetic forces are velocity dependent.