https://github.com/HugoGranstrom/numericalnim NumericalNim is a library for doing basic ODE and integration related things. At the moment the ODE has two solvers: RK4 and DOPRI54, which are two quite standard methods. The integration can at the moment only handle 1D integrals and it has the following methods: trapz, simpson, adaptiveSimpson, romberg, cumtrapz and cumsimpson. Most of these can integrate both functions and discrete data. With the use of generics I hope that you should be able to use your own types (arbitrary precision, vectors etc) but they may need to implement some procs to be able for example calculate the error between two value. NumericalNim does also feature some conviniences like linspace and arange procs to create seqs of floats. And it does of course also feature a Vector type (can't have enough of those, right?) XD. If you want, you can also use Arraymancer Tensors as well which will probably be more performant.
Something I would be very interested in hearing from you is how it performs compared to the software you usually use for these tasks (in any programming language). I have only tested it on toy projects like integrating sin(x) but it would be interesting to see how it performs in some real data.
NumericalNim is my first real project in Nim, which I think is a good language with both performance and usability. I'm coming mostly from a Python background, so alot of the concepts were new to me for example generics and multiple dispatch, both of which are used in my project. I'm no professional in neither ODEs nor numerical integration but I have a interest for all kinds of numerical methods, so be prepared for the existance of bugs. I'm well aware that my implementations are neither the most efficient nor most robust but they work for now. I'm planning on improving on them in the future (or if someone else wants to contribute).
I'm open to suggestions, improvements and all kinds feedback. If you have any questions, don't hestitate :-D
First congratulations of course.
Have you considered bindings to Sundials? It looks CVODE serves the same purpose.
Thank you :-D
Not really, I'm quite new to low-level programming in general so I thought I'd make it in pure Nim so I could learn its features. This was also a project where I learned how all the algorithms worked which has been an enriching experience. To be honest, this isn't even near being production ready so a good first approach to get Nim into the data science field is probably to provide good bindings to libraries like CVODE (but my knowledge isn't there yet to be able to accomplish that, sadly). I would be really excited to see Nim being used more in computational science.
Thanks for the interesting links :-)
Julia has an astonishing amount of solvers, I would like to implement all of them in Nim but I got to be realistic XD and have a life as well. It has been one of my major inspirations when doing this.
Quite a bit has happened since last time:
Adaptive Gauss-Kronrod quadrature which should work well for a wide range of 1D integrals.
More (lower order) ODE integrators have been implemented, mostly for benchmarking integrators of different order (and of course for fun ;)).
JoegottabeGitenme <https://github.com/JoegottabeGitenme> has made some awesome contributions when he added 1D optimization. The methods he introduced was: steepest_descent, conjugate_gradient, newtons. Thank you very much for you kind contributions! :-D
The latest release brought interpolation into the mix with Natural Cubic Splines. They are piecewise polynomials of degree 3. All you have to do is provide a list of x-values and a list of y-values and then you can evaluate the spline. To find with interval the provided point lies in we use binary search. The spline does also have converters to procs and to be compatible with the rest of NumericalNim.
I did also change the operators for the vectors accordningly to the discussion in the Manu thread
It's so quiet on the forum today, I might as well make some noice then ;)
Since last time BarrOff has made several contributions to the ode solvers both by adding higher-order integrators like Tsit54, Vern65. The adaptive ode solver does now also use both an absolute and relative error tolerence instead of just an absolute tolerence it used before.
A new kind of Spline type has been introduced: HermiteSpline. It supports generic types in contrast to the natural spline which only support floats currently. If HermiteSpline is provided with function values and it's derivative it is third-order accurate.
By suggestion of @Vindaar the adaptiveGauss integral function supports infinite integration intervals and has a much more robust global error control instead of the local error control used before. Reaching machine epsilon accuracy was impossible before but now it has been possible for "nice" integrands.