# Confusion with partial fractions integration of $\frac{1}{1+x^2}$

By partial fractions I've got $$\frac{1}{1+x^2}=\frac{1}{2i}\left(\frac{1}{x-i}-\frac{1}{x+i}\right)$$ Then integrating $$\frac{1}{2i}\int\left(\frac{1}{x-i}-\frac{1}{x+i}\right)dx=\frac{1}{2i}(\ln(x-i)-\ln(x+i))$$ If $x-i=R_1e^{i\phi_1}$ and $x+i=R_2e^{i\phi_2}$ then $$\frac{1}{2i}(\ln(x-i)-\ln(x+i))=\frac{1}{2i}(\ln(R_1)-\ln(R_2)+i(\phi_1-\phi_2))=\frac{1}{2}(\phi_1-\phi_2)$$ But now I put that $\phi_1=\arctan\frac{-1}{x}$ and $\phi_2=\arctan\frac{1}{x}$ so: $$\arctan(x)=^?\frac{1}{2}\left(\arctan\frac{-1}{x}-\arctan\frac{1}{x}\right)$$ I tried some values and looks false. The most confusing thing is that $$\frac{d}{dx}\frac{1}{2}\left(\arctan\frac{-1}{x}-\arctan\frac{1}{x}\right)=\frac{1}{1+x^2}$$(Something is happening with the argument function.) What's the mistake?

EDIT: Hans Lundmark wisely said in a comment there's only thing left: the constant $$\arctan(x)=\frac{1}{2}\left(\arctan\frac{-1}{x}-\arctan\frac{1}{x}\right)+\frac{\pi}{2}$$

Now the question is: how should I find this constant in future integrations?

-
Hint: Two primitives may differ by an additive constant. – Hans Lundmark Aug 27 '12 at 10:38
Looks like the constant is $\frac{\pi}{2}$. Thanks. – dot dot Aug 27 '12 at 10:39

Your error is in the second step: $$\frac{1}{2i}\int(\frac{1}{x-i}-\frac{1}{x+i})dx=\frac{1}{2i}(\ln(x-i)-\ln(x+i))\color{red}{+C}$$
When you do an indefinite integral, never forget the $+C$ part. $C$ here is an arbitrary constant. Also if you do the indefinite integral directly by knowing $\arctan'(x) = 1/(1+x^2)$ you still get $\int 1/(1+x^2)\,\mathrm dx = \arctan(x)+C$.
As how to find the constant: You don't. There's not a single constant which is the correct one for the indefinite integral. All constants are allowed (thus the $+C$). If you have a definite integral, you have $\int_a^b f(x)\,\mathrm dx = (F(b)+C)-(F(a)+C) = F(b)-F(a)$, so the constant simply cancels out.
Of course if you want a certain additional condition (such as, $F(0)=0$), then you can use that to fix the constant. But that's then due to an additional constraint of the solution, not due to the integral itself.