Hi all >> see attached images of pendulum and 2nd order model

Currently working on a problem, creating a model for a double pendulum system, we have been given the initial non-linear system of 2x 2nd order equations which have to simplified to 4x 1st order non linear equations; I know the basic theory and know that I can simplify the equations by compacting the variables and going from there

ie. representing them as,

aO1'' + bO2'' + c = 0

dO1'' + eO2'' + f =0

when O1'' = 2nd derivative of phi/ angular acceleration

just a bit lost in how to reproduce the final equations?

The equations are crazy but the theory should be basically the same, would appreciate any ideas......