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?
 A: Let $p=\sqrt{1+\frac{A^2}{B^4}}$ and substitute  $x=Bt$
$$I=\int_0^B \dfrac{1}{A^2 + (B^2-x^2)^2} dx
= \frac1{B^3} \int_0^1 \dfrac{1}{t^4-2t^2+p^2} dt
$$
Decompose  the integrand as
\begin{align}
\frac{1}{t^4-2t^2+p^2} = \frac1{2ps}\left( \frac{t+s}{t^2+st+p}- \frac{t-s}{t^2-st+p}\right)
\end{align}
with $s=\sqrt{2(p+1)}$. Then, integrate to obtain
$$I= \frac{1}{4B^3p}\left(\frac1{\sqrt{2(p+1)}}
\ln\frac {\sqrt{1+p}+\sqrt{2}}{\sqrt{1+p}-\sqrt{2}}
+ \sqrt{\frac2{p-1}}\tan^{-1}\sqrt{\frac2{p-1}}\right)
$$
A: 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*}
A: I don't think those roots are correct.  Any complex roots of a polynomial with real coefficients must come in complex conjugate pairs.  If a+ bi and a- bi are roots then two factors are (x- a- bi) and (x- a+ bi) and their product is $(x-a)^2- (bi)^2= x^2- 2ax+ a^2+b^2$ and that will give a "partial fraction" of the form $\frac{Ax+ B}{x^2- 2ax+ a^2+ b^2}$.
