# How should I evaluate the numerical integral of a function with divergent part substracted?

I want to evaluate the following integral numerically in Mathematica, $$\int_0^{\infty}(\frac{1}{(1 - e^t)^{10}} - (\frac{1}{t^{10}} - \frac{5}{t^9} + \frac{145}{12 t^8} - \frac{75}{ 4 t^7} + \frac{3013}{144 t^6} - \frac{285}{16 t^5} + \frac{4523}{378 t^4} - \frac{6515}{ 1008 t^3} + \frac{7129}{2520 t^2} - \frac{1}{t}))dt$$ which is convergent since the part that is subtracted from $\frac{1}{(1-e^x)^{10}}$ is essentially the negative powers of the Laurent expansion of $\frac{1}{(1-e^x)^{10}}$ near 0, which is the divergent part.

However, if I directly use NIntegrate in Mathematica, I get a divergent result. This is not too surprising given the unrealistic plot of the integrand near zero: So is there a good way to actually evaluate this numerical integral?

• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. – bbgodfrey Jul 14 '15 at 15:08
• Please write your expressions in Mathematica format. – bbgodfrey Jul 14 '15 at 15:08
• FYI, the oscillation near 0 (caused by rounding error) may not be your only problem; Mathematica complains about slow convergence of the integral even if you integrate from 1 to ∞. – Michael Seifert Jul 14 '15 at 15:26

It seems that your integral effectively diverges. Let's define:

ee[x_] := 1/(1 -E^x)^10
(*div is the divergent part*)
div[x_] := Evaluate[Series[ee[x], {x, 0, -1}] // Normal]
all[x_] := ee[x] - div[x]


You're right that you "killed" the divergence at zero:

Integrate[all[x], {x, 0, 1}] // N
(* 0.253202 *)


But the "original" function's integral was already converging in {1, Infinity}

Integrate[ee[x], {x, 1, Infinity}] // N
(* 0.0002918 *)


While the "new" added part integral diverges in this interval:

Integrate[div[x], {x, 1, Infinity}]


Integrate::idiv: Integral of div[x] does not converge on {1,[Infinity]}. >>

so the whole thing won't converge

As your integral from 1 onwards has a closed (but longish) form, if you want a peep at the divergence form you may evaluate

k = Integrate[all[x], {x, 1, p}, Assumptions -> Element[p, Reals]];
Plot[k, {p, 1, 100}] and

s = k /. p -> 1/u;
Plot[s, {u, -1, 1}, PlotRange -> {{-1, 1}, {0, 10}}] • Thanks for your answer! My intention is how to deal with integrals with their divergence part subtracted. I chose a bad example here since the Laurent expansion contains 1/t term which is divergent. However, even if I evaluate the integral from 0 to 1, say Integrate[ 1/(1 - Exp[t])^10 - (1/t^10 - 5/t^9 + 145/(12 t^8) - 75/(4 t^7) + 3013/(144 t^6) - 285/(16 t^5) + 4523/(378 t^4) - 6515/( 1008 t^3) + 7129/(2520 t^2) - 1/t), {t, 0, 1}], Mathematica still tells me it is divergent. – user110373 Jul 14 '15 at 17:19
• But div[x_] := Evaluate[Series[ee[x], {x, 0, -1}] // Normal] works well. Would you like to elaborate on why it is the case? – user110373 Jul 14 '15 at 17:24
• @user110373 take a look at Series[ee[x], {x, 0, -1}] // Normal ... it lacks the Exp[ ] part ... – Dr. belisarius Jul 14 '15 at 17:26
• You mean the O[x^0] part? But why doesn't it converge if I explicitly subtract the result of Series[ee[x], {x, 0, -1}] // Normal from 1/(1 - Exp[t])^10 and do the integral? – user110373 Jul 14 '15 at 17:31
• @user110373 I don't know how the old version behave but v10.3 gives finite answer of your expression. This question may be due to the bad regulator. I'll post a answer. – luyuwuli Dec 7 '15 at 6:36

I think Taylor expansion is a bad regulator to regulate the divergent part of the integration. The following method is meant to give you a feel of the behavior instead of a concrete solution.

First, rewrite your integration to $$\int_0^\infty dt\, \frac{1}{(1-e^{t+i \epsilon})^{10}}.$$ we will set $\epsilon\to 0$ at last step to see how it behave.

The above integration can be easily done by

Integrate[1/(1 - E^(t + I \[Epsilon]))^10, {t, 0, \[Infinity]}, Assumptions -> \[Epsilon] > 0]


you will get:

$$\frac{num1}{2520 \left(-1+e^{i \epsilon }\right)^9}+\log \left(1-e^{-i \epsilon }\right)$$ $$num1:=-41481 e^{i \epsilon }+120564 e^{2 i \epsilon }-210756 e^{3 i \epsilon }+236754 e^{4 i \epsilon }-173250 e^{5 i \epsilon }+80220 e^{6 i \epsilon }-21420 e^{7 i \epsilon }+2520 e^{8 i \epsilon }+7129$$

the $num1\to 280$ when $\epsilon \to 0$, so Taylor expansion it

Series[280/(2520 (-1 + E^(I \[Epsilon]))^9) + Log[1 - E^(-I \[Epsilon])], {\[Epsilon], 0, 1}]


gives you:

$-\frac{i}{9 \epsilon ^9}-\frac{1}{2 \epsilon ^8}+\frac{13 i}{12 \epsilon ^7}+\frac{3}{2 \epsilon ^6}-\frac{1069 i}{720 \epsilon ^5}-\frac{89}{80 \epsilon ^4}+\frac{29531 i}{45360 \epsilon ^3}+\frac{761}{2520 \epsilon ^2}-\frac{i}{9 \epsilon }-\frac{236250367 i \epsilon }{479001600}+\log (\epsilon )-\frac{2857}{89600}+\frac{i \pi }{2}+O(\epsilon^1)$

Then you can read the singular part.