Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Runge-Kutta integration of ordinary differential equations with Perl 6
branch: master
Failed to load latest commit information.
t fix illegal usage of time as a function. tadzik++ fix
README [README] mention that it works Right Now


Runge-Kutta integration for systems of ordinary, linear differential

WARNING: this module is not yet thoroughly tested. Use it at your own risk.
Bug reports, tests and patches are welcome!

Let's say you have a differential equation for the function f(t),
with the equation

df/dt = f(t)^2 + t
and the initial value f(t=0) = 1;

In the context of this module, we call df/dt the "derivative",
t the "parameter"

You'd solve that numerically with this Perl 6 code:

# begin

    use Math::RungeKutta;
    # function that calculates the derivative
    sub d($t, @values) { @values[0]**2 + $t}
    # that's a function that gets called with the
    # current values after each integration step
    sub callback($t, @values) { say "$t @values[0]" };
    my @initial = 1;

# end

And then look at the result:
$ PERL6LIB=lib perl6 | xmgrace -nxy -

The interfaces is inspired by Perl 5 module Math::RungeKutta, to be found at

Math::RungeKutta has last been verified to work on contemporary rakudo on
Something went wrong with that request. Please try again.