Definition (Hamiltonian)
Define the Hamiltonian as $$ \begin{align*} H(\v q, \v p, t) = \sup_{\dv q} \left[\v p\cdot\dv q - L(\v q,\dv q,t)\right], \end{align*} $$ i.e. the Legendre transform of the Lagrangian $L(\v q, \dv q, t)$ with respect to the generalised velocity $\dv q$.
$\v p$ is called the generalised momentum. $(\v q,\v p)$ is called a conjugate pair.
Assuming the convexity of $L$ with respect to $\dv q$, the Hamiltonian is $$ \begin{align*} H(\v q,\v p,t) = \v p\cdot \dv q - L(\v q,\dv q, t)\qquad \text{with $\dv q$ such that } p_i = \pdfd{L}{\dot q_i}. \end{align*} $$