# Integration by partial fractions with complex numbers

I learned you should use integration by partial fractions when the discriminant $D\ge0$ but are you allowed to use it in other cases?

For example take the integral $I=\int{2x-1\over x^2+1}dx$
The traditional way to solve it is: $$I=\int{d(x^2+1)\over x^2+1}-\int{dx\over x^2+1}=\ln(x^2+1)-\arctan(x)+c_1$$

With partial fractions: $${2x-1\over x^2+1}=\frac{A}{x+i}+\frac{B}{x-i}=\frac{(A+B)x+(B-A)i}{x^2+1} \\ \Leftrightarrow \left\{ \begin{array}{c} A+B=2 \\ (B-A)i=-1 \\ \end{array} \right.\Leftrightarrow \left\{ \begin{array}{c} B=2-A \\ (B-A)=i \\ \end{array} \right.\Leftrightarrow \left\{ \begin{array}{c} B={2+i\over2} \\ A={2-i\over2} \\ \end{array} \right. \\ \Leftrightarrow I=A\int{dx\over x+i}+B\int{dx\over x-i}={2-i\over2}\ln|x+i|+{2+i\over2}\ln|x-i|+c_2$$

Is this correct?
How does ${2-i\over2}\ln|x+i|+{2+i\over2}\ln|x-i|+c_2$ simplify to $\ln(x^2+1)-\arctan(x)+c_1$? I checked for $x=0$ and the constants aren't equal.

The formula $\int \frac 1 {x+i} \, dx =\ln |x+i|$ is not valid. In fact the left side is a complex valued function and the right side is real valued. You have borrowed a formula valid for real the real case and applied it to the case.
You made a mistake at the point where you said $(B-A)i=-1$. It should be $(B-A)i=1$. This implies that $B=1-i/2$ and $A=1+i/2$.
• No it should be $(B-A)i=-1$. The mistake I made was ${2x+1\over x^2+1}$ instead of ${2x-1\over x^2+1}$. It should be fixed now. – fejfo Jun 26 '18 at 10:32
• The next comment I have is that the primitive of $\frac{1}{x+i}$ is given by $\log(x+i)$ although you should think about on which branch you define the logarithm. Moreover, you should also think about on which contour you are integrating, because every time you circle around $-i$ or $+i$, the integral will increase by $2\pi i$. – Stan Tendijck Jun 26 '18 at 10:49
• I would specify that you are integrating over real positive $x$ (it is then not too hard to generalize it for all real $x$, I think) – Stan Tendijck Jun 26 '18 at 10:50