# Are expressions including radicals particularly difficult to integrate numerically?

I noticed some unusual result errors when numerically integrating using a TI-84 Plus CE. This answer explains that the TI-84 uses a 15-point Gauss-Kronrod method with a maximum error of $$10^{-5}$$ to perform numerical integrals.

I first noticed the errors when comparing different integral methods for solids of revolution. Using the so-called "shell method", I got the correct answer to within the provided precision. $$\int_{1}^2 2\pi y [(\sin^{-1}(1-\frac{y}{2}))^2 - (\sqrt{2y}-2)) dy \approx 2.985917356$$

However, the "washer method" for the same volume took much longer to integrate and produced an incorrect result: $$\int_{\sqrt{2}-2}^0\pi[(\frac{1}{2}(x+2)^2)^2-1^2]dx\ \ + \ \int_0^{\frac{\pi^2}{36}}\pi[(2-2\sin(\sqrt{x}))^2-1^2]dx\approx 2.985917088$$ [For reference, the exact result for both should be $$\pi^3\frac{5}{36}+\pi^2\frac{7\sqrt{3}}{6}+\pi\frac{8\sqrt{2}-79}{10}\approx2.985917356$$ which matches the "shell method" result to within the available calculator precision.]

The absolute error between the correct answer and the incorrect answer is $$\approx2.68\times10^{-7}$$. This is pretty good and in fact better than the advertised $$10^{-5}$$ bound on the absolute error.

However, I got curious, and I managed to isolate the error in the second calculation to just the term with the $$(2-2\sin(\sqrt{x}))^2$$ in it. Doing a variable substitution changes the integral to $$\int_0^{\frac{\pi}{6}}2\pi u(1-\sin(u))^2du$$ which actually fixes the lack of precision and aligns the numerical result with the correct answer.

From here, I tested a few more integrals of various sorts and discovered that exotic radicals (i.e. negative fractional powers and large denominator powers) consistently produced noticeable errors - and took a lot longer to do it! - whilst even complicated trigonometric and inverse-trigonometric integrals did not. Here are two interesting examples:

$$\int_0^{128} x^{\frac{2}{7}}dx \approx 398.2222228$$

However, the exact answer of $$398\frac{2}{9}$$ is produced to within calculator precision with the equivalent integral $$\int_0^27x^8dx\approx398.2222222$$ an error of $$\approx6\times10^{-7}$$.

Additionally, the calculator finds after a lot of labor $$\int_0^4\frac{1}{\sqrt{x}}dx\approx 3.999994424$$ which differs from the exact answer of $$4$$ by $$\approx5.6\times10^-6$$.

Obviously, the calculator is performing as advertised and suppressing the absolute error to below $$10^{-5}$$; however, it does beg the questions:

Why does the numerical integrator struggle so much to do integrals with unusual radicals? And why do the results have much bigger errors than other types of integrals? Are radical expressions just harder to integrate in general?

EDIT: Inspired by the comments, I investigated several other integrals in which the lower bounds were not exactly $$0$$. In all cases (even for very small lower bounds), the calculator had little difficulty producing the exact result. Moreover, the integrals of $$\ln(x)$$ and of $$\sqrt{x}$$ and of $$\sin^{-1}(x)$$ from $$0$$ to $$1$$ showed the same sort of errors. This suggests that the difficulties with all of the examples given in the main post stem from the slope being undefined at one of its bounds.

This now leads to a perhaps more focused question: Why is that an issue for the numerical integrator?

• I suspect that radicals can cause an integrand's derivative to have a pole or spike, so that the derivative becomes undefined on the integration interval (so that the function is not Lipschitz continuous). And I suspect this can be a problem for numerical integration. Commented Jun 2, 2021 at 17:35
• It is not very surprizing that there are problems for $\int_0^4\frac{1}{\sqrt{x}}dx$ because it is a generalized integral (the integrand isn't defined at one of the bounds (i.e., $0$ is a pole) Commented Jun 2, 2021 at 18:02
• @PeterO. I believe you are correct. I tested several other integrals and found that the errors disappeared when the lower bound was not zero. I've add an edit to the question. Commented Jun 2, 2021 at 19:35

It's not just radicals. Many integration algorithms require the integrand to have derivatives of bounded variation (and other conditions) to work correctly.

For example, Y. Zhang (2018) specifies algorithms for the trapezoidal and Simpson rules that are guaranteed to approximate integrals accurately for any function whose first or third derivative, respectively—

• Has bounded total variation, and
• does not vary too greatly over a small interval.

The work cited below also includes a discussion on the minimum number of function values that any algorithm needs to work correctly, and constructs functions that can fool any numerical integration algorithm (which can even be piecewise linear). These complexity results are based in part on the first or third derivative's total variation.

REFERENCES:

• Y. Zhang, "Guaranteed, adaptive, automatic algorithms for univariate integration: methods, costs and implementations", dissertation, Illinois Institute of Technology, 2018.

The error formula for any numerical integration requires a certain regularity of the integrand. When it is said that that the 15-points formula used by the calculator yields a maximum error of $$10^{-5}$$, this is under the assumption that the integrand has continuous derivatives up to a certain order. More specifically, since Gauss-kronrod method uses a 7-point Gauss integration, you should have continuous derivatives at least up to order 14.

• That seems reasonable, but it's by no means obvious to me. Can you explain where is dependence on high-order derivatives comes from? It doesn't seem to me that the numerical integration ought to explicitly rely on derivatives at all. Commented Jun 3, 2021 at 19:37
• @Geoffrey It is not that the numerical result of the integration rule depends on the derivatives but rather the error expression. If the derivatives up to a certain order are not bounded, we cannot assure that the integration rule approaches the true value of the integral. Commented Jun 3, 2021 at 21:34
• For instance, in the trapezoidal rule, the error term includes a factor which is $f''(\xi), \xi \in (a,b)$. If the second derivative is not bounded we cannot assure that the trapezoidal rule is yielding good estimates of the integral. The same goes for higher order methods like the one you mentioned. Commented Jun 3, 2021 at 21:36