For those of you wanting the equations, i had to split them into 2 comments
phi1dd = -((cos(theta2)*(l2*(pow(m2,2))*(pow(theta2d,2))*(1/tan(phi1-phi2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(1/sin(theta1))-2*l1*(pow(m2,2))*phi1d*theta1d*(pow((1/tan(theta1)),3))*(1/cos(theta2))-4*l1*(pow(m2,2))*phi1d*theta1d*(pow((1/tan(phi1-phi2)),2))*(pow((1/tan(theta1)),3))*(1/cos(theta2))-2*l1*(pow(m2,2))*phi1d*theta1d*(pow((1/tan(phi1-phi2)),4))*(pow((1/tan(theta1)),3))*(1/cos(theta2))-l1*m1*m2*(pow(phi1d,2))*(1/tan(phi1-phi2))*(pow((1/tan(theta1)),2))*(pow((1/sin(phi1-phi2)),2))*(1/cos(theta2))-l1*(pow(m2,2))*(pow(phi1d,2))*(1/tan(phi1-phi2))*(pow((1/tan(theta1)),2))*(pow((1/sin(phi1-phi2)),2))*(1/cos(theta2))+2*l1*m1*m2*phi1d*theta1d*(pow((1/tan(phi1-phi2)),2))*(pow((1/tan(theta1)),3))*(pow((1/sin(phi1-phi2)),2))*(1/cos(theta2))+2*l1*(pow(m2,2))*phi1d*theta1d*(pow((1/tan(phi1-phi2)),2))*(pow((1/tan(theta1)),3))*(pow((1/sin(phi1-phi2)),2))*(1/cos(theta2))+g*m1*m2*(1/tan(phi1-phi2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(1/sin(theta1))*(1/cos(theta2))+g*(pow(m2,2))*(1/tan(phi1-phi2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(1/sin(theta1))*(1/cos(theta2))+l1*m1*m2*(pow(phi1d,2))*(1/tan(phi1-phi2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(1/cos(theta2))+l1*(pow(m2,2))*(pow(phi1d,2))*(1/tan(phi1-phi2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(1/cos(theta2))+l1*m1*m2*(pow(theta1d,2))*(1/tan(phi1-phi2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(1/cos(theta2))+l1*(pow(m2,2))*(pow(theta1d,2))*(1/tan(phi1-phi2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(1/cos(theta2))+2*l1*m1*m2*phi1d*theta1d*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(1/cos(theta2))+2*l1*(pow(m2,2))*phi1d*theta1d*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(1/cos(theta2))-l2*(pow(m2,2))*(pow(theta2d,2))*(1/tan(phi1-phi2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(1/sin(theta1))*(pow((1/cos(theta2)),2))+l1*m1*m2*(pow(phi1d,2))*(1/tan(phi1-phi2))*(pow((1/tan(theta1)),2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/cos(theta2)),3))+l1*(pow(m2,2))*(pow(phi1d,2))*(1/tan(phi1-phi2))*(pow((1/tan(theta1)),2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/cos(theta2)),3))+2*l1*m1*m2*phi1d*theta1d*(pow((1/tan(theta1)),3))*(pow((1/sin(phi1-phi2)),2))*(pow((1/cos(theta2)),3))+2*l1*(pow(m2,2))*phi1d*theta1d*(pow((1/tan(theta1)),3))*(pow((1/sin(phi1-phi2)),2))*(pow((1/cos(theta2)),3))-g*m1*m2*(1/tan(phi1-phi2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(1/sin(theta1))*(pow((1/cos(theta2)),3))-g*(pow(m2,2))*(1/tan(phi1-phi2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(1/sin(theta1))*(pow((1/cos(theta2)),3))-l1*m1*m2*(pow(phi1d,2))*(1/tan(phi1-phi2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),3))-l1*(pow(m2,2))*(pow(phi1d,2))*(1/tan(phi1-phi2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),3))-l1*m1*m2*(pow(theta1d,2))*(1/tan(phi1-phi2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),3))-l1*(pow(m2,2))*(pow(theta1d,2))*(1/tan(phi1-phi2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),3))+2*l1*m1*m2*phi1d*theta1d*(pow((1/tan(phi1-phi2)),2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),3))+2*l1*(pow(m2,2))*phi1d*theta1d*(pow((1/tan(phi1-phi2)),2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),3))-2*l1*(pow(m1,2))*phi1d*theta1d*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),4))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),3))-4*l1*m1*m2*phi1d*theta1d*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),4))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),3))-2*l1*(pow(m2,2))*phi1d*theta1d*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),4))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),3))-l2*(pow(m2,2))*(pow(phi2d,2))*(pow((1/tan(theta1)),2))*(1/sin(phi1-phi2))*(1/sin(theta1))*tan(theta2)-l2*(pow(m2,2))*(pow(phi2d,2))*(pow((1/tan(phi1-phi2)),2))*(pow((1/tan(theta1)),2))*(1/sin(phi1-phi2))*(1/sin(theta1))*tan(theta2)+l2*(pow(m2,2))*(pow(theta2d,2))*(pow((1/sin(phi1-phi2)),3))*(1/sin(theta1))*tan(theta2)+l2*m1*m2*(pow(phi2d,2))*(pow((1/sin(phi1-phi2)),3))*(pow((1/sin(theta1)),3))*tan(theta2)+l2*(pow(m2,2))*(pow(phi2d,2))*(pow((1/sin(phi1-phi2)),3))*(pow((1/sin(theta1)),3))*tan(theta2)+l1*(pow(m2,2))*(pow(phi1d,2))*(1/tan(theta1))*(1/sin(phi1-phi2))*(1/cos(theta2))*tan(theta2)+l1*(pow(m2,2))*(pow(theta1d,2))*(1/tan(theta1))*(1/sin(phi1-phi2))*(1/cos(theta2))*tan(theta2)+l1*(pow(m2,2))*(pow(phi1d,2))*(pow((1/tan(phi1-phi2)),2))*(1/tan(theta1))*(1/sin(phi1-phi2))*(1/cos(theta2))*tan(theta2)+l1*(pow(m2,2))*(pow(theta1d,2))*(pow((1/tan(phi1-phi2)),2))*(1/tan(theta1))*(1/sin(phi1-phi2))*(1/cos(theta2))*tan(theta2)-4*l1*(pow(m2,2))*phi1d*theta1d*(1/tan(phi1-phi2))*(pow((1/tan(theta1)),2))*(1/sin(phi1-phi2))*(1/cos(theta2))*tan(theta2)-4*l1*(pow(m2,2))*phi1d*theta1d*(pow((1/tan(phi1-phi2)),3))*(pow((1/tan(theta1)),2))*(1/sin(phi1-phi2))*(1/cos(theta2))*tan(theta2)+l1*(pow(m2,2))*(pow(theta1d,2))*(pow((1/tan(theta1)),3))*(1/sin(phi1-phi2))*(1/cos(theta2))*tan(theta2)+l1*(pow(m2,2))*(pow(theta1d,2))*(pow((1/tan(phi1-phi2)),2))*(pow((1/tan(theta1)),3))*(1/sin(phi1-phi2))*(1/cos(theta2))*tan(theta2)-l1*m1*m2*(pow(phi1d,2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),3))*(1/cos(theta2))*tan(theta2)-l1*(pow(m2,2))*(pow(phi1d,2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),3))*(1/cos(theta2))*tan(theta2)+4*l1*m1*m2*phi1d*theta1d*(1/tan(phi1-phi2))*(pow((1/tan(theta1)),2))*(pow((1/sin(phi1-phi2)),3))*(1/cos(theta2))*tan(theta2)+4*l1*(pow(m2,2))*phi1d*theta1d*(1/tan(phi1-phi2))*(pow((1/tan(theta1)),2))*(pow((1/sin(phi1-phi2)),3))*(1/cos(theta2))*tan(theta2)+g*(pow(m2,2))*(pow((1/tan(theta1)),2))*(1/sin(phi1-phi2))*(1/sin(theta1))*(1/cos(theta2))*tan(theta2)+g*(pow(m2,2))*(pow((1/tan(phi1-phi2)),2))*(pow((1/tan(theta1)),2))*(1/sin(phi1-phi2))*(1/sin(theta1))*(1/cos(theta2))*tan(theta2)+g*m1*m2*(pow((1/sin(phi1-phi2)),3))*(1/sin(theta1))*(1/cos(theta2))*tan(theta2)+g*(pow(m2,2))*(pow((1/sin(phi1-phi2)),3))*(1/sin(theta1))*(1/cos(theta2))*tan(theta2)-l1*m1*m2*(pow(theta1d,2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),3))*(pow((1/sin(theta1)),2))*(1/cos(theta2))*tan(theta2)-l1*(pow(m2,2))*(pow(theta1d,2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),3))*(pow((1/sin(theta1)),2))*(1/cos(theta2))*tan(theta2)-g*m1*m2*(pow((1/sin(phi1-phi2)),3))*(pow((1/sin(theta1)),3))*(1/cos(theta2))*tan(theta2)-g*(pow(m2,2))*(pow((1/sin(phi1-phi2)),3))*(pow((1/sin(theta1)),3))*(1/cos(theta2))*tan(theta2)+l2*(pow(m2,2))*(pow(phi2d,2))*(pow((1/tan(theta1)),2))*(1/sin(phi1-phi2))*(1/sin(theta1))*(pow((1/cos(theta2)),2))*tan(theta2)+l2*(pow(m2,2))*(pow(theta2d,2))*(pow((1/tan(theta1)),2))*(1/sin(phi1-phi2))*(1/sin(theta1))*(pow((1/cos(theta2)),2))*tan(theta2)+l2*(pow(m2,2))*(pow(phi2d,2))*(pow((1/tan(phi1-phi2)),2))*(pow((1/tan(theta1)),2))*(1/sin(phi1-phi2))*(1/sin(theta1))*(pow((1/cos(theta2)),2))*tan(theta2)+l2*(pow(m2,2))*(pow(theta2d,2))*(pow((1/tan(phi1-phi2)),2))*(pow((1/tan(theta1)),2))*(1/sin(phi1-phi2))*(1/sin(theta1))*(pow((1/cos(theta2)),2))*tan(theta2)-l2*m1*m2*(pow(phi2d,2))*(pow((1/sin(phi1-phi2)),3))*(pow((1/sin(theta1)),3))*(pow((1/cos(theta2)),2))*tan(theta2)-l2*(pow(m2,2))*(pow(phi2d,2))*(pow((1/sin(phi1-phi2)),3))*(pow((1/sin(theta1)),3))*(pow((1/cos(theta2)),2))*tan(theta2)-l2*m1*m2*(pow(theta2d,2))*(pow((1/sin(phi1-phi2)),3))*(pow((1/sin(theta1)),3))*(pow((1/cos(theta2)),2))*tan(theta2)-l2*(pow(m2,2))*(pow(theta2d,2))*(pow((1/sin(phi1-phi2)),3))*(pow((1/sin(theta1)),3))*(pow((1/cos(theta2)),2))*tan(theta2)+l2*(pow(m2,2))*(pow(theta2d,2))*(1/tan(phi1-phi2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(1/sin(theta1))*(pow(tan(theta2),2))+l1*(pow(m2,2))*(pow(phi1d,2))*(1/tan(phi1-phi2))*(pow((1/sin(phi1-phi2)),2))*(1/cos(theta2))*(pow(tan(theta2),2))+l1*(pow(m2,2))*(pow(theta1d,2))*(1/tan(phi1-phi2))*(pow((1/sin(phi1-phi2)),2))*(1/cos(theta2))*(pow(tan(theta2),2))-2*l1*(pow(m2,2))*phi1d*theta1d*(pow((1/tan(phi1-phi2)),2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(1/cos(theta2))*(pow(tan(theta2),2))+l1*(pow(m2,2))*(pow(theta1d,2))*(1/tan(phi1-phi2))*(pow((1/tan(theta1)),2))*(pow((1/sin(phi1-phi2)),2))*(1/cos(theta2))*(pow(tan(theta2),2))+2*l1*m1*m2*phi1d*theta1d*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),4))*(1/cos(theta2))*(pow(tan(theta2),2))+2*l1*(pow(m2,2))*phi1d*theta1d*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),4))*(1/cos(theta2))*(pow(tan(theta2),2))+g*(pow(m2,2))*(1/tan(phi1-phi2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),2))*(1/sin(theta1))*(1/cos(theta2))*(pow(tan(theta2),2))+l2*(pow(m2,2))*(pow(phi2d,2))*(pow((1/sin(phi1-phi2)),3))*(1/sin(theta1))*(pow(tan(theta2),3))+l2*(pow(m2,2))*(pow(theta2d,2))*(pow((1/sin(phi1-phi2)),3))*(1/sin(theta1))*(pow(tan(theta2),3))))/(l1*(-(pow(m2,2))*(pow((1/tan(theta1)),2))-2*(pow(m2,2))*(pow((1/tan(phi1-phi2)),2))*(pow((1/tan(theta1)),2))-(pow(m2,2))*(pow((1/tan(phi1-phi2)),4))*(pow((1/tan(theta1)),2))+m1*m2*(pow((1/tan(phi1-phi2)),2))*(pow((1/tan(theta1)),2))*(pow((1/sin(phi1-phi2)),2))+(pow(m2,2))*(pow((1/tan(phi1-phi2)),2))*(pow((1/tan(theta1)),2))*(pow((1/sin(phi1-phi2)),2))+m1*m2*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))+(pow(m2,2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))+m1*m2*(pow((1/tan(theta1)),2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/cos(theta2)),2))+(pow(m2,2))*(pow((1/tan(theta1)),2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/cos(theta2)),2))+m1*m2*(pow((1/tan(phi1-phi2)),2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),2))+(pow(m2,2))*(pow((1/tan(phi1-phi2)),2))*(pow((1/sin(phi1-phi2)),2))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),2))-(pow(m1,2))*(pow((1/sin(phi1-phi2)),4))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),2))-2*m1*m2*(pow((1/sin(phi1-phi2)),4))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),2))-(pow(m2,2))*(pow((1/sin(phi1-phi2)),4))*(pow((1/sin(theta1)),2))*(pow((1/cos(theta2)),2))-2*(pow(m2,2))*(1/tan(phi1-phi2))*(1/tan(theta1))*(1/sin(phi1-phi2))*tan(theta2)-2*(pow(m2,2))*(pow((1/tan(phi1-phi2)),3))*(1/tan(theta1))*(1/sin(phi1-phi2))*tan(theta2)+2*m1*m2*(1/tan(phi1-phi2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),3))*tan(theta2)+2*(pow(m2,2))*(1/tan(phi1-phi2))*(1/tan(theta1))*(pow((1/sin(phi1-phi2)),3))*tan(theta2)-(pow(m2,2))*(pow((1/tan(phi1-phi2)),2))*(pow((1/sin(phi1-phi2)),2))*(pow(tan(theta2),2))+m1*m2*(pow((1/sin(phi1-phi2)),4))*(pow(tan(theta2),2))+(pow(m2,2))*(pow((1/sin(phi1-phi2)),4))*(pow(tan(theta2),2)))));
phi2dd = -((cos(theta2)*(2*l2*m1*m2*phi2d*theta2d*(pow(cos(phi1-phi2),2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))+2*l2*(pow(m2,2))*phi2d*theta2d*(pow(cos(phi1-phi2),2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))-2*l2*(pow(m2,2))*phi2d*theta2d*(pow(cos(phi1-phi2),4))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))-2*l2*(pow(m1,2))*phi2d*theta2d*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),2))-4*l2*m1*m2*phi2d*theta2d*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),2))-2*l2*(pow(m2,2))*phi2d*theta2d*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),2))+2*l2*m1*m2*phi2d*theta2d*(pow(cos(phi1-phi2),2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),2))+2*l2*(pow(m2,2))*phi2d*theta2d*(pow(cos(phi1-phi2),2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),2))-l2*m1*m2*(pow(phi2d,2))*cos(phi1-phi2)*(pow((1/sin(theta2)),2))*(1/cos(theta2))*sin(phi1-phi2)-l2*(pow(m2,2))*(pow(phi2d,2))*cos(phi1-phi2)*(pow((1/sin(theta2)),2))*(1/cos(theta2))*sin(phi1-phi2)+l2*m1*m2*(pow(phi2d,2))*cos(phi1-phi2)*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))*(1/cos(theta2))*sin(phi1-phi2)+l2*(pow(m2,2))*(pow(phi2d,2))*cos(phi1-phi2)*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))*(1/cos(theta2))*sin(phi1-phi2)+g*m1*m2*cos(phi1-phi2)*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)+g*(pow(m2,2))*cos(phi1-phi2)*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)+l1*m1*m2*(pow(theta1d,2))*cos(phi1-phi2)*cos(theta1)*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)+l1*(pow(m2,2))*(pow(theta1d,2))*cos(phi1-phi2)*cos(theta1)*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)-g*m1*m2*cos(phi1-phi2)*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)-g*(pow(m2,2))*cos(phi1-phi2)*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)-l1*m1*m2*(pow(theta1d,2))*cos(phi1-phi2)*(pow(cos(theta1),3))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)-l1*(pow(m2,2))*(pow(theta1d,2))*cos(phi1-phi2)*(pow(cos(theta1),3))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)+l2*m1*m2*(pow(phi2d,2))*cos(phi1-phi2)*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)+l2*(pow(m2,2))*(pow(phi2d,2))*cos(phi1-phi2)*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)+l2*m1*m2*(pow(theta2d,2))*cos(phi1-phi2)*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)+l2*(pow(m2,2))*(pow(theta2d,2))*cos(phi1-phi2)*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)-l2*m1*m2*(pow(phi2d,2))*cos(phi1-phi2)*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)-l2*(pow(m2,2))*(pow(phi2d,2))*cos(phi1-phi2)*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)-l2*m1*m2*(pow(theta2d,2))*cos(phi1-phi2)*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)-l2*(pow(m2,2))*(pow(theta2d,2))*cos(phi1-phi2)*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)+2*l2*m1*m2*phi2d*theta2d*(pow((1/sin(theta2)),3))*(pow(sin(phi1-phi2),2))+2*l2*(pow(m2,2))*phi2d*theta2d*(pow((1/sin(theta2)),3))*(pow(sin(phi1-phi2),2))-4*l2*(pow(m2,2))*phi2d*theta2d*(pow(cos(phi1-phi2),2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))*(pow(sin(phi1-phi2),2))+2*l2*m1*m2*phi2d*theta2d*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),2))*(pow(sin(phi1-phi2),2))+2*l2*(pow(m2,2))*phi2d*theta2d*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),2))*(pow(sin(phi1-phi2),2))-2*l2*(pow(m2,2))*phi2d*theta2d*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))*(pow(sin(phi1-phi2),4))+4*l2*m1*m2*phi2d*theta2d*cos(phi1-phi2)*cos(theta1)*(pow((1/sin(theta2)),2))*(1/cos(theta2))*sin(theta1)+4*l2*(pow(m2,2))*phi2d*theta2d*cos(phi1-phi2)*cos(theta1)*(pow((1/sin(theta2)),2))*(1/cos(theta2))*sin(theta1)-4*l2*(pow(m2,2))*phi2d*theta2d*(pow(cos(phi1-phi2),3))*cos(theta1)*(pow((1/sin(theta2)),2))*(1/cos(theta2))*sin(theta1)-l2*(pow(m2,2))*(pow(theta2d,2))*(pow(cos(phi1-phi2),2))*cos(theta1)*(pow((1/sin(theta2)),3))*sin(phi1-phi2)*sin(theta1)-l1*m1*m2*(pow(phi1d,2))*(pow(cos(phi1-phi2),2))*(pow((1/sin(theta2)),3))*(1/cos(theta2))*sin(phi1-phi2)*sin(theta1)-l1*(pow(m2,2))*(pow(phi1d,2))*(pow(cos(phi1-phi2),2))*(pow((1/sin(theta2)),3))*(1/cos(theta2))*sin(phi1-phi2)*sin(theta1)-l1*m1*m2*(pow(theta1d,2))*(pow(cos(phi1-phi2),2))*(pow((1/sin(theta2)),3))*(1/cos(theta2))*sin(phi1-phi2)*sin(theta1)-l1*(pow(m2,2))*(pow(theta1d,2))*(pow(cos(phi1-phi2),2))*(pow((1/sin(theta2)),3))*(1/cos(theta2))*sin(phi1-phi2)*sin(theta1)-g*m1*m2*(pow(cos(phi1-phi2),2))*cos(theta1)*(pow((1/sin(theta2)),3))*(1/cos(theta2))*sin(phi1-phi2)*sin(theta1)-g*(pow(m2,2))*(pow(cos(phi1-phi2),2))*cos(theta1)*(pow((1/sin(theta2)),3))*(1/cos(theta2))*sin(phi1-phi2)*sin(theta1)+l1*m1*m2*(pow(phi1d,2))*(pow(cos(phi1-phi2),2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))*(1/cos(theta2))*sin(phi1-phi2)*sin(theta1)+l1*(pow(m2,2))*(pow(phi1d,2))*(pow(cos(phi1-phi2),2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))*(1/cos(theta2))*sin(phi1-phi2)*sin(theta1)+l2*m1*m2*(pow(phi2d,2))*cos(theta1)*(1/sin(theta2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)*sin(theta1)+l2*(pow(m2,2))*(pow(phi2d,2))*cos(theta1)*(1/sin(theta2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)*sin(theta1)-l2*(pow(m2,2))*(pow(phi2d,2))*(pow(cos(phi1-phi2),2))*cos(theta1)*(1/sin(theta2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)*sin(theta1)-l2*(pow(m2,2))*(pow(theta2d,2))*(pow(cos(phi1-phi2),2))*cos(theta1)*(1/sin(theta2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)*sin(theta1)+l2*m1*m2*(pow(theta2d,2))*cos(theta1)*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)*sin(theta1)+l2*(pow(m2,2))*(pow(theta2d,2))*cos(theta1)*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)*sin(theta1)-g*m1*m2*cos(theta1)*(1/sin(theta2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)-g*(pow(m2,2))*cos(theta1)*(1/sin(theta2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)-l1*m1*m2*(pow(theta1d,2))*(pow(cos(theta1),2))*(1/sin(theta2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)-l1*(pow(m2,2))*(pow(theta1d,2))*(pow(cos(theta1),2))*(1/sin(theta2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)+l1*(pow(m1,2))*(pow(phi1d,2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)+2*l1*m1*m2*(pow(phi1d,2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)+l1*(pow(m2,2))*(pow(phi1d,2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)+l1*(pow(m1,2))*(pow(theta1d,2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)+2*l1*m1*m2*(pow(theta1d,2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)+l1*(pow(m2,2))*(pow(theta1d,2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)+g*(pow(m1,2))*cos(theta1)*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)+2*g*m1*m2*cos(theta1)*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)+g*(pow(m2,2))*cos(theta1)*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)-l1*(pow(m1,2))*(pow(phi1d,2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)-2*l1*m1*m2*(pow(phi1d,2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)-l1*(pow(m2,2))*(pow(phi1d,2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*sin(theta1)-4*l2*(pow(m2,2))*phi2d*theta2d*cos(phi1-phi2)*cos(theta1)*(pow((1/sin(theta2)),2))*(1/cos(theta2))*(pow(sin(phi1-phi2),2))*sin(theta1)-l2*(pow(m2,2))*(pow(theta2d,2))*cos(theta1)*(pow((1/sin(theta2)),3))*(pow(sin(phi1-phi2),3))*sin(theta1)-l1*m1*m2*(pow(phi1d,2))*(pow((1/sin(theta2)),3))*(1/cos(theta2))*(pow(sin(phi1-phi2),3))*sin(theta1)-l1*(pow(m2,2))*(pow(phi1d,2))*(pow((1/sin(theta2)),3))*(1/cos(theta2))*(pow(sin(phi1-phi2),3))*sin(theta1)-l1*m1*m2*(pow(theta1d,2))*(pow((1/sin(theta2)),3))*(1/cos(theta2))*(pow(sin(phi1-phi2),3))*sin(theta1)-l1*(pow(m2,2))*(pow(theta1d,2))*(pow((1/sin(theta2)),3))*(1/cos(theta2))*(pow(sin(phi1-phi2),3))*sin(theta1)-g*m1*m2*cos(theta1)*(pow((1/sin(theta2)),3))*(1/cos(theta2))*(pow(sin(phi1-phi2),3))*sin(theta1)-g*(pow(m2,2))*cos(theta1)*(pow((1/sin(theta2)),3))*(1/cos(theta2))*(pow(sin(phi1-phi2),3))*sin(theta1)+l1*m1*m2*(pow(phi1d,2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))*(1/cos(theta2))*(pow(sin(phi1-phi2),3))*sin(theta1)+l1*(pow(m2,2))*(pow(phi1d,2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),3))*(1/cos(theta2))*(pow(sin(phi1-phi2),3))*sin(theta1)-l2*(pow(m2,2))*(pow(phi2d,2))*cos(theta1)*(1/sin(theta2))*(pow((1/cos(theta2)),2))*(pow(sin(phi1-phi2),3))*sin(theta1)-l2*(pow(m2,2))*(pow(theta2d,2))*cos(theta1)*(1/sin(theta2))*(pow((1/cos(theta2)),2))*(pow(sin(phi1-phi2),3))*sin(theta1)+2*l2*m1*m2*phi2d*theta2d*(1/sin(theta2))*(pow((1/cos(theta2)),2))*(pow(sin(theta1),2))+2*l2*(pow(m2,2))*phi2d*theta2d*(1/sin(theta2))*(pow((1/cos(theta2)),2))*(pow(sin(theta1),2))-2*l2*(pow(m2,2))*phi2d*theta2d*(pow(cos(phi1-phi2),2))*(1/sin(theta2))*(pow((1/cos(theta2)),2))*(pow(sin(theta1),2))-l2*(pow(m2,2))*(pow(theta2d,2))*cos(phi1-phi2)*(pow((1/sin(theta2)),2))*(1/cos(theta2))*sin(phi1-phi2)*(pow(sin(theta1),2))-g*m1*m2*cos(phi1-phi2)*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)*(pow(sin(theta1),2))-g*(pow(m2,2))*cos(phi1-phi2)*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)*(pow(sin(theta1),2))-l1*m1*m2*(pow(theta1d,2))*cos(phi1-phi2)*cos(theta1)*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)*(pow(sin(theta1),2))-l1*(pow(m2,2))*(pow(theta1d,2))*cos(phi1-phi2)*cos(theta1)*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*sin(phi1-phi2)*(pow(sin(theta1),2))-l2*(pow(m2,2))*(pow(phi2d,2))*cos(phi1-phi2)*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*(pow(sin(theta1),2))-l2*(pow(m2,2))*(pow(theta2d,2))*cos(phi1-phi2)*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*(pow(sin(theta1),2))-l1*m1*m2*(pow(phi1d,2))*(1/sin(theta2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*(pow(sin(theta1),3))-l1*(pow(m2,2))*(pow(phi1d,2))*(1/sin(theta2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*(pow(sin(theta1),3))-l1*m1*m2*(pow(theta1d,2))*(1/sin(theta2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*(pow(sin(theta1),3))-l1*(pow(m2,2))*(pow(theta1d,2))*(1/sin(theta2))*(pow((1/cos(theta2)),3))*sin(phi1-phi2)*(pow(sin(theta1),3))))/(l2*(m1*m2*(pow(cos(phi1-phi2),2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))+(pow(m2,2))*(pow(cos(phi1-phi2),2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))-(pow(m2,2))*(pow(cos(phi1-phi2),4))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))-(pow(m1,2))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))-2*m1*m2*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))-(pow(m2,2))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))+m1*m2*(pow(cos(phi1-phi2),2))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))+(pow(m2,2))*(pow(cos(phi1-phi2),2))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))+m1*m2*(pow((1/sin(theta2)),2))*(pow(sin(phi1-phi2),2))+(pow(m2,2))*(pow((1/sin(theta2)),2))*(pow(sin(phi1-phi2),2))-2*(pow(m2,2))*(pow(cos(phi1-phi2),2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))*(pow(sin(phi1-phi2),2))+m1*m2*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*(pow(sin(phi1-phi2),2))+(pow(m2,2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))*(pow((1/cos(theta2)),2))*(pow(sin(phi1-phi2),2))-(pow(m2,2))*(pow(cos(theta1),2))*(pow((1/sin(theta2)),2))*(pow(sin(phi1-phi2),4))+2*m1*m2*cos(phi1-phi2)*cos(theta1)*(1/sin(theta2))*(1/cos(theta2))*sin(theta1)+2*(pow(m2,2))*cos(phi1-phi2)*cos(theta1)*(1/sin(theta2))*(1/cos(theta2))*sin(theta1)-2*(pow(m2,2))*(pow(cos(phi1-phi2),3))*cos(theta1)*(1/sin(theta2))*(1/cos(theta2))*sin(theta1)-2*(pow(m2,2))*cos(phi1-phi2)*cos(theta1)*(1/sin(theta2))*(1/cos(theta2))*(pow(sin(phi1-phi2),2))*sin(theta1)+m1*m2*(pow((1/cos(theta2)),2))*(pow(sin(theta1),2))+(pow(m2,2))*(pow((1/cos(theta2)),2))*(pow(sin(theta1),2))-(pow(m2,2))*(pow(cos(phi1-phi2),2))*(pow((1/cos(theta2)),2))*(pow(sin(theta1),2)))));