  The Weak-form Sparse Identification of Nonlinear Dynamics algorithm (WSINDy)
has been demonstrated to offer coarse-graining capabilities in the context of
interacting particle systems (https://doi.org/10.1016/j.physd.2022.133406). In
this work we extend this capability to the problem of coarse-graining
Hamiltonian dynamics which possess approximate symmetries associated with
timescale separation. Such approximate symmetries often lead to the existence
of a Hamiltonian system of reduced dimension that may be used to efficiently
capture the dynamics of the symmetry-invariant dependent variables. Deriving
such reduced systems, or approximating them numerically, is an ongoing
challenge. We demonstrate that WSINDy can successfully identify this reduced
Hamiltonian system in the presence of large intrinsic perturbations while
remaining robust to extrinsic noise. This is significant in part due to the
nontrivial means by which such systems are derived analytically. WSINDy also
naturally preserves the Hamiltonian structure by restricting to a trial basis
of Hamiltonian vector fields. The methodology is computational efficient, often
requiring only a single trajectory to learn the global reduced Hamiltonian, and
avoiding forward solves in the learning process. Using nearly-periodic
Hamiltonian systems as a prototypical class of systems with approximate
symmetries, we show that WSINDy robustly identifies the correct leading-order
system, with dimension reduced by at least two, upon observation of the
relevant degrees of freedom. We also provide a contribution to averaging theory
by proving that first-order averaging at the level of vector fields preserves
Hamiltonian structure in nearly-periodic Hamiltonian systems. We provide
physically relevant examples, namely coupled oscillator dynamics, the
H\'enon-Heiles system for stellar motion within a galaxy, and the dynamics of
charged particles.
