On a flat background Lagrangians mostly look like

(1)and Hamiltonians look like

(2)where $\mathbf{x}$ is the position vector, $\mathbf{\dot x}$ is its time derivative, $\mathbf{p}$ is the momentum vector, and $\cdot$ represents the standard dot product. On the other hand in a curved background, we have to use the metric to take inner products.

First, we establish a splitting into a time coordinate and three spatial coordinates, and we call the spatial part of the metric $g_{ij} , i,j = 1,2,3$. As usual, we let an overdot denote a derivative with respect to our chosen time coordinate.

So the Lagrangian for a particle moving on a curved background described by the spatial metric $g_{ij}$ and experiencing a potential $V \left( \mathbf{x} \right)$ is

(3)the momentum is given by the 1-form $p_i = g_{ij} \dot{x}^j$, and the Hamiltonian is

(4)Here $g^{ij}$ is defined to be the inverse matrix of $g_{ij}$, so that $g_{ij} g^{jk} = \delta_i^k$ (where we are using Einstein summation convention as always here and $\delta_i^k$ is the Kronecker delta. What we are seeing is just the multiplication of a matrix with its inverse to obtain the identity matrix).