Numerical Integration Error Bound 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?
 A: 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.
Specifically,
$$\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}), $$
whence,
$$ \sqrt{1 + 1/n} - 1/\sqrt{n} < \frac{1}{\sqrt{n}} \sum_{k=1}^{n} \frac{1}{\sqrt{k}} < 2, $$
and 
$$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.$$
