<<Daryl`ClassicalDynamics`;

Examples

Simple Pendulum

m	Mass
l	Length
th[t]	Time dependent angular orientation

EquationsOfMotion[1/2 m (l th'[t])^2, m g l(1-Cos[th[t]]), {th[t]}]

Double Pendulum

m1,m2		Mass
l1,l2		Length
th1[t],th2[t]		Time dependent angular orientation

EquationsOfMotion[
  1/2 m1 (l1 th1'[t])^2+1/2 m2((l1 th1'[t])^2+
    (l2 th2'[t])^2+2 l1 l2 th1'[t] th2'[t] Cos[th1[t]-th2[t]]),
 m1 g l1(1-Cos[th1[t]])+m2 g l1 (1-Cos[th1[t]])+m2 g l2 (1-Cos[th2[t]]),
 {th1[t],th2[t]}]

A mass, m[1],  connected to ground by spring, k[1] and then connected to another mass, m[2], by spring, k[2].

EquationsOfMotion[
  1/2 m[1] (x[1])'[t]^2 + 1/2 m[2] (x[2])'[t]^2,
  1/2 k[1] (x[1])[t]^2 + 1/2 k[2] ((x[2])[t]-(x[1])[t])^2,
  {(x[1])[t], (x[2])[t]}]

Spring, k-mass, m-damper, c

EquationsOfMotion[
  1/2 m x'[t]^2, 1/2 k x[t]^2, 1/2 c x'[t]^2,{x[t]}]

Spring, k-Mass, m

EquationsOfMotion[1/2 m x'[t]^2, 1/2 k x[t]^2, {x[t]},
                  Method->Hamiltonian]

Particles, connected by spring, sliding in rotating tube

On[ClassicalDynamics`Private`HamiltonianEquations::printhamiltonian];
$MessagePrePrint=OutputForm;

m1,m2		Mass of two particles
r		Radius of circular tube and natural length of spring
k[t]		Modulus of spring
omega[t]		Rotational speed about vertical axis
q1[t], q2[t]		Angular position of masses in tube, measured from bottom

eqns=EquationsOfMotion[
  1/2 (m1 r^2 D[q1[t],t]^2+m2 r^2 D[q2[t],t]^2+
       r^2 omega[t]^2 (m1 Sin[q1[t]]^2+m2 Sin[q2[t]]^2)),
  1/2 k[t] r^2(q2[t]-q1[t]-1)^2-
      g r(m1 Cos[q1[t]]+m2 Cos[q2[t]]),
  {q1[t], q2[t]}, Method->Hamiltonian, CanonicVariable->{p1[t],p2[t]}]

Off[ClassicalDynamics`Private`HamiltonianEquations::printhamiltonian];
$MessagePrePrint=Short;

Spherical Pendulum

l	Length
m	Mass
phi[t]	Angle in x-y plane
th[t]	Angle from z axis

EquationsOfMotion[1/2 m((l th'[t])^2+(l Sin[th[t]] phi'[t])^2),
                  -m g l Cos[th[t]], {th[t], phi[t]}]