  The principle of least action is one of the most fundamental physical
principle. It says that among all possible motions connecting two points in a
phase space, the system will exhibit those motions which extremise an action
functional. Many qualitative features of dynamical systems, such as the
presence of conservation laws and energy balance equations, are related to the
existence of an action functional. Incorporating variational structure into
learning algorithms for dynamical systems is, therefore, crucial in order to
make sure that the learned model shares important features with the exact
physical system. In this paper we show how to incorporate variational
principles into trajectory predictions of learned dynamical systems. The
novelty of this work is that (1) our technique relies only on discrete position
data of observed trajectories. Velocities or conjugate momenta do {\em not}
need to be observed or approximated and {\em no} prior knowledge about the form
of the variational principle is assumed. Instead, they are recovered using
backward error analysis. (2) Moreover, our technique compensates discretisation
errors when trajectories are computed from the learned system. This is
important when moderate to large step-sizes are used and high accuracy is
required. For this, we introduce and rigorously analyse the concept of inverse
modified Lagrangians by developing an inverse version of variational backward
error analysis. (3) Finally, we introduce a method to perform system
identification from position observations only, based on variational backward
error analysis.
