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

Комментарии •

  • @georgetait386
    @georgetait386 3 года назад +2

    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?

    • @LetsCodePhysics
      @LetsCodePhysics  3 года назад +1

      The first - It depends on your needs for accuracy.

    • @georgetait386
      @georgetait386 3 года назад

      @@LetsCodePhysics Okay, thanks 👍🏻

    • @georgetait386
      @georgetait386 3 года назад +1

      @@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.

    • @LetsCodePhysics
      @LetsCodePhysics  3 года назад +2

      Yes, that's a good criterion.

    • @georgetait386
      @georgetait386 3 года назад

      @@LetsCodePhysics 👍🏻👍🏻

  • @satishrapol3650
    @satishrapol3650 Год назад +1

    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 :-)

  • @funwithMusaEssaTaha
    @funwithMusaEssaTaha 6 лет назад +2

    nice work

  • @patrickstick8249
    @patrickstick8249 3 года назад +1

    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)

  • @muhammadmuzammil2571
    @muhammadmuzammil2571 4 года назад

    how can we get the output of a veriable on each step-size in RK4stepsize method?

    • @LetsCodePhysics
      @LetsCodePhysics  4 года назад

      You mean like a print command?

    • @muhammadmuzammil2571
      @muhammadmuzammil2571 4 года назад

      @@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 ?

    • @LetsCodePhysics
      @LetsCodePhysics  4 года назад

      So, you want to add a function or you want to place Runge-Kutta inside a function?

    • @muhammadmuzammil2571
      @muhammadmuzammil2571 4 года назад

      @@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.

  • @legend8930
    @legend8930 5 лет назад +1

    can we write the code by matlab?

    • @LetsCodePhysics
      @LetsCodePhysics  5 лет назад

      Absolutely! I think there's even a built-in ODE solver.

    • @sunset1394
      @sunset1394 5 лет назад

      @@LetsCodePhysics that's ODE 45,I think

    • @25Yassi
      @25Yassi 4 года назад

      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.

  • @soltys7011
    @soltys7011 3 года назад +1

    pozdrowienia z polibudy osrańskiej