# Implementation of integration schemes for ordinary differential equations in Python and peformance comparison

I look for a book/manual where I can find implementations of different integration schemes for ordinary differential equations (like 4-th order Runge-Kutta) in Python with Numba.

To be more specific, let me provide some details and background. In my research I deal with a system of coupled non-linear differential equations that looks like $$\frac{dx_i}{dt}=F(g,x_i(t),x_j(t)),$$ where $$F$$ is non-linear function, $$g$$ is the parameter and there are $$N$$ equations. My goal is to obtain the solutions $$x_i=x_i(t)$$ on the interval $$[0,T]$$ for all the parameter values from the interval $$[g_1,g_2]$$ as fast as possible and easily perform basic mathematical manipulations with values $$x_i(t=T)$$.

Now background:

1. Currently I use Wolfram Mathematica built-in NDSolve and NDSolveValue functions and use parallelization (Parallelize, ParallelTable). I see that the performance is not good enough for values $$N>1000$$
2. Recently I have known that it seems possible to improve performance in Mathematica: one can implement integration scheme by hand and next use Compile (it is quite similar to byte-code compilation, as I understand) and/or use C++ compilation. For me, this program is desirable but I cast some doubts.

These doubts come from the fact that I can use my GPU with CUDA (it is quite "small" card, NVIDIA GTX 1050) and try to improve performance. Next, I am not sure that built-in functions and any manipulations with compilation in Wolfram Mathematica will be faster than another programming language.

From other programming languages, the appropriate choice for me is Python. I know the following opportunities in Python:

1. odeint from scipy
2. torchdiffeq package
3. diffeqpy that operates with Julia
4. numba in order to wrap numpy-code and make it more fast

So, my ultimate question is:

1. What is the fastest tool for the stated problem: torchdiffeq or diffeqpy or combination numpy+numba (where integration scheme is written by hand)?
2. Does this fastest tool allow me to run my code at cluster/server (in future, now I have only my laptop)?
• Are you experimenting with your own implementations or is your aim an acceleration via JIT? In the last case, you might get some way with the sympy-expression-parser based JITCode (expressions to C code linked to the compiled solver behind odeint). Or the python wrapper to the julia-lang diffeq package with its vast library of methods for various classes of DE. Apr 7 at 16:13
• @LutzLehmann , now I see that my question is not so specific and I should do work myself. Apr 8 at 17:03
• @LutzLehmann I have tried to add more details and background in order to make my question and goals clearer Apr 8 at 17:23
• I think that even if it is now 5 years old, this overview stochasticlifestyle.com/… is still valid. A more recent talk from the same author stochasticlifestyle.com/… Apr 8 at 17:23
• In a speed contest diffeqpy will likely win. It does a code transformation to a complete julia script, compiles that and executes it. Selecting the recommended methods depending on the stiffness should give code that could be faster than even other compiled code. Depending on what $x_j$ in $\dot x_i=F(g,x_i,x_j)$ means, your system could have structure, at least sparseness, that can be fully used in the Julia context. Apr 8 at 17:30