Hamiltonian in Cartesian Coordinates

This section provides a quick introduction on Hamiltonian for a single object in Cartesian coordinates.

In previous sections, we have discussed Hamiltonian with position, velocity, acceleration and momentum as scalar values, which is valid only if the object is moving in a 1-dimensional straight line.

Now, let's re-define Hamiltonian for a single object moving a 3-dimensional space using Cartesian coordinates.

First the position of an object as a function of time can be expressed as a vector function, r(t):

```r(t) = (x(t), y(t), z(t))

or:
r = (x, y, z)                    (H.7)
r = (rx, ry, rz)                  (H.8)
```

The velocity becomes a vector function of time, v(t):

```v = dr/dt
= (drx/dt, dry/dt, drz/dt)

or:
v = r'                           (H.9)
# r' is a shorthand notation of first order derivative
```

The acceleration becomes a vector function of time, a(t):

```a = dv/dt
= (dvx/dt, dvy/dt, dvz/dt)
= (d2x/dt2, d2y/dt2, d2z/dt2)

or:
a = v'
a = r"
# r" is a shorthand notation of second order derivative
```

The momentum also becomes a vector function of time, p(t):

```p = m*v
p = m*r'
```

Hamiltonian as a Function of (r,r')

Now let's look at the Hamiltonian function in Cartesian coordinates. And express it in terms of r and r':

```H = T + V                          (H.1)
```

The kinetic energy part can be expressed in terms of r'

```T = 0.5*m*|r'|2                   (H.10)
```

The potential energy part can be expressed in terms of r:

```V = V(r)                          (H.11)
```

So the Hamiltonian can be expressed in terms of r and r' as:

```H = T + V                         (H.1)

or:
H = 0.5*m*|r'|2 + V(r)          (H.12)
# H.10 and H.11 applied
```

Hamiltonian as a Function of (r,p)

We can also transform Hamiltonian to a function of position r and momentum p:

```H = 0.5*m*|r'|2 + V(r)            (H.12)

or:
H = 0.5*|p|2/m + V(r)           (H.13)
# since p = m*r'
```