Giter Site home page Giter Site logo

RK4 seems broken about owl_ode HOT 9 CLOSED

mseri avatar mseri commented on May 31, 2024
RK4 seems broken

from owl_ode.

Comments (9)

tachukao avatar tachukao commented on May 31, 2024 2

@mseri I just found the bug in the RK4 stepper function, should have been more careful when I wrote the function 🤦.
I also noticed something weird with RK4 a while back, but I never looked into it.
Basically, the problem was with the update:
let dy = M.((k1 + k2 + k3 + k4) /$ 6.)
It should be
let dy = M.((k1 + (2. $* k2) + (2. $* k3) + k4) /$ 6.)
I've made the necessary changes and pushed. But yea I agree, we should add a test suite to test all these stepper functions 👍

from owl_ode.

ryanrhymes avatar ryanrhymes commented on May 31, 2024 1

Agree, we can use matlab (or other tools) to generate a set of solutions beforehand, then use owl-ode to check against it.

from owl_ode.

tbrk avatar tbrk commented on May 31, 2024 1

One example that we often use in Zélus is:

let f t y yd =
  yd.{0} <- (-. y.{1}); (* cosine *)
  yd.{1} <- y.{0} (* sine *)

let y_init = [| 1.0; 0.0 |]

from owl_ode.

ryanrhymes avatar ryanrhymes commented on May 31, 2024

can we add a test suite similar to owl so others can recreate the issue?

from owl_ode.

mseri avatar mseri commented on May 31, 2024

It's on the pipeline. I am still trying to figure out the best way of testing this. Maybe by taking a set of known ode+solutions and checking that the error is somewhat O(h^(method-order)).

from owl_ode.

mseri avatar mseri commented on May 31, 2024

We could even pick some equations with closed form solutions if we want to be more reliable, at that point is really about comparing numerical and analytical solutions.

from owl_ode.

mseri avatar mseri commented on May 31, 2024

Indeed, that's a quite good example.

PS. Zélus seems awesome, I did not know about it, thanks for mentioning it!

from owl_ode.

mseri avatar mseri commented on May 31, 2024

Thanks! I’ll try to prepare some tests following tbrk suggestion soon

from owl_ode.

mseri avatar mseri commented on May 31, 2024

I have a proposal for testing: #6
If you agree with the approach, I am going to merge and release a new version (including also @tachukao fixes)

from owl_ode.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.