Evaluating $\int_0^B \frac{1}{A^2 + (B^2-x^2)^2}\,dx$ I am trying to solve the following integral:
$$\int_0^B \frac{1}{A^2 + (B^2-x^2)^2}\,dx$$
However the polynomial have imaginary roots:
$$-(-i A + B^2)^{1/2},\; (-i A + B^2)^{1/2},\; -(i A + B^2)^{1/2},\;(i A + B^2)^{1/2}$$
I am only interested on the solution from $0$ to $B$. How should I proceed?

Using the variable change $x\to Bx$, one can immediately reduce to the case $B=1$. If $A$ is real, we have:
\begin{align*}
\int_0^1\frac1{A^2+(1-x^2)^2}dx&=\frac1{2Ai}\int_0^1\left[\frac1{(x^2-1)-Ai}-\frac1{(x^2-1)+Ai}\right]dx\\
&=\frac1A\Im\left(\int_0^1\frac1{(x^2-1)-Ai}dx\right)\\
&=\frac1A\Im\left(\frac1{2\sqrt{1+Ai}}\int_0^1\left[\frac1{x-\sqrt{1+Ai}}-\frac1{x+\sqrt{1+Ai}}\right]dx\right),
\end{align*}
where $\Im$ denotes the imaginary part. This then just reduces to the sum of a few logarithms.
Alternatively, from the second line we may immediately obtain:
\begin{align*}
\frac1A\Im\left(\int_0^1\frac1{(x^2-1)-Ai}dx\right)&=\frac1A\Im\left(\frac1{\sqrt{1+Ai}}\arctan\left(\frac 1{\sqrt{1+Ai}}\right)\right).\\
\end{align*}
