Learn Runge-Kutta for Solving Differential Equations

  • Thread starter saltydog
  • Start date
In summary, Salty has been working on creating an Euler-based approximation for Runge-Kutta to solve an IDE. He has been making progress and has been able to improve the approximation with smaller delta t. However, he feels that he needs to perfect a more accurate numerical approach before studying coupled equations over long periods.
  • #1
saltydog
Science Advisor
Homework Helper
1,591
3
I'd like to learn how to use Runge-Kutta to solve IDEs. My understanding is that this technique can be used for the following:

[tex]\frac{dy}{dt}=F(t,y)+\int_0^t G[t,s,y(s)]ds[/tex]

So I start with the following simple version:

[tex]\frac{dy}{dt}=ay-by^2+K\int_0^t y(s)ds[/tex]

This is a good start because this equation can be differentiated to yield:

[tex]y(y^{''})=(y^{'})^{2}-by^{'}y^{2}+Ky^3[/tex]

with:

[tex]y^{'}(0)=ay(0)-b[y(0)]^2[/tex]

And so I can numerically solve the resulting ODE to get a precise answer that I can check against the Runge-Kutta version. Well, my results aren't "close" enough. I've included two plots: The first plot is the Runge-Kutta (dark line) against the ODE solution. The second plot gives the absolute difference between the two. The third plot is the back-substitution of the numerical results of the ODE back into the IDE. As you can see, the values are no more than [itex]10^{-5}[/itex] which is close.

However, the difference between the ODE results and Runge-Kutta of the IDE is the same type even with smaller increments of t and different values of a and b and K.

Perhaps I'm implementing Runge-Kutta incorrectly. Can anyone give me suggestions?

Thanks,
Salty
 

Attachments

  • ideplot1.JPG
    ideplot1.JPG
    5.2 KB · Views: 378
  • ideplot2.JPG
    ideplot2.JPG
    5.1 KB · Views: 352
  • ideplot3.JPG
    ideplot3.JPG
    4.8 KB · Views: 353
Last edited:
Physics news on Phys.org
  • #2
Ok, I'm making progress: Instead of using Runge-Kutta, I've dropped back to just trying an Euler approximation first (still wish a Runge-Kutta).

To the value of the slope calculated by the Euler method, I just add the running value of the developing integral (calculated at each increment of t). This gives me a better approximation which improves with smaller increment in t. Using the function calculated by the Euler method, I determine the LHS and RHS of the IDE and take the absolute value of the difference. The attached plot shows one such run for delta t set at 0.001. As you can see, the difference is not greater than 0.001.

I'm not doing something right with Runge-Kutta else I'd expect a better match to the actual result.
 

Attachments

  • eulerIDE.JPG
    eulerIDE.JPG
    4.9 KB · Views: 381
  • #3
I made a change to the Euler method I'm using to evaluate the IDE. I've attached a comparison plot of the solution calculated by the ODE and a solution calculated directly from the IDE using a modified Euler method. As you can see, the plots overlap nicely but the Euler method is still not precise enough as seen by the back substitution into the IDE. The second plot shows the difference: LHS-RHS of the IDE. Some values are as large as [itex]10^{-3}[/itex] with delta t set at [itex]10^{-3}[/itex]. A slight improvement is obtained with smaller delta t.

Really I'd like to perfect a very accurate numerical approach as I'd like to study some coupled equations over long time periods. The on-line resource is lacking. If no one has an idea, I'll just jump in my truck next week and try the old-fashioned approach: go to the library.
 

Attachments

  • combo1.JPG
    combo1.JPG
    4.2 KB · Views: 374
  • idedif.JPG
    idedif.JPG
    4.2 KB · Views: 346
  • #4
I think I may have a working Runge-Kutta method to solve this IDE. Using the technique I designed for the Euler method, I carried over to the Runge-Kutta method. Really, the Runge-Kutta is a version of Euler in which a weighted average of 4 slopes are calculated as opposed to one. Using the same equation with step size of 0.001 in the interval of (0,20), I was able to lower the difference of the LHS-RHS of the IDE to [itex]10^{-7}[/itex]. The attached plot shows this difference.

Really, I need to experment with different IDEs to see how the error varies and also still need to compare my method with whatever published methods are available. It's a nice ride to the campus.
 

Attachments

  • RKdiff1.JPG
    RKdiff1.JPG
    5.6 KB · Views: 387
  • #5
I've been working with:

[tex]y^{'}=ay-by^{2}-y(1+t)\int_0^ty(s)ds [/tex]

Interesting that this one can also be differentiated yielding the very impressive looking:

[tex]y^2y^{'''}-y^{''}(3yy^{'}-by^{3})+2(y^{'})^{3}=-(1+t)y^{3} y^{'}-2y^{4}[/tex]

Mathematica solves this easily and again I can compare this with my numerical results for the IDE.

I've only looked at it using an Euler method with ok results (within [itex]10^{-3}[/itex] for 0.01 step size.

I'll convert it to Runge-Kutta and also begin looking at IDEs which can't be so nicely differentiated such as those with kernels that can't be eliminated by differentiation. That (and systems) is really why I want to have a good numerical method.
 

Related to Learn Runge-Kutta for Solving Differential Equations

1. What is Runge-Kutta method?

The Runge-Kutta method is a numerical technique used to solve ordinary differential equations. It is an iterative process that involves calculating intermediate values to approximate the solution at a given point.

2. Why is Runge-Kutta method important?

The Runge-Kutta method is important because it allows scientists and engineers to solve differential equations that have no analytical solution. It is also more accurate than other numerical methods, making it a valuable tool in many fields of study.

3. How does the Runge-Kutta method work?

The Runge-Kutta method works by breaking down the differential equation into smaller steps and calculating the solution at each step using a series of intermediate values. These intermediate values are then used to refine the solution, resulting in a more accurate approximation of the actual solution.

4. What are the advantages of using Runge-Kutta method?

One of the main advantages of using the Runge-Kutta method is its ability to handle a wide range of differential equations, including those with complex and nonlinear relationships. It is also a self-starting method, meaning it does not require an initial guess for the solution.

5. Are there any limitations to the Runge-Kutta method?

While the Runge-Kutta method is a powerful tool for solving differential equations, it does have some limitations. It can be computationally expensive for systems with a large number of equations, and it may not be as accurate when used with stiff systems (equations that change rapidly over a small time interval).

Similar threads

Replies
61
Views
1K
  • Differential Equations
Replies
3
Views
530
  • Differential Equations
Replies
6
Views
2K
Replies
7
Views
2K
  • Differential Equations
Replies
6
Views
3K
  • Differential Equations
Replies
1
Views
1K
  • Differential Equations
Replies
16
Views
951
  • Differential Equations
Replies
4
Views
6K
Replies
3
Views
851
  • Differential Equations
Replies
3
Views
1K
Back
Top