8.6 Physics examples 259
In Fig. 8.3 we exhibit the development of the difference between the calculated energy and
the exact energy att= 0 after two periods and withN= 1000 andN= 10000 mesh points. This
figure demonstrates clearly the need of developing tests forchecking the algorithm used. We
see that even forN= 1000 there is an increasing difference between the computed energy
and the exact energy after only two periods.
-3e-11-2.5e-11-2e-11-1.5e-11-1e-11-5e-120
0 2 4 6 8 10 12 14
∆E(t)TN= 1000-3e-15-2.5e-15-2e-15-1.5e-15-1e-15-5e-160
5e-160 2 4 6 8 10 12 14
∆E(t)TN= 10000Fig. 8.3Plot of∆E(t) =E 0 −EcomputedforN= 1000 andN= 10000 time steps up to two periods. The initial
positionx 0 = 1 m and initial velocityv 0 = 0 m/s. The mass and spring tension are set tok=m= 1.