<s>[INST] 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?
 [/INST] 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)
$$
</s>