A general approach to linear and non-linear dispersive waves using a Lagrangian | Synapse