# Making mathematica do regulated integrals

Consider the integration, $\int _0 ^\infty dx\ x \tanh( \pi x) \sqrt {x^2 + a^2 }$ where $a$ is a real number. This integral is divergent. We note that an asymptotic expansion of the integrand about $x =\infty$ reveals it to have an expansion of the kind, $x^2 \tanh(\pi x) + \frac{a^2}{2} \tanh (\pi x ) + O(\frac{1}{x})$

So we can think of "defining" the regulated value of the integral as the quantity that one gets after subtracting off the asymptotic divergence. Hence a possibly sensible definition is to say,

$Limit _ {M \rightarrow \infty} \left [ \int _0 ^M dx \left ( x \tanh( \pi x) \sqrt {x^2 + a^2 } \right ) - \int_0 ^M dx \left ( x^2 \tanh(\pi x) + \frac{a^2}{2} \tanh (\pi x ) \right ) \right ]$

I believe that the above is a finite quantity.

• I would like to know how Mathematica can be gotten to compute this above quantity (may be numerically) for any given $a$

If you are worried about motivations then you can think of QFT.

-

This is at least how I might start such a problem:

First define a function that calculates the numerical integral (using your definition) from 0 to some number:

res[a_?NumericQ, xmax_?NumericQ] :=
res[a, xmax] =
NIntegrate[
x Tanh[Pi x] Sqrt[x^2 + a^2] - (a^2/2 + x^2) Tanh[\[Pi] x], {x, 0,
xmax}, WorkingPrecision -> 50]


You might notice that I have creates res so that it remembers its own values, I anticipate doing some convergence testing later on and it will advantageous to compare results from previous iterations. Let's look at what happens for a=1 and how it converges as xmax gets larger:

Table[res[1, 10^k], {k, 1, 6}] // Column

-0.24096925502781039966521184956775599060753002795837
-0.25219852026366828610735207978092785006490868055453
-0.25332349945194948923463448538767761252993540030015
-0.25343599943113699704705245414034688189614734489415
-0.25344724943111618454713057835870625693748849071056
-0.25344837443111616373463057913994844439842599461908


its looks decently well behaved, so I might have luck with a function that looks for convergence to a certain number of "digits"

conv[a_?NumericQ, d_?NumericQ] := {10^#, res[a, 10^#]} &@
FixedPoint[# + 1 &, 1,
SameTest -> (-Log10@
Abs[(res[a, 10^#1] - res[a, 10^#2])/res[a, 10^#1]] > d &)]


I happened to have this function also output the xmax needed as well, but it's certainly not needed. Here's a test case (again a=1) (where I want to get 5 "digits"):

conv[1, 5]
(* {1000000,  -0.25344837443111616373463057913994844439842599461908} *)


You might find you will need to go back and adjust the working precision or other options for NIntegrate to various values of a and xmax)

You can also look at NLimit (and please read the docs for it so you can see how its approximating the limit).

Needs["NumericalCalculus"]

NLimit[res[1, xmax], xmax -> ∞, WorkingPrecision -> 50]
(* -0.253448526436653269615367431483292411155527711 *)


Personally, I would use the previous approach, but that's my "cautious" side and lets me set a goal of how converged of a result I want.

-
SO taking the "limit" will not work? As in Mathematica knows how to take "limits" - right? So can't one use that inbuilt feature somehow? –  user6818 Apr 16 at 20:14
 lst = Table[{a,
`