Integrating inverse of a polynomial using valid method gives wrong result The integral is:
$$\int \frac{1}{x^2+(x-1)^2}dx$$
One way to integrate inverses of polynomials is to find their roots and find the fractions which when added together, give the original fraction (with the roots being the denominators). For example:
$$\int \frac{1}{x^2-x-2}dx = \int \frac{1}{(x-2)(x+1)}dx\rightarrow \frac{a}{x-2}+\frac{b}{x+1}=\frac{a(x+1)}{(x-2)(x+1)}+\
\frac{b(x-2)}{(x-2)(x+1)}$$
$$\rightarrow ax+a+bx-2b=1 \rightarrow \left\{ 
\begin{array}{c}
ax+bx=0x \\ 
a-2b=1 \\ 
\end{array}
\right. \rightarrow a=\frac{1}{3}, b=-\frac{1}{3}$$
$$\rightarrow \int \frac{1}{x^2-x-2}dx=\int (\frac{1/3}{x-2}-\frac{1/3}{x+1})dx$$
And then solve.
I know this is known, I just wanted to show what I've been taught exactly, no ambiguation.
So about the question. We can open up the squares to get:
$$\int \frac{1}{x^2+(x-1)^2}dx = \int \frac{1}{2x^2-2x+1}dx=\int \frac{1}{2(x-0.5-0.5i)(x-0.5+0.5i)}dx$$
$$\rightarrow \frac{a}{x-0.5-0.5i}+\frac{b}{x-0.5+0.5i}=\frac{1/2}{(x-0.5-0.5i)(x-0.5+0.5i)}$$
I'll spare the details:
$$a=-\frac{i}{2},b=\frac{i}{2}$$
$$\rightarrow \int \frac{1}{x^2+(x-1)^2}dx=\int (\frac{i/2}{x-0.5+0.5i}-\frac{i/2}{x-0.5-0.5i})dx=i(\int \frac{1}{2x-1+i}dx-\int \frac{1}{2x-1-i}dx)$$
Once again sparing the details of some simple u substitution:
$$=\frac{i}{2}(ln\lvert 2x-1+i\rvert-ln\lvert 2x-1-i\rvert)$$
Absolute value (which's added from integrating something to the (-1)) always gives out a real number, and the entire "ln" expression is multiplied by an imaginary number, so the output is always imaginary.
The actual video I took this from contained a completely different solution. It's not even close to mine, which's always imaginary. Why? How did this happen?
Thanks.

consider this instead:
$$\begin{align}
\phantom{=}&x^2+(x-1)^2\\
=&x^2+(x^2-2x+1)\\
=&2x^2-2x+1\\
=&2\left(x-\frac12\right)^2+\frac12\\
=&\frac12\left[4\left(x-\frac12\right)^2+1\right]
\end{align}$$
you can take this half out of the integral (so it becomes two) now first think of the substitution $u=x-\frac12$ so you get:
$$(2u)^2+1$$
now say $2u=\tan v$ and see what you get :)
