Kinetic and Potential Energy of a multi degree of freedom (MDOF) system Consider the following MDOF system:
$M\ddot x+Kx=F$
where $M$ and $K$ are the mass and stiffness matrix respectively, and $x$ and $F$ are the displacement and force vectors.
How can one determine the potential and kinetic energy?
 A: $\def \b {\mathbf}$
$$\b M\,\ddot{\b{x}}+\b K\,\b x=\b F$$
multiply from the left with $~\frac{d}{dt}{\b{x}}$
$$\dot{\b{x}}\,\cdot \left(\b M\,\ddot{\b{x}}\right)+\frac{d}{dt}{\b{x}}\,\cdot\,\left(\b K\,\b x\right)=\frac{d}{dt}{\b{x}}\cdot\b F\tag 1$$
thus equation (1)
$$\frac{d}{dt}\left(\frac 12\dot{\b{x}}^T\b M\,\dot{\b{x}}\right)+\frac{d}{dt}{\b{x}}\,\cdot\,\left(\b K\,\b x\right)=\frac{d}{dt}{\b{x}}\cdot\b F$$
multiply with $~dt~$ and integrate (assume $~\b F~$ is constant)
$$ \underbrace{\frac 12\dot{\b{x}}^T\b M\,\dot{\b{x}}}_{\text{kinetic energy}} +
\underbrace{\frac 12\b x^T\,\b K\,\b x-\b F\cdot x}_{\text{potential energy}}=0$$

assume you have this scalar equation
$$ m\ddot x+k\,x=F$$
multiply with $~\dot x~$
$$\dot x\,m\,\ddot x+\dot x\,k\,x=\dot x\,F$$
with $$~\dot x\,m\,\ddot x~=\frac m2\frac {d}{dt}\,\dot x^2$$
you obtain
$$\frac m2\frac {d}{dt}\,\dot x^2+\frac{dx}{dt}\,k\,x=
\frac{dx}{dt}\,F\\
\frac m2 {d}\,(\dot x^2)+{dx}\,k\,x=
{dx}\,F\\
\int \frac m2 {d}\,(\dot x^2)+\int{dx}\,k\,x=
\int{dx}\,F\\$$
$$\frac m2 \,(\dot x^2)+\frac{k}{2}\,x^2=F\,x$$
If you deals with vectors and matrices you obtain the above result
