# Solving divergent Integral

I want to solve this integral.

using Integrate I get it done, but the problem is it results in complex values, which is incorrect for my problem (has no physical meaning).

I'd like to know if there's any other way to solve these kinds of integrals in Mathematica? Is NIntegrate acceptable in such cases? since I get real values using NIntegrate, but I'm not sure that would be the correct result.

Integrate[(((1 + x*Exp[-a*y])/(1 - x*Exp[-a*y]))^2 - 1)*(1 - y)^3, {y,
0, 1}]



*N.B. x and a are constant values.

• I get -((4 (a^2 (a/(-1+x)-3 Log[-1+x]+3 Log[x])+6 a PolyLog[2,1/x]+6 PolyLog[3,1/x]-6 PolyLog[3,E^a/x]))/a^4) Mar 14 at 16:42
• yes, thanks. I get the same, so I suppose I should only take the real values, not the imaginary ones? because with my constants for a and x, it results in complex numbers. unless I use NIntegrate. @asukaminato
– lia
Mar 14 at 17:19
• What values are you using for a and x? Mar 14 at 18:06
• Just to compare. The command of Maple 2024 int(((1 + x*exp(-a*y))^2/(1 - x*exp(-a*y))^2 - 1)*(1 - y)^3, y = 0 .. 1) assuming (a::real, x::real) correctly calculates the integral under consideration. Mar 15 at 12:04

## 3 Answers

This is the condition cond under which the integral converges (and is real for real a and x):

cond = a == 0 && x ≠ 1 || a > 0 && (x < 1 || x >= E^a) ||
a < 0 && (x > 1 || x <= E^a)


I found the condition half manually, Mathematica alone was not able to solve it.

For special case of the condition a == 0 && x ≠ 1 it is:

int = (((1 + x*Exp[-a*y])/(1 - x*Exp[-a*y]))^2 - 1)*(1 - y)^3 // Factor

Integrate[int /. a -> 0, {y, 0, 1}]


$$-\frac{4 x (y-1)^3 e^{a y}}{\left(e^{a y}-x\right)^2}$$

$$\frac{x}{(x-1)^2}$$

For other cases of the condition cond it is

Integrate[int, {y, 0, 1}] // FullSimplify


(1/(a^4))4 (-((a^3 x)/(-1 + x)) + 3 a^2 Log[1 - x] +
6 a PolyLog[2, x] - 6 PolyLog[3, x] + 6 PolyLog[3, E^-a x])


Testing whether integral converges for specific values - True means it converges False the opposite:

cond /. a -> 1 /. x -> 2
cond /. a -> 1 /. x -> 1/10
cond /. a -> 1 /. x -> 10


False

True

True


This is the region of convergence for a and x:

RegionPlot[cond, {a, -10, 10}, {x, -10, 10}, PlotPoints -> 200,
FrameLabel -> Automatic]


If you consider (0<x<1) and positive a then the result can be put into a form giving real results by using the inversion property of the polylogs as shown in the plot:

0 < x < 1, 0 < a

x = 0.999; LogPlot[{NIntegrate[(4*E^(a*y)*
x*(1 - y)^3)/(E^(a*y) - x)^2, {y, 0, 1}],
(4*x)/(a*(1 - x)) + (12*Log[1 - x])/a^2 + (24*PolyLog[2, x])/
a^3 - (24*PolyLog[3, x])/a^4 +
(24*PolyLog[3, x/E^a])/a^4}, {a, 0.01, 4}, PlotRange -> All,
PlotStyle -> {Automatic, Dashed}]


for 1 < x and negative a you can use the form given in your post above:

1 < x, a < 0

x = 1.01; LogPlot[{NIntegrate[(4*E^(a*y)*
x*(1 - y)^3)/(E^(a*y) - x)^2, {y, 0, 1}],
-(4/(a*(x - 1))) + (12*Log[(x - 1)/x])/
a^2 - (24*PolyLog[2, 1/x])/a^3 -
(24*PolyLog[3, 1/x])/a^4 + (24*PolyLog[3, E^a/x])/
a^4}, {a, -4, -0.001}, PlotRange -> All,
PlotStyle -> {Automatic, Dashed}]


• NIntegrate[(4*E^(a*y)*x*(1 - y)^3)/(E^(a*y) - x)^2 /. {x -> 1.01, a -> 2}, {y, 0, 1}] results in 538096. and "NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in y near {y} = {0.0053386}. NIntegrate obtained 538095.9251324619 and 444170.8516817697 for the integral and error estimates". Mar 15 at 18:25
• for x>1 you need negative a Mar 15 at 19:59
• I mean NIntegrate hardly handles divergent improper integrals. Mar 16 at 15:07

First,

j = Integrate[(((1 + x*Exp[-a*y])/(1 - x*Exp[-a*y]))^2 -
1)*(1 - y)^3, {y, 0, 1}, Assumptions -> {a, x} \[Element] Reals,
GenerateConditions -> False]


-(1/(a^4 (-1 + x))) 4 (a^3 + 3 a^2 Log[1 - E^a/x] - 3 a^2 x Log[1 - E^a/x] + 3 a^2 Log[1 - x] - 3 a^2 x Log[1 - x] - 3 a^2 Log[E^a - x] + 3 a^2 x Log[E^a - x] + 6 a (-1 + x) PolyLog[2, 1/x] + 6 (-1 + x) PolyLog[3, 1/x] + 6 PolyLog[3, E^a/x] - 6 x PolyLog[3, E^a/x])

Second,

FunctionDomain[j, x]//FullSimplify


x < 0 && x < E^a

Third, its partial verification

j /. {a -> 0.25, x -> -10}e


-0.0861123

NIntegrate[(((1 + x*Exp[-a*y])/(1 - x*Exp[-a*y]))^2 -
1)*(1 - y)^3 /. {a -> 0.25, x -> -10}, {y, 0, 1}]


-0.0861123

Addition. In 14.0 on Windows 10

Integrate[(((1 + x*Exp[-a*y])/(1 - x*Exp[-a*y]))^2 - 1)*
(1 - y)^3, {y, 0, 1}, Assumptions -> {a, x} \[Element] Reals, GenerateConditions -> True]//FullSimplify


ConditionalExpression[ 1/a^4 4 (a^2 (-(a/(-1 + x)) + 3 Log[-1 + x] - 3 Log[x]) - 6 a PolyLog[2, 1/x] - 6 PolyLog[3, 1/x] + 6 PolyLog[3, E^a/x]), E^a x < x^2 && x < 0 && (Re[Log[x]/a] > 1 || Re[Log[x]/a] < 0 || Log[x]/a \[NotElement] Reals)]

The result is false as

RegionPlot[ E^a  x < x^2 &&  x < 0 && (Re[Log[x]/a] > 1 || Re[Log[x]/a] < 0 ||
Log[x]/a \[NotElement] Reals), {a, -5, 5}, {x, -5, 5}]


shows.

Addition 2. For the user's convenience, I'd like to complete the answer by @azerbajdzan. The singularity of the integrand is found by

Reduce[1 - x*Exp[-a*y] == 0, y, Reals]


(a == 0 && x == 1) || (a != 0 && x > 0 && y == Log[x]/a

The singularity at y == Log[x]/a is not integrable, as the result of

Series[(((1 + x*Exp[-a*y])/(1 - x*Exp[-a*y]))^2 - 1)*(1 - y)^3,
{y,Log[x]/a, 1}] // Normal


$$\frac{4 (a-\log (x))^3}{a^5 \left(y-\frac{\log (x)}{a}\right)^2}-\frac{12 (a-\log (x))^2}{a^4 \left(y-\frac{\log (x)}{a}\right)}+\left(\left(1-\frac{\log (x)}{a}\right)^2-\frac{4}{a^2}\right) \left(y-\frac{\log (x)}{a}\right)-\frac{\left(a^2-2 a \log (x)+\log ^2(x)-36\right) (a-\log (x))}{3 a^3}$$

shows.

Therefore, Log[x]/a has not to belong to $$[0,1]$$ or to have the non-zero imaginary part. This leads to the equation

Reduce[Log[x]/a < 0 || Log[x]/a > 1 ||
ComplexExpand[Im[Log[x]/a]] != 0, {x, a}, Reals] // FullSimplify


(x < 0 && a != 0) || (0 < x < 1 && (Log[x] < a < 0 || a > 0)) || (x > 1 && (a < 0 || 0 < a < Log[x]))

Let us show it by

RegionPlot[(x < 0 &&
a != 0) || (0 < x < 1 && (Log[x] < a < 0 || a > 0)) || (x >
1 && (a < 0 || 0 < a < Log[x])), {a, -5, 5}, {x, -5, 5}]


Now we turn to the integral

Integrate[(((1 + x*Exp[-a*y])/(1 - x*Exp[-a*y]))^2 - 1)*
(1 - y)^3, {y,  0, 1}, Assumptions -> (x < 0 &&
a != 0) || (0 < x < 1 && (Log[x] < a < 0 || a > 0)) ||
(x >  1 && (a < 0 || 0 < a < Log[x])), GenerateConditions -> False]


-(1/(a^4 (-1 + x))) 4 (a^3 + 3 a^2 Log[1 - E^a/x] - 3 a^2 x Log[1 - E^a/x] + 3 a^2 Log[1 - x] - 3 a^2 x Log[1 - x] - 3 a^2 Log[E^a - x] + 3 a^2 x Log[E^a - x] + 6 a (-1 + x) PolyLog[2, 1/x] + 6 (-1 + x) PolyLog[3, 1/x] + 6 PolyLog[3, E^a/x] - 6 x PolyLog[3, E^a/x])

Finally, it remains to consider

Integrate[(((1 + x*Exp[-a*y])/(1 - x*Exp[-a*y]))^2 - 1)*
(1 - y)^3, {y, 0, 1}, Assumptions -> a == 0 && x != 1]


x/(-1 + x)^2

• Function domain of the output of the integral does not have to coincide with domain where the integral is convergent in case we have some parameters that the integral is dependent on. Integral converges not only for x<0 as is indicated by output of FunctionDomain. Mar 14 at 19:32
• @three777:Yes, I am aware of it, but the answer is produced programmatically, not by hand. Mar 14 at 19:41
• [CASE:5122702] about the wrong result of Integrate[(((1 + x*Exp[-a*y])/(1 - x*Exp[-a*y]))^2 - 1)* (1 - y)^3, {y, 0, 1}, Assumptions -> {a, x} \[Element] Reals, GenerateConditions -> True]//FullSimplify has been submitted by me. Mar 14 at 23:46