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

  • Thread starter maistral
  • Start date
  • #1
209
10

Main Question or Discussion Point

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:

Answers and Replies

  • #2
209
10


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:
  • #3
AlephZero
Science Advisor
Homework Helper
6,994
291


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.
 
  • #4
209
10


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.
 
  • #5
Filip Larsen
Gold Member
1,256
183


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.
 
  • #6
35
0


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.
 
  • #7
AlephZero
Science Advisor
Homework Helper
6,994
291


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.
 
  • #8
209
10


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.
 

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

Replies
3
Views
2K
Replies
18
Views
1K
Replies
4
Views
2K
Replies
2
Views
684
  • Last Post
Replies
16
Views
4K
Replies
1
Views
672
  • Last Post
Replies
5
Views
13K
  • Last Post
Replies
7
Views
4K
Top