I need a fast and accurate method to calculate 3d spherical volume integrals.I have pre-calculated data of high precision that just needs a few trivial manipulations before each integration step - in other words function calls are mostly just array look ups and multiplication and so are relatively cheap.The data is evenly spaced in spherical polar coordinates: 4 samples per degree for theta and phi, 500 radial samples.I need good precision, but I also need to perform several million such integrals, so speed is an important concern. What algorithm is most suitable for this problem?Bonus points for a link to an implementation in C++!
Spherical volume integral from pre-calculated points - which algorithm is best?
c++;quadrature;integration
So you want to evaluate$$F=\int_0^r \int_0^{2\pi} \int_{0}^\pi f(r,\phi,\theta) \, r^2 \, \sin (\theta) \ dr \, d\phi \, d\theta$$and you have your function $f$ available on equidistant gridpoints $r_i$, $\phi_j$ and $\theta_k$. Call$$f_{ijk} =  f(r_i, \phi_j, \theta_k)$$The plain simple approach is then just to use the trapezoidal rule (I'll omit the one-halves at the endpoints):$$F \approx \sum_{ijk}f_{ijk} \, r_i^2 \, \sin(\theta_i)$$... or, if you're feeling for higher order, use another Newton-Cotes formula.Just to note that once. For other approaches, see the comment section.EDIT: I've just noticed you were asking for the best method, so this will probably be quite boring for you.