I would like to use numerical integration to approximate $\int_{0}^{1} f(x) dx$ where $f(x) = \frac{1}{\sqrt{x}}$. But I can't figure out how to get an error bound.

For example, if I use trapezoidal rule then the error bound is

$$|E|\leq K\frac{1}{12\cdot n^2}$$

where $|f''(x)|\leq K$. But in this case there is no $K$ since $|f''(0)|$ is infinite.

I have a similar issue if I try to use Simpson's rule.

Is there a numerical integration method where I could calculate a error bound for this problem?

  • 1
    $\begingroup$ Your function $f$ is not defined at $0$ so applying the trapezoidal rule directly is not going to work. Would you be interested in the case $g(x) = x^\frac{1}{2}$ for which the trapezoidal rule is defined and where the standard error bound does not apply either? $\endgroup$ – Carl Christian Feb 1 '16 at 15:41
  • $\begingroup$ I picked this $f$ because even though it is not defined at 0, the integral between 0 and 1 converges. I'm curious if there is a way to calculate an error bound for this type of functions. $\endgroup$ – Daniel Vaca Feb 1 '16 at 17:35
  • $\begingroup$ The following paper derives both the classical and some less common error estimates for the trapzoidal rule using partial integration. maa.org/sites/default/files/An_Elementary_Proof30705.pdf The authors assume slightly more than you allow, but it is still worth a read. $\endgroup$ – Carl Christian Feb 1 '16 at 19:07

The simplest approximation that works for this improper integral is the lower Riemann sum where

$$E = \left| \frac{1}{n} \sum_{k=1}^{n} \frac{1}{\sqrt{k/n}} - \int_0^1 \frac{dx}{\sqrt{x}} \right|= \left|\frac{1}{\sqrt{n}} \sum_{k=1}^{n} \frac{1}{\sqrt{k}} - 2 \right| < O(1/ \sqrt{n}).$$

The RHS error bound is obtained by summing with the inequalities

$$ \frac{1}{\sqrt{k}} > \frac{2}{\sqrt{k} + \sqrt{k+1}} = 2( \sqrt{k+1} - \sqrt{k}) \\ \frac{1}{\sqrt{k}} < \frac{2}{\sqrt{k} + \sqrt{k-1}} = 2( \sqrt{k} - \sqrt{k-1}),$$

and using a Taylor expansion.


$$\frac{1}{\sqrt{n}} \sum_{k=1}^{n}2( \sqrt{k+1} - \sqrt{k}) < \frac{1}{\sqrt{n}} \sum_{k=1}^{n} \frac{1}{\sqrt{k}} < \frac{1}{\sqrt{n}} \sum_{k=1}^{n}2( \sqrt{k} - \sqrt{k-1}), $$


$$ \sqrt{1 + 1/n} - 1/\sqrt{n} < \frac{1}{\sqrt{n}} \sum_{k=1}^{n} \frac{1}{\sqrt{k}} < 2, $$


$$E < 2(1 + 1/\sqrt{n} - \sqrt{1+1/n}) = O(1 / \sqrt{n}).$$

In general for such improper integrals, it is advisable to try to remove the singularity before applying a numerical approximation. In some cases, you can simply ignore the singularity and apply the trapezoidal or Simpson rule with the value $f(0)$ arbitrarily set to $0$, or use something like Gaussian quadrature that does not explicitly involve the value $f(0)$. However, the convergence rate will be degraded and most certainly will not be $O(1/n^2)$. Furthermore, this may not work well if the integrand oscillates, e.g. $f(x) = (1/x) \sin (1/x).$

If the integrand is of the form $x^{-1/2}f(x)$, where $f \in C([0,1])$, then you can apply the transformation $s^2 = x$ and obtain a proper integral that is amenable to numerical approximation:

$$\int_0^1 x^{-1/2}f(x) \, dx = 2\int_0^1 f(s^2) \, ds.$$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.