Integration of ~1/r and ~1/r^2 functions

I would like to integrate some rational functions I have which scale
as 1/r and 1/r^2 respectively. Gaussian quadratures are exact for polynomial functions. Do you know any julia implementation of a rational quadrature?

Assuming that you’re dealing with possible poles/singularities, don’t the functions from the QuadGK.jl package work in your case?

sorry I forgot to mention about the poles/singularities. I want to integrate those functions in the region where they are regular.

Any quadrature will do its job there. But using a specialized for rational functions quadrature would provide exact integration, thus I would need less points to get a similar error from a usual quadrature.

I am performing these integrations in every time step in my simulation
for a 3D grid, for each cell. This explodes exponentially and I am seeking methods to improve.

Is it impossible to approximate the integral analytically? You could try to expand the integrand in a way that allows you to further integrate analytically and just leaving what you need to actually numerically integrate as something cheaper than the original integral. Or by parts.

1 Like

Also, check on Gaussian Quadrature · FastGaussQuadrature.jl if there is any scheme that fits your problem better.

i doubt it can be approximated analytically, and if it could ( i mean you can approximate anything ), its outside of my skills.

The functions are very complex because of multiple derivatives wrt to position and velocity and you have a Lorentz matrix in the func to begin with. So it will be a nightmare to tackle this analytically.

If the integration domain is fixed, then you can build 1/r^n into the weight function for your quadrature rule. See weighted quadrature in QuadGK, for example.

There are also some papers on other algorithms for quadrature of rational functions with known poles, e.g. Gautschi (2001) and Tomanovic (2023), but I don’t have experience with these.

In general, however, I don’t know offhand of any practical quadrature algorithm that is guaranteed to be exact for all rational functions of a given degree, analogous to Gaussian quadrature for polynomials. (There’s been a lot of recent progress in rational approximation via the AAA algorithm, but it still has few theoretical guarantees.)

1 Like

I don’t think it’s possible, at least with classical rules of the form \sum_{i=1}^n w_i f(x_i): the set of functions for which a certain rule is exact must be a vector subspace (it’s closed under sum and multiplication by scalars), while the smallest vector subspace that contains all rational functions of a given degree is the space of all rational functions.

2 Likes