# Integrate diverges for convergent integral, and returns unnecessary condition

I'm trying to solve an infinite integral using Mathematica. For some reason, Mathematica claims the integral diverges although when solving to a finite limit L and taking L->Infinity results in a finite expression. Also, the finite integration gives a ConditionalExpression, even though the conditions are unnecessary (solving the integral explicitly outside them using Assuming gives the same result).

The integral I'm trying to solve is:

func = p x^3/((x^2 + 1) ((x - p)^2 + 1))
Integrate[func, {x,-Infinity, Infinity}]


As an infinite integral, it fails. Instead, I performed the integration to a limit L>0, and then taken L->Infinity:

int = Assuming[L \[Element] Reals && L > 0, Integrate[func, {x, -L, L}]]
Limit[int, {L -> Infinity}]


This gives a ConditionalExpression:

ConditionalExpression[(p^2 (3 + p^2) \[Pi])/(4 + p^2), ! (Im[p] >= 1 || Im[p] <= -1)]


I thought maybe the infinite case fails because of the condition, so I explicitly separated into cases using even more Assuming statements:

(*Case #1:*)
int = Assuming[L \[Element] Reals && L > 0 && Abs[Im[p]] > 1 && L > Abs[Re[p]], Integrate[func, {x, -L, L}]]
Limit[int, {L -> Infinity}]

(*Case #2:*)
int = Assuming[L \[Element] Reals && L > 0 && Abs[Im[p]] < 1 && L > Abs[Re[p]], Integrate[func, {x, -L, L}]]
Limit[int, {L -> Infinity}]

(*Case #3:*)
int = Assuming[L \[Element] Reals && L > 0 && Abs[Im[p]] > 1 && L < Abs[Re[p]], Integrate[func, {x, -L, L}]]
Limit[int, {L -> Infinity}]

(*Case #4:*)
int = Assuming[L \[Element] Reals && L > 0 && Abs[Im[p]] < 1 && L < Abs[Re[p]], Integrate[func, {x, -L, L}]]
Limit[int, {L -> Infinity}]


In all cases the result is the same, just without the condition which appeared before.

There are many similar examples for such behavior. But as far as I know, there's never been a consistent and general explanation of WHY does this happen or how to perform such computations correctly without checking both ways. So in total, I have three general questions:

1. Why did the original integral failed if the finite integral converges at the limit? Is there a general rule for when it happens and how to avoid this behavior?
2. Why did Mathematica add the ConditionalExpression if the result is independent of it? Is there a simpler way of removing or avoiding it when it is indeed unnecessary?
3. Does my integral converge or diverge?

Thanks a lot!

Why did the original integral failed if the finite integral converges at the limit?

Try

func = p  x^3/((x^2 + 1)  ((x - p)^2 + 1))

Integrate[func, {x, -Infinity, Infinity},
GenerateConditions -> False,
PrincipalValue -> True]


Default is False

From help