Errors in Adaptive Runge Kutta Method?

  • Context: Graduate 
  • Thread starter Thread starter gradnu
  • Start date Start date
  • Tags Tags
    Method Runge kutta
Click For Summary

Discussion Overview

The discussion revolves around issues encountered while using an adaptive stepsize Runge Kutta (order 4) method to solve a set of Lotka Volterra equations. Participants explore potential causes of errors related to step size and the number of steps in the numerical integration routine.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant reports errors indicating that the step size is too small and there are too many steps in the routine.
  • Another participant suggests that the issues may stem from the implementation of the adaptive stepsize Runge Kutta method rather than the mathematics itself, emphasizing the importance of understanding the software's limitations.
  • A different viewpoint highlights that the adaptive RK method may involve a fifth-order integrator for error checking, and suggests that errors could arise from incorrectly formulated derivative functions or from dealing with stiff systems.
  • One participant notes that the code from Numerical Recipes works for small limits of integration but fails with larger intervals, indicating a potential issue with the range of integration.
  • Another participant agrees that the problem is likely software-related and encourages the original poster to understand the code better and research the RK method.
  • A further contribution points out that the user must supply a function for computing derivatives, and if this function is incorrect, it could lead to failures or incorrect results. The importance of customizing the Numerical Recipes code to the specific problem is also mentioned.

Areas of Agreement / Disagreement

Participants generally agree that the issues are related to software implementation rather than purely mathematical problems. However, there are differing opinions on the specific causes of the errors and the best approach to resolve them.

Contextual Notes

Participants mention limitations related to the precision of floating-point calculations and the necessity of customizing the Numerical Recipes routines for specific problems. There is also an acknowledgment of potential issues with stiff systems and the formulation of derivative functions.

gradnu
Messages
21
Reaction score
0
Hi
I am using adaptive stepsize Runge Kutta (order4) method to solve a set of Lotka Volterra system of equations.

But I am getting the errors
1) Step size too small
2) Too many steps in the routine

Can somebody please help me on this.
 
Physics news on Phys.org
This has nothing to do with mathematics! Also, you aren't using" adaptive stepsize Runge Kutta"- you are running a particular implementation of it and the difficulties are that of the implementation.
It would seem obvious from the second "error message" that their is a limit ion how many steps you can use in whatever program you are using. Of course, since the stepsize is the length of the interval divided by number of steps, using too many steps will cause the stepsize to be too small.
Do you have the documentation for your software? Is there a limit on how many steps you can use? If so, make sure your number of steps is below that limit. If not, try smaller numbers of steps until you don't get those error messages. The move it back up to find the limit.
 
HallsofIvy said:
This has nothing to do with mathematics!

You purists! Of course it does. Applied mathematics is a very important part of mathematics.

Back on topic:
First, you are using something in addition to fourth-order RK. For example, an RK4/5 adaptive step size integrator uses a fifth order RK integrator to act as a check on the fourth order integrtor. The step size is adjusted to make the fifth order integrator more-or-less agree with the fourth order integrator. Too little agreement and the step size is reduced; too much and the step size is increased.

Two possible causes of the error:
  • You formulated the derivative function incorrectly. This can make the integrator try to find a numerical solution to an insoluble problem.
  • The problem is inherently stiff. Adaptive RK integrators fare poorly against stiff systems.
 
Thanks for the prompt replies.
I am using the code in 'C' from numerical recipes.
It works for small limits of integration but starts giving errors if I increase the interval of integration.
 
I agree with Hall's this is not a math problem, it is a software problem.

You have the code, do you not understand it? Seems like it is time to read through the code with the goal of understanding exactly what it is doing. That may mean doing some research on the RK method. This will also be an opportunity to improve your C skills.

You should be able to find in the code what the limits on your step size and number of steps is. You can then use the software as the programmer intended.
 
You are not merely using the Numerical Recipes code. This code requires the user to supply a function that computes the total derivatives of the state vector components. If this function is wrong the NR code will either give incorrect result or will simply fail. That user-written function (i.e., your function) is the first thing you should deem as suspect.

This disclaimer in Numerical Recipes in C section 16.2 is pertenant: "The routine odeint should be customized to the problem at hand". The Numerical Recipes routines use single-precision floating point unless modified. Unless modified (and you need to do this with extreme care), trying to push the precision beyond the capability of single-precision will fail.
 
I apologize for posting the problem in Diff. Eq. section.
Thanks D H for the suggestions.
 

Similar threads

  • · Replies 65 ·
3
Replies
65
Views
8K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
7K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K