I\'m trying to develop a physics simulation and I want to implement a fourth-order symplectic integration method. The problem is that I must be getting the math wrong, since my
I am in the field of accelerator physics (synchrotron light sources), and in modelling electrons moving through magnetic fields, we use symplectic integrators on a regular basis. Our basic workhorse is a 4th order symplectic integrator. As noted in the comments above, unfortunately these codes are not so well standardized or easilly available.
One open source Matlab based tracking code is called Accelerator Toolbox. There is a Sourceforge project called atcollab. See a messy wiki here https://sourceforge.net/apps/mediawiki/atcollab/index.php?title=Main_Page
For the integrators, you can look here: https://sourceforge.net/p/atcollab/code-0/235/tree/trunk/atintegrators/ The integrators are written in C with MEX link to Matlab. Because the electrons are relativistic the kinetic and potential terms look a little different than in the non-relativistic case, but one can still write the Hamiltonian as H=H1+H2 where H1 is a drift and H2 is a kick (say from quadrupole magnets or other magnetic fields).