Re: Wolfram, meet Stefan and Boltzmann
- To: mathgroup at smc.vnet.net
- Subject: [mg117399] Re: Wolfram, meet Stefan and Boltzmann
- From: "Emilio Martin-Serrano" <emartinserrano at telefonica.net>
- Date: Thu, 17 Mar 2011 06:32:31 -0500 (EST)
First, quit the Kernel On my Intel i5, 3.2 GHz (4 Gb Ram) In[1]:= Timing[Integrate[x^3/(Exp[x] - 1), {x, 0, Infinity}]] Out[1]= {1.731, \[Pi]^4/15} In[2]:= Timing[Integrate[x^3/(Exp[x] - 1), {x, 0, Infinity}]] Out[2]= {0.078, \[Pi]^4/15} -----Mensaje original----- De: Daniel Lichtblau [mailto:danl at wolfram.com] Enviado el: martes, 15 de marzo de 2011 12:03 Para: mathgroup at smc.vnet.net Asunto: [mg117316] Re: Wolfram, meet Stefan and Boltzmann 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]] Out[22]//InputForm= -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 used. 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