Question: 6) Write a computer program in C to find the motion of a harmonic oscillator using the velocity verlet algorithm. Plot position versus time for
6) Write a computer program in C to find the motion of a harmonic oscillator using the velocity verlet algorithm. Plot position versus time for your numerical solution and for the exact analytic solution. Make a table of the error in the position after 10 seconds of your numerical Lysolution compared to the analytic result for time steps dt of 1, 0.1, and 0.01 seconds. How does the error depend on dt. Also calculate the energy per unit mass after 10 seconds. How does the error in the energy depend on dt? Assume the natural frequency of the oscillator wo=1s and the initial conditions are x(0)=1 m and dx/dt(0)=0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
