Indefinite integral of $1/(1+x^2)$ I was studying calculus 1 other day, in the subject of integral of partial fractions, when I perceived that the well know indefinite integral:
$$ \int \dfrac{dx}{1+x^2} $$
could be done another way, just by factoring it in $\mathbb{C}[x]$.
So I did $1+x^2=(x+i)(x-i)$.
Hence 
$$ \dfrac{1}{1+x^2}=\dfrac{A(x-i)+B(x+i)}{1+x^2} $$ for some A, B constants.
It is easy to see that $A=i/2$ and $B=-i/2$. 
Then $$ \int \dfrac{dx}{1+x^2}=\int \left(\dfrac{i/2}{x+i}+\dfrac{-i/2}{x-i} \right) dx = \dfrac{i}{2}\ln{|x+i|}-\dfrac{i}{2}\ln{|x-i|}+c=$$ $$=\dfrac{i}{2}\ln{\left|\dfrac{x+i}{x-i}\right|}+c$$
Finally, my question is: Am I allowed to factorize a polynomial in $\mathbb{C}[x]$ to integrate it, and if I am, what is the relation between the real indefinite integral $\tan^{-1}$ and $\dfrac{i}{2}\ln{\left|\dfrac{x+i}{x-i}\right|}$.
Thank you in advance.
 A: What you've done is correct as far as it goes.  The big complication, which I think might just be the only reason why complex numbers are usually avoided in first-year calculus courses, is that the logarithm ($\ln$ or $\log$) function and the $\arctan$ function are multiple-valued.  The multiple-valued nature of the arctangent is mentioned in the trigometry course you took before taking calculus; that of the logarithm is apparent when you learn that $e^{i\theta} = \cos\theta + i\sin\theta$, recallying that $\cos$ and $\sin$ are not one-to-one.  Once you've seen that exponential functions are trigonometric functions, it might not be too surprising that logarithmic functions are inverse-trigonometric functions.
Later addition: If you write
$$
\begin{align}
\cos x & = \frac{e^{ix}+e^{-ix}}{2} \\  \\  \\
\sin x & = \frac{e^{ix}-e^{-ix}}{2i}
\end{align}
$$
you can then find $y=\tan x$ as a function of $e^{ix}$.  Multiplying the numerator and denominator by $e^{ix}$ you get an expression in which $e^{2ix}$ occurse twice, and with further algebra, you can solve for $e^{2ix}$ and then for $x$ as a function of $y$, if you allow multiple-valued inverse functions.
The conventional way of defining the concept of "function" for the past century or so rules out "multiple-valued" functions, so any use of that term will cause some mathematicians some discomfort.
