Numerical integration over given integral. How to do it in Julia?

In my current work I integrate numericaly some function over [0, \infty) using NumPy calling of Fortran libraries. I want to try do my problem using Julia, but I can’t find out-of-the-box library computing integrals.

Can someone tell my how numerical integration look now in Julia? Do I need call Fortran code directly? I try google something, but find almost nothing.

1 Like

Hi, There are several packages for numerical integration in Julia.

5 Likes

More explicitly, do using Pkg; Pkg.add("QuadGK") to install the QuadGK package, and then do

using QuadGK
quadgk(f, 0, Inf, rtol=1e-3)

to compute \int_0^\infty f(x)dx (along with an error estimate) for a function f, to about 3–4 digits.

7 Likes

Does anyone know how to perfom numerical integration on a gpu?

1 Like

Use GitHub - JuliaApproximation/FastGaussQuadrature.jl: Julia package for Gaussian quadrature to get the quadrature rates, use a CUArray and broadcast your function across the array, and then accumulate according to the quadrature weights.

5 Likes

this would work, thanks!