Decidability of checking an antiderivative?

Let's suppose I have two functions $F$ and $G$ and I'm interested in determining whether

$$F(x) = \int G(x)dx.$$

Let's suppose that my functions are composed of elementary functions (polynomials, exponentials, logs, and trigonometric functions), but not, say, Taylor series.

Is this problem decidable? If not, it is it semidecidable?

(I'm asking because I'm teaching a class on computability and a student asked me if a TM could help you integrate a function whose integral was not currently known. I suspect that the functions we don't know how to integrate are more properly functions whose integral can't be expressed as a combination of the above elementary functions rather than functions for which we don't actually know the integral, but that got me thinking about whether the general problem of checking integrals was decidable.)

• You seem to be asking about symbolic differentiation. You might take a look at en.wikipedia.org/wiki/Symbolic_computation and en.wikipedia.org/wiki/Computer_algebra_system. It's not clear to me what class of functions you allow. What kinds of composition do you allow? e.g., is $F(x)=\sin(\cos(e^x)) + \log(2x^3+3)$ allowed? I suggest you try to formalize the class of functions you care about using a recursive definition. Have you tried seeing what happens when you use the chain rule, and see if you can get a recursive algorithm that handles all cases? – D.W. Nov 12 '15 at 21:53
• Since differentiation is easy, you are really asking whether we can decide if an expression $F$ is identically zero. This is probably a problem on which information is easier to find. – Yuval Filmus Nov 12 '15 at 22:12

The short answer to your question is "no". Richardson's theorem and its later extensions basically state that as soon as you include the elementary trigonometric functions, the problem of deciding if $f(x) = 0$ (and hence if $f(x) = g(x)$, since this is the same as $f(x) - g(x) = 0$) is unsolvable.

What's interesting about this is that the first-order theory of real closed fields is decidable. Intuitively, the reason why adding trigonometric functions makes the first-order system undecidable is because you can construct the integers via $\{ x \in R : \sin(\pi x) = 0 \}$, and the theory of the integers is undecidable.

Whether or not the theory of real closed fields with $e^x$ is decidable is a fairly famous open problem.

Even more interesting that this is that if you had an oracle which "solved" the constant problem (i.e. an oracle which can tell you if $f(x) = 0$ or not), then integration of elementary functions in finite terms is decidable, and a practical algorithm is known. So given $G(x)$, we could find $F(x)$ or know that there is no elementary integral of $G$ in finite terms.

Your problem seems to reduce the following simpler question:

Given two functions $F,G$ in class of functions, do we have $F(x)=G(x)$ for all $x$? (In other words, do they have the same value everywhere?)

I don't know whether this is decidable, for this class of functions. If it is, then your problem should be decidable as well.

For your problem, a general approach is: symbolically differentiate $F(x)$ to get $F'(x)$, then check whether we have $F'(x)=G(x)$ for all $x$.

So the key step is the symbolic differentiation. Let's work out how to do that in more detail. We can define the class of allowable functions recursively:

$$\newcommand{\or}{\;\vert\;} F(x) ::= c \or x \or e^x \or \log(x) \or \sin(x) \or \cos(x) \or \tan(x) \or F_1(x) + F_2(x) \or F_1(x) \times F_2(x) \or F_1(x)/F_2(x) \or F_1(F_2(x))$$

where $c$ ranges over constants and $F,F_1,F_2$ range over functions.

It is then possible to devise a recursive algorithm for symbolically differentiating this class of functions, using the standard rules of calculus (e.g., the chain rule, etc.). In particular, we can handle every case above, and show recursively that the derivative can be expressed symbolically as a function within this class. For instance:

• If $F(x)=c$, $F'(x)=0$.

• If $F(x)=x$, $F'(x)=1$.

• If $F(x)=e^x$, $F'(x)=e^x$.

• If $F(x)=\log(x)$, $F'(x)=1/x$.

• If $F(x)=\sin(x)$, $F'(x)=\cos(x)$.

• If $F(x)=\tan(x)$, $F'(x)=1 + (\tan(x))^2$.

• If $F(x)=F_1(x)+F_2(x)$, $F'(x)=F'_1(x)+F'_2(x)$.

• If $F(x)=F_1(x) \times F_2(x)$, $F'(x)=F'_1(x) F_2(x) +F_1(x) F'_2(x)$.

• If $F(x) = F_1(F_2(x))$, $F'(x) = F'_1(F_2(x)) F'_2(x)$ (chain rule).

And so on. In each case, if $F(x)$ is in the class of allowable functions, then so is $F'(x)$, and you can recursively work out a symbolic expression for $F'(x)$ -- this is known as symbolic differentiation.

Finally, all that remains is to check whether $F'(x)=G(x)$ for all $x$. That's the problem I mention at the top of my answer.

There's a simple method for checking whether two functions are identically equal that I'd expect to work pretty well in practice. The algorithm is this: repeatedly pick a random value of $x$, and check whether $F(x)=G(x)$ holds for that value of $x$. If it holds with equality for many randomly chosen $x$, then output "they are identically equal". If you find any $x$ for which $F(x)\ne G(x)$, then output "they are different".

There is no guarantee that this will work, but for many classes of functions, the output of this procedure will be correct with high probability. In particular, suppose we have some distribution on $x$ represented by the random variable $X$ and some $\epsilon>0$ such that $\Pr[F(X)=0] \ge \epsilon$ holds for all $F$ in the class. Suppose moreover that the class of allowable functions is closed under subtraction (as your class is). Then it follows that $r$ rounds of the above procedure gives the wrong answer with probability at most $(1-\epsilon)^r$.

Also, if there is a randomized procedure for polynomial equality testing, then the problem is decidable.

It remains to ask whether such a result holds for your particular class of functions. The statement above probably won't hold. However, if we lucky, perhaps we might be able to prove something like the following:

For all $s \in \mathbb{N}$, maybe we can find a distribution on real numbers, i.e., a random variable $X_s$, and a constant $\epsilon_s > 0$, such that such that $\Pr[F(X)=0]$ holds for all functions $F$ that are in your class and have "size" at most $s$.

If this is true, then it will follow that there is a randomized algorithm for polynomial equality testing and thus your problem is decidable.