  Hamiltonian matrices appear in a variety or problems in physics and
engineering, mostly related to the time evolution of linear dynamical systems
as for instance in ion beam optics. The time evolution is given by symplectic
transfer matrices which are the exponentials of the corresponding Hamiltonian
matrices. We describe a method to compute analytic formulas for the matrix
exponentials of Hamiltonian matrices of dimensions $4\times 4$ and $6\times 6$.
The method is based on the Cayley-Hamilton theorem and the Faddeev-LeVerrier
method to compute the coefficients of the characteristic polynomial. The
presented method is extended to the solutions of $2\,n\times 2\,n$-matrices
when the roots of the characteristic polynomials are computed numerically. The
main advantage of this method is a speedup for cases in which the exponential
has to be computed for a number of different points in time or positions along
the beamline.
