(*Energy of (Subscript[m, 1])*)
x1 = (Subscript[r, 1])[t]*Sin[(Subscript[θ, 1])[t]];
x1Dot = D[x1,t]//Simplify;
y1 = -(Subscript[r, 1])[t]*Cos[(Subscript[θ, 1])[t]];
y1Dot = D[y1,t]//Simplify;
kE1 = (1/2)*(Subscript[m, 1])*((x1Dot^2) + (y1Dot^2))//Simplify;
pE1 = (1/2)*(Subscript[k, 1])*((((Subscript[l, 1])-(Subscript[r, 1])[t]))^2)+(Subscript[m, 1])*g*y1//Simplify;

(*Energy of (Subscript[m, 2])*)
x2 = (Subscript[r, 1])[t]*Sin[(Subscript[θ, 1])[t]] + (Subscript[r, 2])[t]*Sin[(Subscript[θ, 2])[t]];
x2Dot = D[x2,t]//Simplify;
y2 = -(Subscript[r, 1])[t]*Cos[(Subscript[θ, 1])[t]] - (Subscript[r, 2])[t]*Cos[(Subscript[θ, 2])[t]];
y2Dot = D[y2,t]//Simplify;
kE2 = (1/2)*(Subscript[m, 2])*((x2Dot^2) + (y2Dot^2))//Expand//Simplify;
pE2 = (1/2)*(Subscript[k, 2])*((((Subscript[l, 2])-(Subscript[r, 2])[t]))^2)+(Subscript[m, 2])*g*y2//Simplify;

(*Lagrangian*)
lagrange = kE1+kE2 - pE1 - pE2//Expand//Simplify;

(*Euler lagrange for (Subscript[θ, 1])*)
dLdTheta1 = D[lagrange,(Subscript[θ, 1])[t]]//Expand//Simplify;
dLdTheta1Dot = D[lagrange,(Subscript[θ, 1])'[t]]//Expand//Simplify;
dLdTheta1DotdT = D[dLdTheta1Dot,t]//Expand//Simplify;
equation1 = dLdTheta1-dLdTheta1DotdT//Expand//Simplify;

(*Euler lagrange for (Subscript[r, 1])*)
dLdR1 = D[lagrange,(Subscript[r, 1])[t]]//Expand//Simplify;
dLdR1Dot = D[lagrange,(Subscript[r, 1])'[t]]//Expand//Simplify;
dLdR1DotdT = D[dLdR1Dot,t]//Expand//Simplify;
equation2 = dLdR1-dLdR1DotdT//Expand//Simplify;

(*Euler lagrange for (Subscript[θ, 2])*)
dLdTheta2 = D[lagrange,(Subscript[θ, 2])[t]]//Expand//Simplify;
dLdTheta2Dot = D[lagrange,(Subscript[θ, 2])'[t]]//Expand//Simplify;
dLdTheta2DotdT = D[dLdTheta2Dot,t]//Expand//Simplify;
equation3 = dLdTheta2-dLdTheta2DotdT//Expand//Simplify;

(*Euler lagrange for (Subscript[r, 2])*)
dLdR2 = D[lagrange,(Subscript[r, 2])[t]]//Expand//Simplify;
dLdR2Dot = D[lagrange,(Subscript[r, 2])'[t]]//Expand//Simplify;
dLdR2DotdT = D[dLdR2Dot,t]//Expand//Simplify;
equation4 = dLdR2-dLdR2DotdT//Expand//Simplify;

(*Simultaneously solve equations of motion*)
Solve[{equation1==0, equation2==0, equation3==0, equation4==0},{(Subscript[θ, 1])''[t],(Subscript[r, 1])''[t],(Subscript[θ, 2])''[t],(Subscript[r, 2])''[t]}]//Simplify