syms m1 m2 m3 l1 l2 l3 lc1 lc2 lc3 Ic1 Ic2 Ic3 th1 th2 th3 th1_dot th2_dot th3_dot g
L=inline('(1/2*m1*lc1^2 + 1/2*Ic1*th1_dot^2 + 1/2*m2*(l1^2 + lc2^2 * (th1_dot+th2_dot)^2 +2*l1*lc2*(th1_dot+th1_dot*th2_dot)*cos(th2)) + 1/2*Ic2(th1_dot+th2_dot)^2 + 1/2*m3*(2*l1*l2*cos(th2)*th1_dot*(th1_dot+th2_dot)+ l1^2 * th1^2 +2*l1*lc3*cos(th2+th3)*th1_dot(th1_dot+th2_dot+th3_dot)+ l2^2 *(th1_dot+th2_dot)^2 +2*l2*lc3 *cos(th3)*(th1_dot+th2_dot)*(th1_dot+th2_dot+th3_dot)+lc3^2 *(th1_dot+th2_dot+th3_dot)^2) + 1/2 * Ic3*(th1_dot+th2_dot+th3_dot)-m1*g*lc1*sin(th1)-m2*g*(l1*sin(th1)+lc2*sin(th1+th2)) - m3*g*(l1*sin(th1)+l2*sin(th1+th2)+lc3*sin(th1+th2+th3))','m1','m2', 'm3', 'l1', 'l2', 'l3', 'lc1', 'lc2', 'lc3', 'Ic1', 'Ic2', 'Ic3', 'th1', 'th2', 'th3', 'th1_dot', 'th2_dot', 'th3_dot', 'g')
part_1=diff(L(m1,m2,m3,l1,l2,l3,lc1,lc2,lc3,Ic1,Ic2,Ic3,th1,th2,th3,th1_dot,th2_dot,th3_dot,g),th1)