Learn Runge-Kutta for Solving Differential Equations

  • Context: Graduate 
  • Thread starter Thread starter saltydog
  • Start date Start date
Click For Summary

Discussion Overview

The discussion focuses on the application of the Runge-Kutta method for solving integral differential equations (IDEs). Participants explore various numerical approaches, including comparisons with Euler methods, and express challenges in achieving accurate results.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant, Salty, presents an IDE and attempts to solve it using Runge-Kutta but finds discrepancies between the numerical results and the ODE solution, suggesting possible implementation issues.
  • Another participant reports progress by reverting to an Euler approximation, achieving better results by incorporating the integral directly into the method, but still expresses a desire to use Runge-Kutta.
  • A subsequent post describes modifications to the Euler method, showing improved overlap with the ODE solution but still insufficient precision, prompting a consideration of library resources for further research.
  • One participant claims to have developed a working Runge-Kutta method that significantly reduces the difference in the IDE's LHS and RHS, indicating a potential improvement over previous attempts.
  • Another participant discusses a different IDE, noting that Mathematica provides easy solutions and expresses intent to convert this problem to Runge-Kutta while also exploring more complex IDEs.

Areas of Agreement / Disagreement

Participants express varying levels of success with different numerical methods, particularly between Runge-Kutta and Euler methods. There is no consensus on the best approach or resolution of the discrepancies observed in the results.

Contextual Notes

Participants mention challenges with precision and accuracy in numerical methods, as well as the complexity of certain IDEs that may not easily yield to differentiation. There are unresolved questions regarding the implementation of Runge-Kutta and the effectiveness of alternative methods.

Who May Find This Useful

Readers interested in numerical methods for solving differential equations, particularly those involving integral terms, may find this discussion relevant.

saltydog
Science Advisor
Homework Helper
Messages
1,590
Reaction score
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: 453
  • ideplot2.JPG
    ideplot2.JPG
    5.1 KB · Views: 432
  • ideplot3.JPG
    ideplot3.JPG
    4.8 KB · Views: 432
Last edited:
Physics news on Phys.org
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: 455
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: 466
  • idedif.JPG
    idedif.JPG
    4.2 KB · Views: 420
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: 485
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.
 

Similar threads

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