HNHacker News
TopNewBestAskShowJobs

mtantaoui

61 karma · joined November 19, 2024

https://github.com/mtantaoui mohamedalmahdi.tantaoui@gmail.com
submissionscomments
mtantaoui··on Show HN: Rust library for numerical integration of real-valued functions
Thanks! That’s awesome to hear—I’d love to see how your Raku numerical integration project turns out!

You can email me if you want to, I'll be happy to help.

mtantaoui··on Show HN: Rust library for numerical integration of real-valued functions
for ]-inf, inf[ integrals, you can use Gauss Hermite method, just keep in mind to multiply your function with exp(x^2).

    use integrate::{
        gauss_quadrature::hermite::gauss_hermite_rule,
    };
    use statrs::distribution::{Continuous, Normal};

    fn dnorm(x: f64) -> f64 {
        Normal::new(0.0, 1.0).unwrap().pdf(x)* x.powi(2).exp()
    }

    fn main() {
        let n: usize = 170;
        let result = gauss_hermite_rule(dnorm, n);
        println!("Result: {:?}", result);
    }

I got Result: 1.0000000183827922.
mtantaoui··on Show HN: Rust library for numerical integration of real-valued functions
this was mainly to use an Iteration free method in this paper: https://www.cfm.brown.edu/faculty/gk/APMA2560/Handouts/GL_qu...

this method is much faster and simpler.