Show HN: Rust library for numerical integration of real-valued functions

mtantaoui | 123 points

> Does the function oscillate over the region of integration? If it does, then make sure that the step size is chosen to be smaller than the wave length of the function.

Nyquist limit, but for numerical integration?

zackangelo | 2 days ago

I think the project should be called "NIntegrate".

BTW, that is not a serious suggestion; it is just that Wolfram Language (aka Mathematica) has both `Integrate` and `NIntegrate` for symbolic and numeric integration, respectively.

antononcube | 2 days ago

It looks a bit sloppy to hardcode so many constants in a single file: `src/gauss_quadrature/legendre.rs`. Isn't it possible to generate them with the help of rust macros in the same way Julia uses metaprogramming?

JanisErdmanis | 2 days ago

I was always amazed that R can do:

  > integrate(dnorm, -Inf, +Inf)
  1 with absolute error < 9.4e-05
Can we do the same in this library?
wjholden | 2 days ago
[deleted]
| 2 days ago

In the rectangle method, there is "let x = a + i * h + (h / F1::from(2)...)"

I didn't check, but I wonder if it is not better to do x = a + (i+0.5)*h... My reasoning is that if "i" is very big, then i * h can be much bigger than h/2 and thus h/2 may be eaten by numerical precision when added to i*h... And then you have to convince the optimizer to do it the way you want. But well, it's late...

wiz21c | 2 days ago
[deleted]
| 2 days ago

I don't see any explicit SIMD in here. Is the rust compiler able to emit SIMD instructions automatically in cases like this? (I guess I could compile and disassemble to check... )

cozzyd | 2 days ago

Fast, small, lightweight compared to what?

zppln | 2 days ago

Thanks for showing this! It is very motivating to develop (and finish) my Raku numerical integration project.

antononcube | 2 days ago

Is there a technical reason to now allow closures as the integrand?

legobmw99 | a day ago
[deleted]
| 2 days ago

[flagged]

Dowwie | 2 days ago