Question: Exercise taken from Paul L DeVries - A first course in computational physics ( 1 9 8 4 ) . Please create a . f

Exercise taken from Paul L DeVries - A first course in computational physics (1984). Please create a .f95 program for this exercise.
EXERCISE 5.3
Use the modified Euler method with a time step of 0.1 to solve the "mass on a spring" problem, and present your results in a plot similar to Figure 5.4. How well is the energy conserved?
It might seem that a numerical method that preserves constants of the motion is inherently "better" than one that does not. Certainly, the improved and modified Euler methods are to be preferred over the simple Euler method. But this preference is derived from improvements made in the algorithm, as verified by the computation of constants of the motion, not because the constants were guaranteed to be preserved.
It is possible to construct an algorithm that preserves constants of the motion. For example, consider the mass-on-a-spring problem. We might use the simple Euler expression to determine position,
x(t0+)=x(t0)+dxdt|t0|=x(t0)+v(t0)
and determine the velocity by requiring that
E=mv22+kx22
This will give us the magnitude of the velocity, and we could obtain its sign by requiring it to be the same as that obtained from the expression
v(t0+)=v(t0)+dvdt|t0|=v(t0)-x(t0)
Runge-Kutta Methods
This algorithm is absolutely guaranteed to conserve energy, within the computer's ability to add and subtract numbers. But how good is it otherwise?
 Exercise taken from Paul L DeVries - A first course in

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!