Wolfram Alpha:

```Hamiltonian Formulation
-----------------------

Phase space refers to the plotting of particle's
momentum and position on a 2 dimensional graph.

t                    p
| State space        |  Phase space
|                    |
| Lagrange           |  Hamilton
|                    |
|_______ q           |_________ q

The Hamiltonian formulation specifies mechanics in
terms of coordinates (p,q) rather than (x,y) (Newton)
and (q,dq/dt) (Lagrange).  In other words, Hamilton's
equations explain the flow through phase space.  The
Hamiltonian formulation is very elegant and is of
fundamental importance in most formulations of quantum
theory.

The Hamiltonian (H) can be obtained from the Lagrangian
(L) by performing a LEGENDRE transformation.
.
Consider 2 the variables, p and q which are singled
valued functions of each other and define:
functions such that
.
L(q) and H(p)

p
|
p'......
|     /'
|  H / .
|   /  .
|  /   .
| / L  .
|/     '       .
------------- q
.
q'
.       .  .           .
Area of L(q) = ∫p(q)dq from 0 to q
.
Area of H(p) = ∫q(p)dp from 0 to p
.           .
H + L = p'q' or H = p'q' - L

Now consider small change in H,  Therefore,
after dropping the primes):
.    .           .   .
δH = Σ[piδqi + qiδpi - (∂L/∂qi)δqi - (∂L/∂qi)δqi]
i
The last term is a consequence of the fact that
the Lagrangian is a function of both q and dq/dt.
.
Since pi = ∂L/∂q, terms 1 and 3 are equivalent
and cancel, we get:
.
δH = Σ[qiδpi - (∂L/∂qi)δqi]
i
Recall that the general rule for a small
change in a function of several variables is:
.                           .  .
δH(qi,pi) = (∂H/∂pi)δpi + (∂H/∂qi)δqi

By comparison,
.
∂H/∂pi = qi and ∂H/∂qi = -∂L/∂qi

Now from the E-L equations, the second term is
the time derivative of the canonical momentum:
.     .
∂L/∂qi = d/dt(∂L/∂qi) = pi

so we can write,
.
-∂H/∂qi = pi

and
.
∂H/∂pi = qi

These are HAMILTON's equations.  The energy of the
system is described by the Hamiltonian, H, which
is defined as,
.
H = pq - (T - U)
. .         .
= (mq)q - (1/2)mq2 + U
.          .
= mq2 - (1/2)mq2 + U
.
= (1/2)mq2 + U

= T + U

Example 1.

H = T + U

= p2/2m + U(x)
.
= m2x2/2m + U(x)
.
= mx2/2 + U(x)

∂H/∂x = dU/dx

= F (by definition, U = F*d)

= ma

= mdv/dt
.
= p
.
∂H/∂p = p/m = x

Example 2.  Harmonic Oscillator

x
|  \
|  /
|  \  <-- spring
|  /
|  \
|  m
|_________

.
H = T + U = (1/2)mx2 - (k/2)x2

= (1/2)p2/2m - (k/2)x2
.
∂H/∂x = p = -kx
.
∂H/∂p = x = p/m
.
so p = mx
.    ..
Now p = mx

= F

= -kx

Let x = cosωt
.
x = -ωsinωt
..
x = -ω2cosωt = -ω2x

-k/mx = -ω2x

=> ω = √(k/m)

Poisson Brackets
----------------

Poisson Brackets are another formulation of
classical mechanics.

Consider any function of momentum, p, and position, q,
f(p,q).  Using the Chain Rule we get:

df(p,q)/dt = Σ{(∂f/∂pi)(dpi/dt) + (∂f/∂qi)(dqi/dt)}
i
Substitute Hamiltons equations into this formula
to get:

df(p,q)/dt = Σ{(∂f/∂qi)(∂H/∂pi) - (∂f/∂pi)(∂H/∂qi)}
i
This is written as {f,H}

Therefore, {f,H} is equivalent to df/dt.  If df/dt = 0
then f is conserved.  For example, if f = H then:

dH/dt = Σ(∂H/∂qi)(∂H/∂pi) - (∂H/∂pi)(∂H/dqi) = 0
i

This means that energy is conserved as long as
there is no explicit appearance of time in the
Hamiltonian.  Another way of saying this is that
the motion of a particle through phase space lies
on a surface of constant energy as the system
evolves with time.

NOTE:  THE POISSON BRACKETS ARE NOT THE SAME AS
THE ANTI-COMMUTATOR.  POISSON BRACKETS ARE THE
ANALOG OF THE COMMUTATOR FOUND IN QUANTUM MECHANICS.

In general:

{A,B} = Σ{(∂A/∂qi)(∂B/∂pi) - (∂A/∂pi)(∂B/∂qi)}
i
With properties,

{A,B} = -{B,A}

{qi,qj} = {pi,pj} = 0

{qi,pj} = δij

Proof:

{qi,pj} = (∂qi/∂qi)(∂pj/∂pi) - (∂qi/∂pi)(∂qj/∂qi)

= (∂qi/∂qi)(∂pj/∂pi)

= ∂pj/∂pi

= 1 when i = j, 0 otherwise.

{pi,f} = -∂f/∂qi

{qi,f)} = ∂f/∂pi

{αA,B} = α{A,B}

{A + C,B} = {A,B} + {C,B}

{AB,C} = A{B,C} + B{A,C}

Examples:

A = qi
.
q = {qi,H}

= [(∂qi/∂qi)(∂H/∂pi) - (∂qi/∂pi)(∂H/∂qi)]

= ∂H/∂pi

and A = pi
.
pi = {pi,H}

= [(∂pi/∂qi)(∂H/∂pi) - (∂pi/∂pi)(∂H/∂qi)]

= -∂H/∂qi

These are Hamilton's equations.
```