Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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] = 
   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


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).


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.

share|improve this answer
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 '14 at 20:14
I'd have gone a bit farther and use the Shanks transformation: SequenceLimit[Table[res[1, 10^k], {k, 1, 6}]]. – J. M. Jun 3 '15 at 10:29
 lst = Table[{a, 
    NIntegrate[(-(a^2/2) + x (-x + Sqrt[a^2 + x^2]))*
      Tanh[\[Pi]*x], {x, 0, \[Infinity]}]}, {a, 0.2, 1, 0.05}];


enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.