# Background

This post is motivated by my interest in the performance of symbolic integrators in computer algebra systems (CAS's), such as Mathematica (MMA).

I've found that, when an integrand has discontinuities, the indefinite integral returned by MMA often has discontinuities that don't match locations with those in the integrand itself (i.e., they occur at different points in the domain). Here is an example taken from a WRI (Wolfram Research Institute, the maker of MMA) blog (https://blog.wolfram.com/2008/01/19/mathematica-and-the-fundamental-theorem-of-calculus/):

Consider the integrand: $$f(x) = \frac{1}{4 \sin (x)+5}$$

$$f$$ is continuous over the reals, but has poles in the complex plane at $$x = \pi (2 n-\frac{1}{2}) \pm i \ln(2)$$, where $$n \in Z$$.

MMA returns the following indefinite integral:

$$F_1(x)=\frac{1}{3} \left(\tan ^{-1}\left(2-\frac{3}{\tan \left(\frac{x}{2}\right)+2}\right)-\tan^{-1}\left(2-\frac{3}{\cot \left(\frac{x}{2}\right)+2}\right)\right)$$

While $$f$$ is continuous on the reals, $$F_1$$ is not. By comparison, the following indefinite integral is continuous on the reals (see picture below):

$$F_2(x) = \frac{x}{3}+\frac{2}{3} \tan^{-1}\left(\frac{\cos (x)}{\sin (x)+2}\right)$$

As the blog author explains, $$F_1$$ and $$F_2$$ differ by a piecewise constant.

[Interestingly, Rubi (https://rulebasedintegration.org), developed by Albert Rich, and available as add-on integration package for MMA, does return $$F_2$$.]

An implicit message of the blog seems to be that $$F_1$$'s discontinuities on the reals do not make it an inferior result to $$F_2$$, since if the integrand has discontinuities, discontinuities somewhere in the antiderivative are unavoidable: "Moreover, if a meromorphic integrand $$h(z)$$ has simple poles in the complex plane, it is impossible to choose an antiderivative $$\mathcal{H}(z)$$ continuous along every imaginable path in the complex plane–because of branch cuts in $$\mathcal{H}(z)$$."

Specifically, the author explains that while $$F_1$$ may have discontinuities in the reals that aren't present in $$F_2$$, $$F_2$$ has discontinuities elsewhere in the complex plane that aren't present in $$F_1$$. For instance, he shows that $$F_2$$ has a discontinuity at $$x = \frac{3}{2} + i \ln(2)$$, while $$F_1$$ does not. I.e., you have to pay somewhere.

However (and this is what motivates my questions), I disagree with that message (that $$F_1$$ and $$F_2$$ are equivalent because they both have discontinuities). Instead, I think it is functionally superior to have an antiderivative whose discontinuities occur only where there are also discontinuities in the integrand. For instance, if the integrand is continuous on the reals, it is convenient to have an antiderivative that is likewise continuous along the reals, so that one does not have to do a piecewise integration there. [Note also that $$F_2$$'s discontinuity at $$x = \frac{3}{2} + i \ln(2)$$ matches that of $$f$$.]

# Questions

[Note: Based on Robert Israel's answer, I've edited my question to improve it.]

As I understand it, if an integrand has certain types of discontinuities, one cannot avoid discontinuities in its antiderivatives.

Further, not every function has an antiderivative. But: Suppose we have a discontinuous integrand for which a continuous-everywhere antiderivative can't exist (because of the nature of the discontinuities in the integrand) (such as $$f$$, above). Further suppose a non-piecewise antiderivative (i.e., one with a single functional form) for this integrand does exist, but that it has discontinuities that don't match up to those of the integrand (e.g., $$F_1$$). In such cases, must there also exist a non-piecewise antiderivative whose discontinuities do match the locations of those of the integrand (e.g., $$F_2$$)?

For example, consider the integrand:$$g(x) = \frac{x^2+1}{\left(1-x^2\right) \sqrt{x^4+x^2+1}}$$

This integrand is discontinuous over the reals, yet it is possible to find an antiderivative, $$G(x)$$ (generated by Rubi), whose discontinuities occur in the same locations (at $$x=-1$$ and $$x=1$$):

$$G(x)=\frac{\tanh ^{-1}\left(\frac{\sqrt{3} x}{\sqrt{x^4+x^2+1}}\right)}{\sqrt{3}}$$

Now, by contrast, consider the integrand:

$$h(x)=\frac{(2 \sec (4 x+3)+1)^{3/2}}{\sqrt{\cos (4 x+3)}}$$

for which Rubi generates the following antiderivative (MMA's antiderivative is not real-valued on the reals); I believe $$F$$, $$E$$, and $$\Pi$$ are incomplete elliptic integrals of the first, second, and third kind, respectively:

Unlike the case with $$G(x)$$, $$H(x)$$ has discontinuities on the reals not present in its integrand (e.g., at $$x = \frac{(\pi -3)}{4}$$):

Given the above, should there exist another real-valued antiderivative of $$h$$ that, at least on the reals, has discontinuities that correspond to those of $$h$$?

I also have the following auxiliary question:

The quote from the WRI blog author mentions "simple poles". But I'm concerned with discontinuities generally, i.e., with anything that would require a piecewise integration. Thus I'm wondering if his statement can be generalized/reworded to something like: "If an integrand has one or more discontinuities, it is impossible to choose a single antiderivative that will be continuous everywhere."

• contour integration fails horribly in the last 3 or 4 versions of MMA, this means that probably it fails too for other kinds of integrals. By example – Masacroso Apr 23 '19 at 10:42
• The issue with *simple pole" is that the integral of it is $\log()$ which is multi-valued and hence has branch cuts. Integrals of higher order poles do not have this problem. – Somos Apr 23 '19 at 13:13
• @Somos I see. But what if the discontinuity is not a pole, but some other type, e.g., an essential singularity [such as x=0 for log(x)]? Here, the discontinuity in the integrand does appear to necessitate a discontinuity in the antiderivative, even though the integrand's discontinuity isn't a simple pole. Thus while (as you've explained) not all categories of integrand discontinuities necessitate discontinuities in the antiderivative, it seems it's broader than just simple poles. – theorist Apr 23 '19 at 17:06
• $0$ is a branch point of $\log(x)$, not an essential singularity. – Robert Israel Apr 23 '19 at 20:44
• – Jean-Claude Arbaut Apr 23 '19 at 21:11

By the Fundamental Theorem of Calculus, if the integrand $$f(x)$$ is continuous on an interval $$(a,b)$$, there is a continuous antiderivative on that interval, e.g. $$\int_c^x f(t)\; dt$$ where $$a < c < b$$. Finding an expression for it in a CAS is another matter.
It is possible for a discontinuous function $$f(x)$$ to have a continuous antiderivative. For example, consider $$f(x) = \cases{2x \sin(1/x) - \cos(1/x) & for x \ne 0\cr 0 & for x=0}$$ which has antiderivative $$F(x) = \cases{x^2 \sin(1/x) & for x \ne 0\cr 0 & for x=0\cr}$$
EDIT: My first paragraph says you can avoid antiderivatives whose "discontinuity locations don't match the integrand's". Maybe it will help to look at your example $$\frac{(2 \sec(4x+3)+1)^{3/2}}{\sqrt{\cos(4x+3)}}$$ which, with the change of variables $$4x+3=t$$, becomes $$\frac{(2 \sec(t)+1)^{3/2}}{\sqrt{\cos(t)}}$$ That is continuous on each interval of the form $$((2k-1)\pi/2, (2k+1)\pi/2)$$. Therefore it must have a continuous antiderivative on each of these intervals (as I wrote, finding a closed form for such an antiderivative is another matter). Since the integrand is undefined at the odd multiples of $$\pi/2$$ where $$\cos(t) = 0$$, the antiderivative doesn't have to be defined there either, and since the integrand has a non-integrable singularity there the antiderivative will also go to $$\pm \infty$$ as $$t$$ approaches those points.
• Thanks for your answer, and your example.I understand from your post that, if $f$ is continuous on an interval, then there must exist an antiderivative of $f$ that is also continuous there. But what about the key remaining part of my ques. (which I've improved based on your answer), concerning functions that can't have continuous-everywhere antiderivatives, but for which non-piecewise discontinuous antiderivatives exist, but whose discontinuity locations don't match the integrand's? In such cases, must there also exist a non-piecewise antideriv. whose discontinuities do match the integrand's? – theorist Apr 23 '19 at 19:43
• Thanks for your edit, and for sticking with this. Let's call your example (with the change of variables) $h_1$. I understand there must exist an antiderivative continuous on each of intervals over which $h_1$ is continuous. Further, because of $h_1$ 's periodic nature, it seems an antiderivative on the reals would require only two expressions, covering the intervals on which $h_1>0$ and $h_1<0$, respectively. A CAS may or may not be able to find those. But that doesn't get to the heart of what I'm trying to ask (sorry for not having better math language tools), which is this: [continued...] – theorist Apr 24 '19 at 2:28
• Supppose an integrand that is expressible as a single (i.e., non-piecewise) function has non-integrable singularities on the reals (e.g., $h_1$). Must there exist a single (non-piecewise) expression that will serve as a continuous antiderivative on all of $h_1$'s continuous intervals, having discontinuities only where $h_1$ itself is non-integrable? An example of such a pair would be $g$, and $G$, above. I'm not asking if a CAS could find it, I'm asking if it must exist. – theorist Apr 24 '19 at 2:28
• You can write a piecewise expression as a non-piecewise one by something like $$\frac{x-a}{2\sqrt{(x-a)^2}} (g_1(x) - g_2(x)) + \frac{g_1(x) + g_2(x)}{2}$$ which is $g_1(x)$ when $x > a$ and $g_2(x)$ when $x < a$. – Robert Israel Apr 24 '19 at 12:45