Numerically Integrating Differential Equations in Excel and Python: Runge Kutta Method
Vložit
- čas přidán 25. 08. 2024
- I want to go over an implementation of the 4th-order Runge Kutta algorithm in both Python and Excel. This algorithm is used extensively in scientific computing. MATLAB’s ODE45 solver, as well as the solve_ivp function from Scipy use a variation of this technique. The goal of this video is to show how simple it is to make use of this method when one doesn’t gave access to canned routines such as those in MATLAB or Scipy. This video was inspired by an engineer I worked with years ago who ran into this issue. He had an ODE to solve, but the only software he had easy access to was Excel.
Tip Jar: paypal.me/kpmo...
Video on Euler’s Method: • Numerically Integratin...
Wikipedia Page on Runge Kutta: en.wikipedia.o...
Github: github.com/kpm....
Great video! Thank you!
Thank you for this video. May I ask what if the initial value is at a singular point. For example, dy/dx = f(y,x)/x but the initial value is at y(0) = 0. Can we still use Runge Kutta method? How can we solve the problem like that?
Yes, it shouldn't be a problem as long as you don't have to plug x = 0 directly into the Runge-Kutta function for evaluation. Just setting an initial condition should still work.
@@kpmooney Thank you so much for your reply. But I would get the infinite value on that.
I had a similar situation once. Assuming a solution exists, you could start your integration off at some small number close to zero. In my case, I had a second order equation with x = 0 .. 2 * pi. I ended up just starting the integration at x = 1e-6 and using the initial value at that point instead of zero. Then I tried to estimate the error involved by doing so. Since it was small, I just used that result.
@@kpmooney Okay. Thank you so much. It is super helpful.