Solution (source code)

= Solution

Retain terms quadratic in the small displacements and velocities. The approximations $1-\cos\theta\simeq\theta^2/2$ and $\cos(\theta_1-\theta_2)\simeq1$ yield
$$
U\simeq\frac{mgl}{2}(4\theta_1^2+\theta_2^2),\qquad K\simeq\frac{ml^2}{2}(8\dot\theta_1^2+4\dot\theta_1\dot\theta_2+\dot\theta_2^2).
$$
Thus the correct <quadratic forms> are
$$
\boxed{U=\frac12\boldsymbol\theta^{\mathsf T}\mathbf V\boldsymbol\theta,\quad K=\frac12\dot{\boldsymbol\theta}^{\mathsf T}\mathbf T\dot{\boldsymbol\theta},\quad \mathbf V=mgl\begin{pmatrix}4&0\\0&1\end{pmatrix},\quad\mathbf T=ml^2\begin{pmatrix}8&2\\2&1\end{pmatrix}.}
$$
\b[Source correction.] The printed kinetic-energy matrix formula omits both time-derivative dots. It cannot hold as a function of angles alone: at $\boldsymbol\theta=0$, $\dot\theta_1\ne0$, $\dot\theta_2=0$, the actual kinetic energy is $4ml^2\dot\theta_1^2>0$, whereas the printed undifferentiated quadratic form vanishes.