Lagrangian mechanics problem i have managed to find the kinetic energy but it cant be right because i didnt do anything to do with the rotational inertia because i have no idea how to do part (a)
for part 3 the lagrangian is just $L=T-U$ where $T$ is the kinetic energy and $U$ is the potential energy?
part 4 seems straight forward but i need to calculate L first, but i'm struggling to find the potential energy and the correct kinetic energy, i've only been doing examples with one mass this time there is multiple so its confusing me.

 A: Calling $I_O$ the hoop inertia moment regarding $O$ and
$p_M = a(\sin\phi,-\cos\phi),\ \ p_m = p_M + a(\sin\theta,-\cos\theta)$ we have
$$
T = \frac 12\left(I_O\dot\phi^2+m \|\dot p_m\|^2\right)
$$
and
$$
V = g\left(M p_M + m p_m\right)\cdot(0,1)
$$
then $L = T - V$ and the movement equations are
$$
\left\{
\begin{array}{rcl}
\phi'' & = &  -\frac{a \left(2 a m \sin (\phi-\theta ) \left(\phi '^2 \cos (\phi-\theta)+\theta '^2\right)+g (m+2 M) \sin (\phi)+g m \sin (\phi
  -2 \theta)\right)}{2 \left(a^2 (m+M)+a^2 (-m) \cos ^2(\phi -\theta )+I_O\right)} \\
\theta'' & = &  -\frac{a^3 m \theta '^2 \sin (2 (\phi-\theta ))-g \sin (\theta) \left(a^2 (m+M)+2 I_O\right)+a^2 g (m+M) \sin (2 \phi-\theta)+2
   a \phi '^2 \left(a^2 (m+M)+I_O\right) \sin (\phi-\theta )}{2 \left(a^3 m \cos ^2(\phi-\theta)-a \left(a^2
   (m+M)+I_O\right)\right)} \\
\end{array}
\right.
$$
Considering now small variations $(|\alpha| << 1, \sin\alpha = \alpha,\ \cos\alpha = 1,\ \alpha^2=0)$ we have
$$
\left(
\begin{array}{c}
\phi''\\
\theta''
\end{array}
\right)=
\left(
\begin{array}{cc}
 -\frac{a g (m+M)}{I_O} & \frac{a g m}{I_O} \\
 \frac{a g (m+M)}{I_O} & -\frac{g \left(a^2 m+I_O\right)}{a I_O} \\
\end{array}
\right)\left(
\begin{array}{c}
\phi\\
\theta
\end{array}
\right)
$$
