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?
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)
$$
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 &quot;partial fraction&quot; of the form $\frac{Ax+ B}{x^2- 2ax+ a^2+ b^2}$.