# Moving the negative out of the integral - a bug in Wolfram Alpha?

A guy I follow on Twitter seems to be having some issues with Wolfram Alpha - namely that moving a negative outside of an integral results in two different answers:

• $\int -f(x) = -\int f(x)$ gives us True, since they're equal - Wolfram
• $\int {-1 \over {x-1}} = -\int {1 \over {x-1}}$ gives us $-\log(x-1) = -\log(1-x)$ instead of True - Wolfram

His summary of the issue:

Apparently you can take a minus sign out of an integral in all cases except when you can't? What the flying &@*! is going on here?

I'm inclined to agree that he's right - it does look wrong to me. I was always under the impression that moving the negative out of the integral shouldn't make a difference.

In order to test the issue, he tried $-1 \over f(x)$ and it came out True. I'd guess the solver is jumping to identities first in order to save processing power, which results in a tricky situation where the two equations have no solution.

Is he correct? Is this a bug in Wolfram Alpha? Or are we missing something?

-
One thought is that $f(x)$ might be the reason it works, since it can't try to "optimise" with identities and other shortcuts. – Polynomial Jan 18 '13 at 9:40
I think a lot of simplification is done for each step, and information gets lost along the way. I detect two things that Wolfram Alpha did wrong in your example: 1) The correct formula should be $\int \frac{dx}{x-1} = \log|x-1|$ + c. 2) The constants of integration on both sides just disappear. You might want to let Wolfram know about this. – Tunococ Jan 18 '13 at 9:53
@Tunococ: For point 1): no, the expression you give only describes some of the primitives, and a complete answer involves two independent constants. See my answer. – Marc van Leeuwen Jan 18 '13 at 10:24
@MarcvanLeeuwen Yes you're right. The root of the problem actually was the automatic determination of the domain. – Tunococ Jan 18 '13 at 10:30
For the principal branch of $\log z$ as used by Wolfram Alpha, we have that $\log -z = \log z +i \pi$ for $z\geq 0$ and thus the two expression differ only by a constant (assuming $x \in \mathbb{R}$). – Fabian Jan 18 '13 at 11:11

The function $x\mapsto\frac1{x-1}$ is defined on the disconnected set $\Bbb R\setminus\{1\}$. Its primitives on the interval $(1,+\infty)$ are functions of the form $x\mapsto \ln(x-1)+C_1$ where $C_1$ is a constant, while its primitives on $(-\infty,1)$ are functions of the form $x\mapsto \ln(1-x)+C_2$ where $C_2$ is a constant; its primitives one the whole domain are any combination of a pair of primitives on these segemnts, so there are now two independent constants of integration.
The usual convention of writing $\int f=g$ where $g$ is some primitive of $f$, implicitly assuming that the general form of a primitive of $f$ is $g+C$ only works well if $f$ has a connected domain. So in particular it does not work well for $f:x\mapsto\frac1{x-1}$ defined on $\Bbb R\setminus\{1\}$. If you write $\int f=g_1$ where $g_1(x)=\ln(x-1)$, which is defined for $x>1$ only, then you have only given a primitive on part of the domain; if you write $\int f=g_2$ where $g_2(x)=\ln(1-x)$, which is defined for $x<1$ only, then you have only given a primitive on a complementary part of the domain, and if you write $\int f=g_3$ where $g_2(x)=\ln|1-x|$ as many do, which is defined on all of the domain of $f$, then you falsely suggest that one is obliged to choose the constants of integration to be equal on both components of the domain. So there is no really good solution here.
Apparently your CAS has chosen to write $\int f=g_1$ here, but $\int -f=-g_2$. That may seem inconsistent, since $-f$ is surely defined on the same domain as $f$ is, but neither is entirely wrong, they are just part of the truth. And it is hard to design computer algebra software that must make arbirtrary choices in such a way that the end result never seems inconsistent. Combining the two parts in an equality statement now leads to rewriting equation that looks patently valid into something that is nonsensical, as it is comparing expressions that are defined on disjoints sets. But with indefinite integration you can expect to find even worse than this occasionally, namely that equating the primitives of two expressions that are equivalent (and everywhere defined) leads to an equation that is always false, namely one equating two expressions that differ by a constant (obtained by choosing different constants of integration when finding primitives for both expressions).