

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Write a program to integrate any number of coupled differential equations using the Euler method, fourth-order Runge-Kutta, and Leapfrog (note: Leapfrog only applies to special cases). You will be using this program in a future assignment, so make sure it’s well docu- mented. Use double precision throughout.
d^2 x dt^2
with initial conditions x(0) = 1, ˙x(0) = 0. Note the analytical solution is x = cos(t).
(a) Integrate the equation for 0 ≤ t ≤ 15 using each of the methods, and stepsizes of 1, 0.3, 0.1, 0.03, and 0.01. (b) Plot your integration results against the analytical solution for each case. (Hint: do all the Euler plots on one page, with one plot per timestep; then all the Leapfrog plots on another page, etc.) Comment on the results. (c) Plot log |xnumerical(15) − xexact(15)| as a function of log(stepsize) in each case and comment. (Hint: does the error have the expected dependence on the stepsize? Remember you’re integrating over many steps, not just one.
1 + αx^2 + βy^2
where we are assuming unit mass for the particle in this potential. Show analytically that the orbit is given by the coupled differential equations:
d^2 x dt^2
αx (1 + αx^2 + βy^2 )^3 /^2
d^2 y dt^2
βy (1 + αx^2 + βy^2 )^3 /^2
and then reduce these to 4 coupled first-order equations.
(a) Integrate this system for α = 2, β = 2, and 0 ≤ t ≤ 100, with the initial conditions x = 1, y = 0, ˙x = 0, y˙ = 0.1. Try this with Leapfrog and Runge-Kutta, and stepsizes of 1, 0.5, 0.25, and 0.1. Plot x vs. y for these integrations. (b) Plot the energy E = ( ˙x^2 + ˙y^2 )/2+Φ(x, y) as a function of time for your integrations and comment. (c) Explore the behaviour for different choices of α and β and comment (no need to include any plots).
x˙ = Ax − Bxy − dx y ˙ = −Cy + Dxy − ey
where x is the prey density (rabbits), y the predator density (foxes), A = 1 (rabbit reproduction rate), B = 0.1 (rabbit consumption rate by foxes), C = 1.5 (fox death rate by natural causes), D = 0.03 (fox population growth rate due to consumption of rabbits), and d = e = 0 (hunting rate of foxes and rabbits, respectively). Use only your Runge-Kutta integrator, with t = 0 to 100 and timesteps of 1, 0.5, 0.25, and 0. to solve this system, starting with x = 30 and y = 3. If d = e = q, for roughly what value of q do both populations drop below 10−^9 by t = 100 for a timestep of 0.1?