Fourth Order Runge-Kutta Method

In summary, the high school student is looking for a good method to integrate four differential equations numerically. He has found Fourth Order Runge-Kutta Method to be a good option. However, he is not very comfortable with the final differential equations. He needs help from someone who is more comfortable with these equations.
  • #1
scarllatti
3
0
Hi
As a high school student I was working on an independent project and at last I found final differential equations that I want to integrate them numerically. I read a little bit and found out that Fourth Order Runge-Kutta Method is one of the good methods. By the way could you please help me to do that. I want to write a C++ program to use numerically integrated numbers to simulate something. So could please help me with that. I mean to integrate these four differential equations preferably in C++.
I give one of the four equations as a sample but all of them are in attachment so please refer to attachment to see them.

Û = -(K1 (sin z)^2 + K2 (cos z)^2 + (K1 - K2) * sin z * cos z u

Please help me or give me some advice about how to start.
Thanks very very much
 

Attachments

  • DE.jpg
    DE.jpg
    23.2 KB · Views: 698
Technology news on Phys.org
  • #2
Wiki Runge_Kutta link:

http://en.wikipedia.org/wiki/Runge–Kutta_methods

Issues are covered here:

http://en.wikipedia.org/wiki/Stiff_equation

I described a simple interative trapezoidal predictor-corrector algorithm here:

thread_323921_post_14.htm

also here:

wiki_predictor_corrector_proposed_example.htm

Since the trapezoidal algorithm is a linear approximation for each time step, the time steps still need to be very small for even the iterative algorithm to work. Wiki describes this as a predictor corrector method to implement the second method in this list:

wiki_adams_moulton_method.htm

The iterative process is needed for implict algorithms because the next step value is an input to it's own calculation:

yn+s = ... + f(yn+s, ...)

Wiki mentions this at the top of the multi-step article:

http://en.wikipedia.org/wiki/Multistep_method
 
Last edited:
  • #3


I'd start with getting / borrowing a copy of "Numerical Recipes in C++"

However, the big question here is: do you know what an ODE is, and how you'd go about solving different classes of these by hand? Secondarily, do you have enough exposure to controls to understand what these equations signify?

If not, you may wish to reevaluate your independent project. If you do, hat's off to you!
 
  • #4


What you are trying to do is called "Finite element" methods/analysis. This is a numerical way of projecting a differential equation forward in time by treating its evolution as a number of small discrete steps. I have to say I am impressed that you are tackling such a thing in high school. Ultimately, if you think as a mathematical derivative you think of [itex]=\lim{\Delta \rightarrow 0}\frac{f(x+\Delta x}-f(x)}{x+\Delta x - x}[/itex] however, instead of [itex]\Delta x[/itex] going to zero to get the deriviative, you let it equal a small number and get an approximation to the derivative (i.e. [itex]f(x+\Delta x)=f(x)+\Delta x f'(x)[/itex]). So look up finite element methods and specifically what you want is the Verlet algorithm (it is the most accurate/numerically stable). and you will basically code the differential equation as is replacing the verlet equivalent with the derivatives as needed.
 
  • #5
No, he is not looking for finite element analysis. He is looking for techniques to numerically solve an ordinary differential equation initial value problem. Finite element techniques numerically solve a partial differential equation. There is a huge difference in complexity between ODEs and PDEs.
 
  • #6
D H said:
No, he is not looking for finite element analysis. He is looking for techniques to numerically solve an ordinary differential equation initial value problem. Finite element techniques numerically solve a partial differential equation. There is a huge difference in complexity between ODEs and PDEs.


I guess I'm confused as to what the variables are in your DE's. Is there more than one?
 
  • #7
This is an ODE with four dependent variables: u, v, θ, and ω. There is but one independent variable: Time.
 
  • #8
Let me talk about that project maybe it can help you to really understand what I want to do. I want to mention this is not an school project or related to anything only I became interested in it so I wanted to do some works on it because I really love physics. I became interested in motion of falling papers and leaves so first I did many experiments to conclude some statistics data about fluttering and tumbling in their motion and how are they occur. After that I read some papers about visualizing it so I thought that it is a good idea to do it myself too. I mean I wanted to use the simplified equations that Tanabe and Kaneko used in their paper. So I want to use the equations from their paper. I know what ODEs are and I can solve basic ones too but I am not really mathematically comfortable with the final differential equations that I want to integrate them numerically as their mentioned in their paper.
I attache the paper that I am specifically interested into this reply. I will appreciate if someone can guide me through this process.
Thanks very much
 

Attachments

  • Behavior of a Falling Paper.pdf
    733.1 KB · Views: 261
  • #9
Rather than starting with RK4, or any of the techniques Jeff mentioned in his post, you should start simple. The simplest technique for numerically solving ODEs is Euler's method. A couple of articles:
http://www.ugrad.math.ubc.ca/coursedoc/math100/notes/mordifeqs/euler.html
http://www.swarthmore.edu/NatSci/echeeve1/Ref/NumericInt/Euler1.html

Do a Google search "Euler's method" and you will find tons of online articles. The reason you need to understand Euler's method first is because all of the integration techniques mentioned use Euler's method as a starting point. Note well: Nobody uses Euler's method as an ending point is because it is, by itself, an incredibly lousy technique. Nonetheless, understanding Euler's method is critical for understanding more advanced techniques.
 
  • #10
The trapezoidal predictor corrector alogrithm improves Euler in two ways. First is using the average of the slopes at the current and next step. Second, iteration using the estimated next step value as an input provides feedback and will (normally) converge to a specific value, similar to Newtons root finding method (except the first guess is a given known good value):

initialize:
ynext = ycurrent

then iterate:
ynext = ycurrent + 1/2 (y'(ycurrent) + y'(ynext))

for some number of steps (6 to 16). ynext will converge after a reasonable number of steps if Δt is small enough.

The initialize and first iteration are essentially Euler

ynext = ycurrent + (y'(ycurrent))

but there's no need to code anything other than the trapezoidal (slope averaging) iteration step, after setting ynext = ycurrent.

4th order Runge-Kutta includes two weighted mid-point estimates, but Δt can just be halved to accomplish a similar thing. I doubt that complex algorithms designed to minimize computation time are actually needed much with the speeds of computers, including PC's these days.

I made an example Excel spreadsheet that shows this method used to solve y'=e-15y, with initial value y=1 at t=0, so y=e-15t. This is an example of a stiff equation that some numerical integration methods have issues with.

http://jeffareid.net/misc/numerical_integration.zip

A convergence test can be optionally added to the iteration loop from above:

iteration with convergence test:
yprev = ynext
ynext = ycurrent + 1/2 (y'(ycurrent) + y'(ynext))
if( | ynext - yprev | < tolerance ) early exit
 
Last edited:
  • #11
I think one question that needs to be asked is "How accurate do you want to be?" MatlabDude set you onto the right website, www.nr.com (Numerical Recipes). Also, if you need to solve systems which most of the time you will since all higher order ODE's can be represented by a system of single order ODE's the implementation can be difficult and the NR guys already got it all figured out. (For the most part) Also, if the system is considered to be "Stiff" you will need much more advanced algoritms than RK4. For instance, Simi-implicit Euler. Also, you need to have the ability to automatically adapt the time stepping. This too is done by the NR guys.

Check out that resource, I live by it.

Thanks
Matt
 

1. What is the Fourth Order Runge-Kutta Method?

The Fourth Order Runge-Kutta Method is a numerical method used for solving ordinary differential equations. It is a widely used method for approximating the solution of differential equations in various fields such as physics, engineering, and economics.

2. How does the Fourth Order Runge-Kutta Method work?

The method works by taking small steps and using a weighted average of four different estimates of the solution at each step. These estimates are obtained by evaluating the differential equation at different points within the step.

3. What are the advantages of using the Fourth Order Runge-Kutta Method?

One major advantage is that it is more accurate than other numerical methods like Euler's method. It also has a higher order of convergence, meaning it can achieve a more accurate solution with fewer steps.

4. What are the limitations of the Fourth Order Runge-Kutta Method?

One limitation is that it can be computationally expensive, especially for complex and high-dimensional systems. It also requires a relatively small step size to achieve accurate results, which can be time-consuming.

5. In what situations is the Fourth Order Runge-Kutta Method commonly used?

The method is commonly used in situations where the differential equations cannot be solved analytically, but a numerical solution is needed. It is also useful for simulating and predicting the behavior of systems in various fields such as physics, engineering, and finance.

Similar threads

  • Programming and Computer Science
Replies
15
Views
2K
  • Programming and Computer Science
Replies
8
Views
2K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
13
Views
2K
  • Programming and Computer Science
Replies
4
Views
6K
  • Programming and Computer Science
Replies
7
Views
2K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
4
Views
4K
Replies
9
Views
2K
  • Programming and Computer Science
Replies
5
Views
2K
Back
Top