# I need a little help on how does the iteration process. I know how

• maistral
In summary, the conversation is about the Fehlberg method of iteration and its use in solving differential equations. The method requires two iterations and involves a scaling factor, and the question is raised about how to determine the new value of the step size and the level of accuracy achieved with a given tolerance. The conversation also touches on the use of adaptive step size control and interpolation for better performance.

#### maistral

I need a little help on how does the iteration process. I know how Runge-Kutta 4 works, but I don't know how this Fehlberg one does.

So apparently the iteration goes like this:
http://math.fullerton.edu/mathews/n2003/rungekuttafehlberg/RungeKuttaFehlbergMod/Images/RungeKuttaFehlbergMod_gr_2.gif [Broken]

Then apparently, the scheme requires two iterations; first would be
http://math.fullerton.edu/mathews/n2003/rungekuttafehlberg/RungeKuttaFehlbergMod/Images/RungeKuttaFehlbergMod_gr_3.gif [Broken]

The second would be
http://math.fullerton.edu/mathews/n2003/rungekuttafehlberg/RungeKuttaFehlbergMod/Images/RungeKuttaFehlbergMod_gr_4.gif [Broken]

My question is: what the freaking hell is this lol
http://math.fullerton.edu/mathews/n2003/rungekuttafehlberg/RungeKuttaFehlbergMod/Images/RungeKuttaFehlbergMod_gr_5.gif [Broken]

As far as I understand this s thing is supposed to correct the value for h, given a value of ε.

My question are,
(1) How do I get the new value of h?
(2) Isn't this the value of h to be used in the next iteration, since I read from some texts that h is to be modified such that given a differential equation that doesn't behave very well, it's for accuracy purposes?
(3) Further, how does the value of ε really work? I know I have to enter the value of ε, and it apparently assigns the degree of accuracy, or so I've heard. But I want to understand this, really. Say for example, my tolerance is 0.84. How different is this from using a tolerance of 0.5? More accurate or less accurate?

This isn't an assignment guys, I just want something new instead of the old RK4 method that requires ridiculously small stepsizes to retain significant accuracy vs. indecently behaving equations. Needless to say, I've been using RK4 blindly with epicly small setpsize just to make sure that I get an accurate answer (which is fairly pathetic).

Thanks and more power guys! :)

Last edited by a moderator:

I got a few stuff running in mind now, and if I'm correct, s is a scaling value;
Hnew = s * Hold; Xnew = s * Xold

My question now is this. If I continue to follow this method, my stepsize would surely continue to change assuming my function is rather ugly.

If this happens, if I assume initial values of x = 0, y = 1, and if x = 100 as the final x value, will I still end up with the exact value of x = 100 and y = whatever even if my stepsize keeps on changing? Thanks!
EDIT:

What I mean is, say for example I iterated a certain differential equation from x = 0 to x = 100. What I'm thinking is, say I'm at x = 99.72, but because of certain things, my stepsize became h = 0.45. That would cause me to get a value for x = 100.17, which is definitely not x = 100.

Or am I missing something?

Last edited:

maistral said:
I got a few stuff running in mind now, and if I'm correct, s is a scaling value;
Hnew = s * Hold; Xnew = s * Xold
Hnew = s * Hold look right, but I'm not sure why you want to do Xnew = s * Xold (but you haven't defined Xnew and Xold anywhere in your posts)
My question now is this. If I continue to follow this method, my stepsize would surely continue to change assuming my function is rather ugly.

If this happens, if I assume initial values of x = 0, y = 1, and if x = 100 as the final x value, will I still end up with the exact value of x = 100 and y = whatever even if my stepsize keeps on changing? Thanks!
If the final step would take you past x = 100, just reduce the final step to take you to exactly x = 100.

Often this doesn't matter. For example if you just want to plot the function, you can set the limits of the X axis of the plot to 0 and 100 and let the graphics software truncate the last line segment.

If does matter if you are integrating a function like sqrt(100 - x) that isn't even defined for x > 100.

Actually, you might want to adjust the step BEFORE the last one, if the last step would be a lot shorter than the previous steps. For eaxmple if the step size is about 1 and the last-but-one step would take you to x = 99.999, you might want to take 2 steps of about 0.5 each, rather than 1 and then 0.001.

Argh, nevermind, I give up. This method won't help me because I just realized that I would have to interpolate for such event, which is something I'm deliberately evading.

For generating tabular data with fixed interval of the independent variable (e.g. time) you should know that there exists methods that utilize the evaluations of the field made during an RK step to make interpolations with very few (or none, if I remember correct) extra evaluations. You will usually get much better performance (i.e. better global solution accuracy for a given computational effort) using an adaptive RK method with interpolation than with a fixed-step method without interpolation, but of course, the later is much simpler to implement.

Do you want to implement RKF? Why? Use ode45 in Matlab, which is RKF. There you have step size control and everything. (RK with fixed step size is just for academic considerations suitable. In practice, fixed step sizes are horror.) Additionally, if you have problems with an explicit solver like RKF use an implicit one like ode15s.

Filip Larsen said:
You will usually get much better performance (i.e. better global solution accuracy for a given computational effort) using an adaptive RK method with interpolation than with a fixed-step method without interpolation, but of course, the later is much simpler to implement.

You will usually get orders of magnitude better performance than RK (with or witout step size control) from a method that is a better match to the ODE you are solving.

The one big advantage of RK is that it rarely gives "plasubile looking but wrong" answers. When if blows up, it usually blows up big time. But it has the same defect as most finite difference methods of higher order than the ODE you are solving; the solution of the difference equations contains solutions that are NOT approximations to any solution of the ODE, and for steps bigger than some limit they are usually unstable. Step size control suppresses the symptoms, but it doesn't cure the disease.

RK is a good method for solving equations with a small number of degrees of freedom (e.g. one!) when it's not worth investing any effort to find a better way, but it's not good for much else IMO.

Unstable said:
Do you want to implement RKF? Why? Use ode45 in Matlab, which is RKF. There you have step size control and everything. (RK with fixed step size is just for academic considerations suitable. In practice, fixed step sizes are horror.) Additionally, if you have problems with an explicit solver like RKF use an implicit one like ode15s.

I actually have a programmable calculator for use, I just want it to have all the stuff I need. That's why I attempted to implement RKF. However I am deliberately evading interpolation, because, even though a weird reason, it gives me the hassle of interpolating everytime i need an answer for some value which is what I really don't like.

I however still wanted to pull out RKF45 properly, however my values explode to gazillions after trying to replicate it in Excel. God I'm horrible. I'm trying to practice now, but if I can't still pull it off correctly I might need your help guys.

## 1. How does the iteration process work?

The iteration process is a method used in problem-solving, where a set of instructions or operations are repeated multiple times until a desired result is achieved. It involves breaking down a complex problem into smaller, more manageable steps which are then repeated until the desired outcome is reached.

## 2. What are the benefits of using iteration in problem-solving?

Using iteration allows for a systematic approach to problem-solving, making it easier to identify and fix errors. It also helps to improve efficiency and accuracy, as the same set of instructions are repeated until the desired result is achieved.

## 3. How do you know when to stop the iteration process?

The iteration process can be stopped when the desired outcome is reached, or when a predetermined number of iterations has been completed. In some cases, there may be specific conditions or criteria that need to be met before the process can be stopped.

## 4. Can the iteration process be used for all types of problems?

While the iteration process can be used for a wide range of problems, it may not be the most efficient or effective method for certain types of problems. It is best suited for problems that can be broken down into smaller steps and have a clear end goal.

## 5. Are there any alternatives to the iteration process?

Yes, there are other problem-solving methods such as trial and error, heuristics, and algorithms. These methods may be more suitable for certain types of problems, and it ultimately depends on the nature of the problem and the preferences of the problem solver.