see also Hamiltonian Formalism and Hamilton's Equations
Reading Recommendations
Lagrangian mechanics can be formulated geometrically using fibre bundles.
The Hamiltonian function is defined on the cotangent bundle $T^\star(C)$, which is called phase space.
In contrast, the Lagrangian function is defined on the tangent bundle $T(C)$ of the configuration space $C$.
The map from $T^\star(C) \leftrightarrow T(C)$ is called Legendre transformation.
The phase space is endowed with a symplectic structure, called Poisson Bracket. The Poisson Bracket is an operation that eats two scalar fields $\Phi$, $\Psi$ on the manifold and spits out another scalar field $\theta $:
$$ \theta = \{ \Phi,\Psi \}= \frac{\partial \Phi}{\partial p_a}\frac{\partial \Psi}{\partial q^a}-\frac{\partial \Phi}{\partial q_a}\frac{\partial \Psi}{\partial p^a}.$$
If we leave the $\Psi$ slot blank, we can use the Poisson bracket to define a differential operator $\{\Phi,\ \}$. This is a vector field and when in acts on $\Psi$, we get $\{\Phi, \Psi \}$. If we use instead of $\Phi$, the Hamiltonian $H$, we get an differential operator $\{H,\ \}$ that 'points along' the trajectories on in phase space $T^\star(C)$ and describes exactly the evolution that we get from Hamilton's equations.
In this sense, the dynamical evolution of a given system is completely described by the Hamiltonian (= a scalar function).
a ‘Hamiltonian’ $$H : T^* Q \to \mathbb{R}$$ or a ‘Lagrangian’ $$L : T Q \to \mathbb{R}$$
Instead, we started with Hamilton’s principal function $$S : Q \to \mathbb{R}$$ where $Q$ is not the usual configuration space describing possible positions for a particle, but the ‘extended’ configuration space, which also includes time. Only this way do Hamilton’s equations, like the Maxwell relations, become a trivial consequence of the fact that partial derivatives commute.
https://johncarlosbaez.wordpress.com/2012/01/23/classical-mechanics-versus-thermodynamics-part-2/