Exercise ODEs

  1. (6 points)

    Implement a Runge-Kutta stepper-routine rkstepN (where N is the order of the method to be used)---wich advances the solution by a step h and estimates the error---using one of the Runge-Kutta methods, for example the midpoint method.

    Implement an adaptive-step-size driver-routine wchich advances the solution from a to b (by calling your rkstepN with appropriate step-sizes) keeping the specified relative, eps, and absolute, acc, precision. Your driver must store the points {xi,yi|i=1,...} it calculated along the way.

    Illustrate that your subroutines work as intended by solving some interesting systems of ordinary differential equations.

  2. (3 points)

    Implement the simplest multistep algorithm---the two-step method---and the corresponding driver. Remember that the first step must be Runge-Kutta.

    Compare it with the your Runge-Kutta method from exercise-A. Comparing here means counting the number of right-hand-side evaluations each of the methods used to achieve the same tolerance. The methods with fewest evaluations wins. (Of course if the routine failed to reach the given tolerance, it is a failure -- ikke bestået.)

  3. (1 point)

    A definite integral

    
    abf(x)dx
    
    can be reformulated as an ODE,
    
    y'=f(x), y(a)=0 : find y(b),
    
    which can be solved with your adaptive ODE solver.

    Implement this idea in a subroutine which calculates definite integrals based on your favourite ODE routine (to be later compared with your dedicated adaptive integrators).

    Calculate some interesting integrals.

  4. (0 points)

    Implement the 2/3-step method. Check that it beats all the other methods you implemented so far.