Scientific Computing in Rust

In my academic career I've been using Python and SciPy to do things like solve differential equations, but I recently fell in love with Rust and wanted to do those sorts of things in it.
However, it seems like all the scientific computing crates not focused on linear algebra or statistics (like nalgebra and statrs) are 5+ years old with a single exception, peroxide (whose interface I do not like). So, I took it upon myself to go through my numerical analysis book and implement some functions in a rust crate. Thus, I present bacon-sci: . I have also written a blog post about how the crate works: .


This looks great! And thanks for writing the blog post about it, for more context than just the docs.

I was using Fresnel integrals the other day, with a naive power series implementation. What would you suggest as the best way to compute them using bacon-sci? I'm a noob at scientific computing like this...

The best way would be:

use bacon_sci::integrate::integrate;

fn fresnel_S(t: f64, error: f64) -> Result<f64, String> {
    integrate(0.0, t, |x: f64| x.powi(2).sin(), error)

fn fresnel_C(t: f64, error: f64) -> Result<f64, String> {
    integrate(0.0, t, |x: f64| x.powi(2).cos(), error)

The crate and the blog are probably great, but I haven’t done much in the way of math for a long time, so I’m not fit to comment, however I do have one question.

In the blog article one section ends and the next section starts like so:

How does one solve an implicit equation? Well, stay tuned! ( bacon-sci does not currently have any BDF solvers).

Solving Initial Value Problems with bacon-sci

The theory is all well and good, but how do you solve an initial value problem with bacon-sci ? There are currently seven implemented solvers in the library: RK45 , RK23 , Adams , Adams2 , BDF , BDF2 , and Euler .

How can it be that bacon-sci has no BDF solver if 2/7 implemented solvers are named BDF and BDF2?

That section of the blog was written before I implemented BDF and I forgot to update it.


Thank you.

Have you thought about going further and implementing for efficiency? - Maybe for bulk processing, e.g., generating MLIR directly (or indirectly via XLA), or some kind of BLAS?

Great work! I wonder do you have any performance comparisons between bacon-sci and peroxide (or sundial)?

@aftix You might want to look into statrs, it implements many PDFs and CDFs, as well as descriptive statistics.