# Understanding the result of this integral (partial fractions)

Evaluating the integral $$\int \frac{x^2 -2x+13}{(x-2)(x^2+2x+5)} dx$$ using partial fractions I obtained $$\ln \vert x -2|-2 \arctan\left(\frac{x+1}{2}\right) +c_1$$ The answer given in the textbook is $$\ln \vert x -2|+2 \arctan\left(\frac{2}{x+1}\right) +c_2$$ WolframAlpha gave the answer $$\ln (2-x) +2 \arctan\left(\frac{2}{x+1}\right) +c_3$$ when inputting the initial fraction directly, and the answer $$\ln (x -2)-2 \arctan\left(\frac{x+1}{2}\right) +c_4$$ when I entered it in partial fraction form.

I tried plotting the graphs of each of these functions (shown below) to understand what's going on, but I'm still confused as to which of these is/are correct, and where the discrepancies arise from.

In each of the regions $$(- \infty,1)$$,$$(-1,2)$$ and $$(2, + \infty)$$ each graph is the same shape (if it is defined in that region), so the difference is only in the constants of integration. However, the WolframAlpha answer defined for $$x<2$$ (which I have taken to be correct for this region) is not continuous in this region, whereas my answer is, which I presume makes it incorrect?

The textbook answer follows the shape of the WolframAlpha answer for $$x<2$$, but is also defined for $$x>2$$. For it to follow the shape of both of the WolframAlhpa graphs simultaneously, it requires them to have different constants of integration; if both of the WolframAlpha answers are required to fully describe this integral in two regions, can they have different constants of integration?

The conversion of $$\ln|x-2|$$ to $$\ln(2-x)$$ is a product of forgetting the antiderivatives of $$\frac1x$$ are of the form $$\ln x+c_+$$ for $$x>0$$ and $$\ln(-x)+c_-$$ for $$x<0$$. (As for its being $$2-x$$ rather than $$x-2$$, I'm guessing that either your partial fractions included a $$2-x$$ denominator instead of an $$x-2$$ one, or their algorithm prefers the $$a-x$$ option over $$x-a$$.)
The identity $$\arctan\frac1x=\frac{\pi}{2}-\arctan x$$ for $$x>0$$ (for $$x<0$$, the fraction becomes $$\frac{-\pi}{2}$$) explaines the $$+2\arctan\frac{2}{x+1}$$ answers.
Let's discuss this more carefully than the software did. The odd antiderivative of $$\frac{1}{1+x^2}$$ is $$\arctan x$$, and unlike the case of $$1/x$$, there's no discontinuity to complicate the family of antiderivatives. You're trying to integrate $$\frac{1}{x-2}-\frac{4}{x^2+2x+5}$$. So if we want an $$\Bbb R\mapsto\Bbb R$$ antiderivative, the most general result is $$\ln|x-2|-2\arctan\frac{x+1}{2}+C$$, where $$C$$ is locally constant but can assume different values on either side of $$x=2$$. (This is due to integrating the $$\frac{1}{x-2}$$.) It's erroneous of software to try $$2\arctan\frac{2}{x+1}$$, since unlike any true antiderivative of $$\frac{1}{x^2+4x+5}$$ this function has different left- and right-hand limits at $$x=-1$$.
• Thanks, this answer is extremely helpful - a lot of my confusion stemmed from the $\arctan \left(\frac{2}{1+x}\right)$ terms but that identity clears up how they were obtained. When you refer to the 'odd antiderivative' is that just the property of $\arctan x$ being an odd function? Commented Oct 23, 2019 at 18:41