RigidBodyPendulumDynamicsKaneLagrange.html  (MotionGenesis input/output).
```   (1) % MotionGenesis file:  RigidBodyPendulumDynamicsKaneLagrange.txt
(3) %----------------------------------------------------------------
(4) NewtonianFrame  N            % Earth.
(5) RigidBody       A            % Rod.
(6) %----------------------------------------------------------------
(7) Variable   theta''           % Angle and 1st/2nd time-derivatives.
(8) Constant   g = 9.8 m/s^2
(9) Constant   L = 7.5 cm
(10) A.SetMassInertia( m = 10 grams,  IAx,  IAy,  I = 50 g*cm^2 )
(11) %----------------------------------------------------------------
(12) %       Rotational and translational kinematics.
(13) A.RotateZ( N, theta )
-> (14) A_N = [cos(theta), sin(theta), 0;  -sin(theta), cos(theta), 0;  0, 0, 1]
-> (15) w_A_N> = theta'*Az>
-> (16) alf_A_N> = theta''*Az>

(17) Acm.Translate( No, -L*Ay> )
-> (18) p_No_Acm> = -L*Ay>
-> (19) v_Acm_N> = L*theta'*Ax>
-> (20) a_Acm_N> = L*theta''*Ax> + L*theta'^2*Ay>

(21) %----------------------------------------------------------------
-> (24) Force_Acm> = -m*g*Ny>

(25) %----------------------------------------------------------------
(26) %       Kane's equation of motion.
(27) SetGeneralizedSpeed(  theta'  )
(28) KaneDynamics = System.GetDynamicsKane()
-> (29) KaneDynamics = [m*g*L*sin(theta) + (I+m*L^2)*theta'']

(30) %----------------------------------------------------------------
(31) %       Lagrange's equation of motion.
(32) SetGeneralizedCoordinate(  theta  )
(33) PE = System.GetForceGravityPotentialEnergy( -g*Ny>, No )
-> (34) PE = -m*g*L*cos(theta)

(35) LagrangeDynamics = System.GetDynamicsLagrange( SystemPotential = PE )
-> (36) LagrangeDynamics = [m*g*L*sin(theta) + (I+m*L^2)*theta'']

(37) %---------------------------------------------------------------
(38) %       Check conservation of kinetic and potential energy.
(39) KE = System.GetKineticEnergy()
-> (40) KE = 0.5*(I+m*L^2)*theta'^2

(41) MechanicalEnergy = KE + PE
-> (42) MechanicalEnergy = PE + KE

(43) %----------------------------------------------------------------
(44) %       Integration parameters and initial values.
(45) Input  tFinal = 4 sec,  tStep  = 0.02 sec,  absError = 1.0E-07
(46) Input  theta = 90 deg,  theta' = 0.0 rad/sec
(47) %----------------------------------------------------------------
(48) %       List output quantities and solve ODEs.
(49) Output  t seconds,  theta degrees,  MechanicalEnergy Joules
(50) ODE( KaneDynamics = 0,  theta'' )

(51) %----------------------------------------------------------------
```