Learning the Runge-Kutta Method 2. Adaptive Step Size
HTML-код
- Опубликовано: 29 дек 2024
- This series helps students learn how to use the Runge-Kutta Method in VPython. It assumes familiarity with the Euler-Cromer Method ( • Euler-Cromer Method fo... ) and VPython (www.youtube.co....
Code available at www.glowscript....
Support this channel: ko-fi.com/LetsC..., / letscodephysics
Thank you, patrons!
Fan Xinyu
Super Mario 64 ReMix by DaMonz: "The Slumber of the Beast" [Piranha Plant's Lullaby] (#3462), ocremix.org
The threshold for the difference in outputs from the different step sizes... is that simply some user defined random value or is there some ideal threshold?
The first - It depends on your needs for accuracy.
@@LetsCodePhysics Okay, thanks 👍🏻
@@LetsCodePhysics Hi guys, just got round to making my adaptive runge kutta function, would you advise setting the tolerance as some percentage of the output? Say you wanted the error to never go above 0.001% of the output value. That way the tolerance is relevant for outputs of all magnitudes.
Yes, that's a good criterion.
@@LetsCodePhysics 👍🏻👍🏻
On line 63 of the code from the link I think the condition for doubling the step is incorrect
The code says : else if (abs(step_x) > x_tol and abs(step_x-dble_step_x)/abs(step_x) < dx_min):
Here the abs(step_x) > x_tol should be changed to abs(step_x) < x_tol
I mean why would you allow it to be more than tolerance for doubling the step.
Please confirm me if its correct or not.
Also if @LetsCodePhysics can please share your email Id where I can contact you for queries, it would be a big help for me :-)
nice work
Nice video, but how to apply this to system of equations of first order? I have 2 equations (first depends on second and vice versa)
Just keep watching 😉
how can we get the output of a veriable on each step-size in RK4stepsize method?
You mean like a print command?
@@LetsCodePhysics no I mean I have one output variable let say z in main program and I want to give z as an output in a Function for which i have to calculate root by Brent mthod so in that function i wana give z as an input how can i ?
So, you want to add a function or you want to place Runge-Kutta inside a function?
@@LetsCodePhysics I want root from brents method and that root is dependent on z variable and i have find the z vadiable by adaptive step size already i just want to put value of z in the function which contains root and z and while putting z in that function only one value of root appears while i have the values of z more than one so if z has more than one value then root should have more than one value not constant value so how can i put z into root finding function so that i can find the corresponding values of root of variable say lambda.
can we write the code by matlab?
Absolutely! I think there's even a built-in ODE solver.
@@LetsCodePhysics that's ODE 45,I think
There are several ODE solvers in MatLab that allows us to approximate solutions of a differential equation. ode45 solver uses a pair of Runge-Kutta methods of order 4 and 5 respectively, but there are also other solvers such as ode23. If you have a stiff differential equation you can use the ode15s to run your code with greater efficiency.
pozdrowienia z polibudy osrańskiej