# How can I find a condition for convergence of an integral? [closed]

Wolfram|Alpha says that

$$\int_0^\infty \frac{x^n}{(x-1)(x-2)} dx=\pi (1-2^n)(\cot(\pi n)+i)$$

for $$\text{Re}(n)>-1$$. However, for $$n=0$$, it says the integral doesn't converge, even though it has Cauchy principal value of $$-\ln2$$.

So what is the condition for the integral to converge? And why does it say it's $$\text{Re}(n)>1$$?

New contributor
Faoler is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
• Welcome to Mathematica Stack Exchange! WolframAlpha questions are explicitly off-topic here. If you have questions about using Mathematica itself, then this is the place to ask! Commented 2 days ago
• Re(n) > -1 is necessary because if Re(n) ≦ -1 the integrand diverges too fast as x → 0. Commented 2 days ago

\$Version
(*"14.0.0 for Microsoft Windows (64-bit) (December 13, 2023)"*)

A = Integrate[x^n/((x - 1)*(x - 2)), {x, 0, Infinity},
GenerateConditions -> True, PrincipalValue -> True]

(* ConditionalExpression[-((-1 + 2^n) \[Pi] Cot[n \[Pi]]), Re[n] > -(3/2)] *)

Limit[A[[1]], n -> 0]
(*-Log[2]*)

f[n_?NumericQ] := NIntegrate[x^n/((x - 1)*(x - 2)), {x, 0, Infinity}, Method -> "PrincipalValue", Exclusions -> (x - 1)*(x - 2) == 0, MaxRecursion -> 20];
g[n_] := -((-1 + 2^n)  \[Pi]  Cot[n  \[Pi]]);

Show[{Plot[g[n], {n, -1, 1}, PlotStyle -> {Black}],
ListLinePlot[Table[{n, f[n]}, {n, -1, 1, 1/25}],
PlotStyle -> {Dashed, Red}]}] // Quiet(*A nice plot *)

• @MariusIwaniuk Nice solution! I'm wondering why f[n] for n>1 doesn't evaluate. Any ideas? Commented 2 days ago
• @UlrichNeumann A good question. With: Integrate[x^n/((x - 1)*(x - 2)) /. n -> 7/3, {x, 0, 3/2}, PrincipalValue -> True] + Integrate[x^n/((x - 1)*(x - 2)) /. n -> 7/3, {x, 3/2, Infinity}, PrincipalValue -> True] == Integrate[x^n/((x - 1)*(x - 2)) /. n -> 7/3, {x, 0, Infinity}, PrincipalValue -> True] is True. With NIntegrate dosen't work!. Maybe you can add a new question about yours findings in the comment ? Commented 2 days ago