Can we always numerically integrate? I posted this question in physics SE, as few suggested me to post it here: when I watch online lectures (usually of physics) most lecturers say that if we cant solve a integral exactly we can always numerically integrate it. (E.g. in central force problem the orbit where we find $\theta(r)$ or $r(\theta)$ is pretty difficult to compute and professor said that if needed we can always integrate it numerically if we cannot do it exactly)
So is it always possible to numerically integrate? Is there any example in physics where it not possible to integrate numerically or any integral which cannot be even integrated numerically? Is there any limitation of numerical integration?
 A: Suppose the integrand $f$ is Riemann integrable on $[a,b]$.  Then the Riemann sums converge to $\int_a^b f(x)\;dx$.  If you know a bound $M$ for $|f(x)|$ on $[a,b]$ you can rigorously prove a bound on the error for that approximation.  That error bound goes to zero as the number of terms goes to infinity.  So you CAN numerically integrate in this setting.
If you know $f$ is $n$ times differentiable, there are numerical integral calculations that converge more rapidly.  For example, Simpson's rule.
But of course there are functions (according to mathematicians) that are not Riemann integrable.  Do any of them come up in physics?  You will have to ask physicists about that.  (Mandelbrot reported that his early papers on fractals were routinely rejected by physics journals as "unphysical".  But that is no longer the case today.)
For example, in quantum physics you deal with Hilbert spaces like $L^2$, where there are lots of non-Riemann-integrable functions.
Mathematical physicists are often writing down integrals with delta functions in there, but pretending they are actual functions.  Will they try to compute these numerically?
Physicists write down divergent integrals like this:
$$
\delta(x-\alpha) = \frac{1}{2\pi}\int_{-\infty}^{+\infty} e^{ip(x-\alpha)} \; dp .
$$
Will they try to compute these numerically?
A: The answer by @GEdgar considers numerical integration in exact arithmetic. This answer considers numerical integration using finite precision arithmetic.

So is it always possible to numerically integrate?

No. It is essentially impossible to evaluate an integral if the exact value is sufficiently close to zero. It is a question of conditioning. Finite sums that contain both negative and positive terms and sum to nearly zero are ill-conditioned. Our inability to compute the necessary function values with the required accuracy will destroy the accuracy of the computed approximation of the integral.

Is there any example in physics where it not possible to integrate
numerically

Yes. The solution of the initial value problem
\begin{align} y'(t) &= y(t) \\ y(0) &= 1 \end{align}
will rapidly exceed the representational range of any finite number system.

or any integral which cannot be even integrated numerically?

Yes. Consider a polynomial $p$ that is zero for all machine numbers. Then $|p|$ is continuous and
$$ \int_a^b |p(x)|dx > 0,$$
for any interval $[a,b]$, but the computed value of any Riemann sum or Gauss quadrature will be zero.

Is there any limitation of numerical integration?

Yes. You must provide the user with

*

*an approximation of the integral

*an error estimate, and

*an argument that explains why the error estimate is reliable.

If the truncation error obeys an asymptotic error expansion, then this is theoretically possible. However, if the order of accuracy is too high, then the asymptotic range is too short and it is essentially impossible to recognize that the error estimates are reliable.
