Exercise 4.2: computation of
the potential, kinetic, and total energies, and some simple output
diagnostics: initially, just print out the time, the energy
E, and the energy error (E - E0)
note the use of softening in the expression for the potential
energy U: