Wolfram Alpha:

Ex:  Newtonian, Lagrangian and Hamiltonian Mechanics
----------------------------------------------------

We will demonstrate the equivalency of Newtonian,
Lagrangian and Hamiltonian mechanics by finding the
equations of motion for the simple pendulum using
all three methods.

Newtonian
---------

FT = -mgsinθ

Where,

T stands for tangential.

Now sinθ = θ for small θ.

Therefore,

FT = -mgθ

Angular acceleration, α = dω/dt = d2θ/dt2

α = αT/r ∴ αT = rα = rd2θ/dt2

Where,

ω = angular velocity = dθ/dt.

Therefore, we can write:

-mgθ = mαT

-gθ = rd2θ/dt2

Or,

d2θ/dt2 + (g/r)θ = 0

Lagrangian
----------

Tangential velocity, v = rω = rdθ/dt

KE = (1/2)mr2(dθ/dt)2  [ E = Fd]

U = -mgrcosθ

L = KE - U = (1/2)mr2(dθ/dt)2 + mgrcosθ

Euler-Lagrange gives:
.      .
πθ = ∂L/∂θ = mr2θ

∂L/∂θ = -mgrsinθ

dπ/dt - ∂L/∂θ = 0
..
mr2θ + mgrsinθ = 0

d2θ/dt2 + (g/r)sinθ = 0

Hamiltonian
-----------
.
H = πθθ - L
.
= (1/2)mr2(θ)2 - mgrcosθ

= KE + U

To get the equations of motion we need to get the KE
in terms of the angular momentum, L'.

KER = (1/2)Iω2

If we compare this to:

KET = (1/2)mv2

We get:

L' ≡ p, I ≡ m and ω2 ≡ v2

KE = p2/2m => L'2/2I.  But I = mr2.  Therefore,

KE = L'2/2mr2

H = KE + U

= L'2/2mr2 - mgrcosθ

Hamilton's equations are:
.
-∂H/∂q = p
.
∂H/∂p = q

Or, in terms L' and θ:
.
L'/dt = -∂H/∂θ = -mgrsinθ
.
θ = ∂H/∂L' = L'/mr2

So,
..   .
θ = L'/mr2

= -mgrsinθ/mr2

= (-g/r)sinθ

d2θ/dt2 + (g/r)sinθ = 0