MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Wolfram, meet Stefan and Boltzmann

  • To: mathgroup at
  • Subject: [mg117316] Re: Wolfram, meet Stefan and Boltzmann
  • From: Daniel Lichtblau <danl at>
  • Date: Tue, 15 Mar 2011 06:03:02 -0500 (EST)

AES wrote:
> Responses to all:
> Many of you will recognize that the integral in question
>    Integrate[x^3/(Exp[x] - 1), {x, 0, Infinity}]
> arises in the derivation of the Stefan-Boltzmann constant.  
> I was reviewing this derivation in Wikipedia. Wikipedia's analytical 
> evaluation of the integral itself, given in an Appendix to the 
> Stefan-Boltzmann article, takes a couple of screens of text and a dozen 
> intermediate formulas, with excursions into contour integration and 
> infinite series expansions.  
> I became curious as to whether Mathematica could "just do" this integral 
> so I opened Mathematica, typed in the line above, and evaluated it.  I 
> was surprised at how long it took the first time, although reevaluation 
> of the same cell was essentially instantaneous.
> So I shut down Mathematica; re-Opened it; and repeated the evaluation 
> using Timing[-].  Did this several times, and found that from a "cold 
> start", that is, when I Quit and then re-Open Mathematica, it always 
> takes 18 or 19 seconds to do the first evaluation.
> My Mac is a 2007 or 2007 vintage MacBook with hardware overview given 
> below, running Snow Leopard in a generally vanilla setup (only about 60 
> GB occupied on the 160 GB HD).  
> So, I'm still a bit curious:  What's Mathematica doing all that time? -- 
> loading a lot of other stuff?  actually going through some lengthy 
> algorithm to evaluate the integral?   ???
> Hardware Overview:
>   Model Name:  MacBook
>   Model Identifier:  MacBook2,1
>   Processor Name: Intel Core 2 Duo
>   Processor Speed:   2.16 GHz
>   Number Of Processors: 1
>   Total Number Of Cores:   2
>   L2 Cache: 4 MB
>   Memory:   1 GB
>   Bus Speed:   667 MHz
>   Boot ROM Version:  MB21.00A5.B07
>   SMC Version (system): 1.17f0

Offhand I do not know why it is so slow for that first evaluation. I 
will make several comments on the questions raised here.

* There is a startup time for loading some mx files used in Integrate. 
It should be negligeable in comparison to the time to integrate this 
example. On my faster machine it takes around 1.5 seconds, or which i 
would guess no more than .1 involves package loading. To check whether 
loading might be a problem on the macBook (I doubt that it is), could do 
as follows.

(i) Open a new kernel.
(ii) Evaluate
Integrate[x^4/(Exp[x] - 1), {x, 0, Infinity}]
(note different power of x). This will cause the same autoloading, but 
not likely have anything cached that would se3rve to improve the next step.
(iii) Evaluate Timing[your integral].

* A second evaluation can be much faster because some of the key 
computations needed were cached in the first computation. As to what 
these are, more below.

* Integrate, for definite integrals, will check for convergence at the 
endpoints and also look for interior path singularities. If any are 
found, it will again do convergence checks.

* In the case of this integral the Newton-Leibniz method is used. That 
is to say, we find an antiderivative and work out limits as needed.

So the steps are as follows.

(1) Check for convergence at 0 and infinity.

(2) Look for path singularities of the integrand. This often involves 
hard core technology like solving transcendental equation. For this 
example, the only candidate located is zero. We discard it because it is 
an endpoint, hence already will get special handling (via Limit).

(3) Find the antiderivative. It is

In[22]:= InputForm[Integrate[x^3/(Exp[x] - 1), x]]

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

(4) Check for path singularities of the antiderivative. Needed because 
an off-path singularity in the integrand could lead to a branch cut 
crossing on the path for the antiderivative. In this example I would 
surmise a bit of time is spent checking the antiderivative.

(5) If singularities are found, check for convergence. If confergence is 
fine, split the path. Exception: Not necessary if seeming singularities 
have the same limits for antiderivative, when approaching from both 
directions along integration path.

(6) Take limits at endpoints.

As for caching, I know that the antiderivative and the various limits 
(and any calls to Series on which Limit might rely) will be cached. 
Moreover intermediate simplifications might happen, and some parts of 
those computations will be cahced e.g. polynomial gcds, if any such are 

One respondent commented to the effect that this was significantly 
faster in version 4.2. This was because several of the above steps were 
done in more heuristic, and less reliable, ways. That said, it is quite 
possible that there are redundent steps, and steps that could be made 
faster, in the framework of the present methodology. I an cautiously 
hopeful that this will get some attention in future development.

Daniel Lichtblau
Wolfram Research

  • Prev by Date: Re: Joining points of ListPlot
  • Next by Date: Re: Vectorized molecular dynamics with Mathematica?
  • Previous by thread: Re: Wolfram, meet Stefan and Boltzmann
  • Next by thread: Re: Wolfram, meet Stefan and Boltzmann