Analysis

An area that is a sum of n to the minus n

The area under the curve x to the power minus x, between 0 and 1, is 1 + 1/4 + 1/27 + 1/256 + …, the sum of 1/n^n. Johann Bernoulli found it in 1697, and it is called the sophomore's dream because it looks like the mistake of a student who integrates term by term without checking — except that it is true. The proof expands the exponential into layers, each with an exact area, and every layer peaks at the same point, 1/e. The peaks hold Stirling's formula, and seven terms of the series beat a thousand samples of the curve.

Worth reading first: Adding up rectangles until they stop being rectangles · Where to take the samples.

Some identities look like errors. A student asked for ∫01x−x dx\int_0^1 x^{-x}\,dx might hope that the answer is the sum of n−nn^{-n}, the way a student asked to square a+ba + b hopes the answer is a2+b2a^2 + b^2. The second hope is wrong. The first is right:

∫01x−x dx=∑n=1∞1nn=1+14+127+1256+⋯=1.29128599706266…\int_0^1 x^{-x}\,dx = \sum_{n=1}^{\infty} \frac{1}{n^n} = 1 + \frac{1}{4} + \frac{1}{27} + \frac{1}{256} + \cdots = 1.29128599706266\ldots

Johann Bernoulli published it in 1697, together with its companion

∫01xx dx=1−14+127−1256+⋯=0.78343051071213…,\int_0^1 x^{x}\,dx = 1 - \frac{1}{4} + \frac{1}{27} - \frac{1}{256} + \cdots = 0.78343051071213\ldots,

and it was later nicknamed the sophomore’s dream — the dream being that this is how integration always works. It is not, and the reason it works here, and nowhere near as cleanly almost anywhere else, says something about the curve that the picture of the curve does not show at all. Adding up rectangles defined an area as a limit of sums of rectangles; this essay finds an area that is a sum of a very different kind, where every term is itself an exact area and the terms run out faster than any power.

Two curves that turn at 1/e

Two areas that are sums of n^(−n). int x^-x = 1.29128599706266; int x^x = 0.78343051071213
Fig. 1 The curves x−xx^{-x} and xxx^x between 0 and 1. Their areas, computed by quadrature to twelve places, match the two sums to every digit shown.

The curve xxx^x is defined for positive xx as exln⁡xe^{x \ln x}, and as xx shrinks to zero, xln⁡xx \ln x shrinks to zero too — the logarithm runs off to minus infinity, but more slowly than xx falls — so xxx^x tends to 11. At x=1x = 1 it is 11 again. In between it dips: its logarithm xln⁡xx \ln x has derivative ln⁡x+1\ln x + 1, which vanishes at x=1/ex = 1/e, so xxx^x is smallest there, with value e−1/e=0.6922e^{-1/e} = 0.6922. Its reciprocal x−xx^{-x} is a hump with the same ends and a maximum of e1/e=1.4447e^{1/e} = 1.4447 at the same point.

Neither curve has an elementary antiderivative, so the fundamental theorem of area as the undoing of slope does not apply. The areas have to be computed some other way, and the figure computes them by Gauss–Legendre quadrature after the substitution x=u2x = u^2, which smooths out the steep start of both curves near zero: ∫01x−x dx=1.291285997063\int_0^1 x^{-x}\,dx = 1.291285997063 and ∫01xx dx=0.783430510712\int_0^1 x^x\,dx = 0.783430510712. Adding 1/nn1/n^n for nn from 1 to 30 gives the first number to sixteen digits, and adding ±1/nn\pm 1/n^n gives the second. The agreement is the identity. What remains is to see why.

The point 1/e1/e will keep appearing. It is where −xln⁡x-x \ln x is largest, and −xln⁡x-x \ln x is the quantity everything else is built from. Its maximum value is 1/e1/e as well, which will matter shortly: on the whole interval, 0≤−xln⁡x≤1/e0 \le -x \ln x \le 1/e.

The proof is a stack of layers

The curve built from its series, layer by layer. layer 0: 1.000000000; layer 1: 0.2500000000; layer 2: 0.03703703704; layer 3: 0.003906250000; layer 4: 0.0003200000000
Fig. 2 The curve x−xx^{-x} rebuilt from its exponential series, one layer at a time. Each layer is (−xln⁡x)n/n!(-x \ln x)^n/n!, and each has an exact area, 1/(n+1)n+11/(n+1)^{n+1}.

Write x−x=e−xln⁡xx^{-x} = e^{-x \ln x} and expand the exponential in its power series, which the curve that is its own slope built:

x−x=∑n=0∞(−xln⁡x)nn!.x^{-x} = \sum_{n=0}^{\infty} \frac{(-x \ln x)^n}{n!}.

Each term is a curve on [0,1][0, 1], and the figure stacks them. The bottom layer is the constant 1, below the window. The next is −xln⁡x-x \ln x, a hump of height 1/e1/e; the next (xln⁡x)2/2(x \ln x)^2/2, a smaller hump; and so on. With five layers the stack is within a few ten-thousandths of x−xx^{-x} everywhere, and the dashed curve is barely distinguishable from the top of the stack.

The proof is two steps. First, the area of the whole is the sum of the areas of the layers. That is not automatic — a limit that forgets to be continuous showed how integrating a limit and taking the limit of integrals can disagree — but here it holds for a strong reason. Since −xln⁡x-x \ln x never exceeds 1/e1/e, the nn-th layer never exceeds (1/e)n/n!(1/e)^n/n!, and these bounds have a finite sum. The series therefore converges uniformly on the interval: the gap between the stack of the first kk layers and the curve is at most the tail of the bounds, which shrinks to zero independently of xx. The figure checks that the gap after five layers is below the bound (1/e)5/5!⋅e1/e(1/e)^5/5! \cdot e^{1/e}. The bound is generous and still small: after two layers the curve is within 0.098 of the stack everywhere, after four within 0.0011, after six within five millionths, and the factorial in the denominator makes each further layer cost less than the one before by a factor that keeps growing. A uniformly convergent series of continuous functions can be integrated term by term, so

∫01x−x dx=∑n=0∞1n!∫01(−xln⁡x)n dx.\int_0^1 x^{-x}\,dx = \sum_{n=0}^{\infty} \frac{1}{n!} \int_0^1 (-x \ln x)^n \,dx.

Second, each layer’s area is exact. Substitute x=e−t/(n+1)x = e^{-t/(n+1)}, so that −ln⁡x=t/(n+1)-\ln x = t/(n+1) and dx=−e−t/(n+1) dt/(n+1)dx = -e^{-t/(n+1)}\,dt/(n+1). The integrand xn(−ln⁡x)nx^n (-\ln x)^n becomes e−nt/(n+1) tn/(n+1)ne^{-nt/(n+1)} \, t^n/(n+1)^n, the extra factor from dxdx brings the exponent to −t-t, and the interval from 0 to 1 becomes the half-line from ∞\infty to 0:

∫01xn(−ln⁡x)n dx=1(n+1)n+1∫0∞tne−t dt=n!(n+1)n+1.\int_0^1 x^n(-\ln x)^n\,dx = \frac{1}{(n+1)^{n+1}} \int_0^\infty t^n e^{-t}\,dt = \frac{n!}{(n+1)^{n+1}}.

The integral on the right is the gamma integral, which only one curve through the factorials identified as n!n!. The n!n! cancels the 1/n!1/n! in front, and the layer’s area is exactly 1/(n+1)n+11/(n+1)^{n+1}. Summing over n≥0n \ge 0 and renaming n+1n + 1 as nn gives the sophomore’s dream. The figure’s legend prints the areas measured by quadrature: 1, 1/4, 1/27, 1/256 and 1/3125, each matching to twelve places.

The companion for xx=exln⁡xx^x = e^{x \ln x} is the same calculation with the sign of every odd layer reversed, since (xln⁡x)n=(−1)n(−xln⁡x)n(x \ln x)^n = (-1)^n(-x \ln x)^n. Everything in the proof survives, and the areas alternate in sign.

Why the dream is rare

The identity is not a fluke of the proof; it is a fluke of the function. Term-by-term integration of a power series always works inside the series’ interval of convergence, so the trick is available for any eg(x)e^{g(x)}. What made it pay off is that every layer g(x)ng(x)^n could be integrated exactly, by one substitution, into a factorial. For most choices of gg the layers have no closed form, and the series is a series of numbers each of which needs its own quadrature — no improvement at all.

Here the substitution worked because xnx^n and (−ln⁡x)n(-\ln x)^n are the same thing in different coordinates: putting x=e−sx = e^{-s} turns xnx^n into e−nse^{-ns} and −ln⁡x-\ln x into ss, so the layer becomes sne−(n+1)ss^n e^{-(n+1)s}, a gamma integrand rescaled. Bernoulli’s integral is a gamma function in disguise, sampled at every whole number at once, and the sum ∑n−n\sum n^{-n} is what the rescalings leave behind. Other integrals of the same kind give similar sums. Replacing x−xx^{-x} by x−axx^{-ax} for a constant aa multiplies the nn-th layer by ana^n and gives ∑an−1/nn\sum a^{n-1}/n^n; integrating against xmx^{m} shifts the exponents in the same way. But the family is narrow, and it is the coincidence of power and logarithm that defines it.

Every layer peaks at the same point

Every layer peaks at 1/e. n=1..6 normalised by e^-n, all peaking at 1/e
Fig. 3 The integrands xn(−ln⁡x)nx^n(-\ln x)^n for nn from 1 to 6, each divided by its height at 1/e1/e. All six peak at exactly the same point, and each is narrower than the last.

Look at the layers individually, before the factorials are divided out. The function xn(−ln⁡x)nx^n(-\ln x)^n is (−xln⁡x)n(-x \ln x)^n, the nn-th power of a single hump, so it is largest wherever that hump is: at x=1/ex = 1/e, with height (1/e)n=e−n(1/e)^n = e^{-n}. Dividing each by e−ne^{-n} puts all of them at height 1 at the same point, and the figure draws them that way. Raising a function to a higher power makes it narrower, since values below its maximum shrink faster than the maximum does: the width at half height falls from 0.72 for n=1n = 1 to 0.34 for n=6n = 6, roughly in proportion to 1/n1/\sqrt{n}.

This is a coincidence of the problem worth noticing. The minimum of xxx^x, the maximum of x−xx^{-x}, the peak of every layer and the point where −xln⁡x-x \ln x reaches its largest value are all the same point, 1/e1/e. The curve in the hero bulges at 1/e1/e because every one of its layers does, and the layers decay in size because their common peak height e−ne^{-n} shrinks geometrically while their width shrinks only like a square root.

Stirling’s formula, inside the layers

Stirling's formula inside the series. 1:0.73695/1.08444 2:0.83941/1.04221 3:0.88422/1.02806 4:0.90944/1.02101 5:0.92563/1.01678 6:0.93690/1.01397 7:0.94520/1.01197 8:0.95158/1.01047 9:0.95662/1.00930 10:0.96071/1.00837 11:0.96410/1.00760 12:0.96695/1.00697 13:0.96938/1.00643 14:0.97147/1.00597 15:0.97330/1.00557 16:0.97491/1.00522 17:0.97633/1.00491 18:0.97761/1.00464 19:0.97875/1.00440 20:0.97978/1.00418
Fig. 4 Each layer’s exact area n!/(n+1)n+1n!/(n+1)^{n+1}, divided by the area of the Gaussian that fits its peak; and n!n! divided by Stirling’s approximation. Both ratios tend to 1, because they are the same statement.

Because the layers narrow around their peak, a layer’s area for large nn is determined by the shape of the peak alone. That is Laplace’s method: near its maximum, a function raised to a high power looks like a Gaussian bell, and the bell’s area is computed from the height and the curvature at the top. For h(x)=xn(−ln⁡x)nh(x) = x^n(-\ln x)^n the logarithm is nln⁡x+nln⁡(−ln⁡x)n\ln x + n\ln(-\ln x), whose second derivative at x=1/ex = 1/e is −ne2-n e^2. So near the peak

h(x)≈e−nexp⁡ ⁣(−12ne2(x−1/e)2),h(x) \approx e^{-n} \exp\!\left(-\tfrac{1}{2} n e^2 (x - 1/e)^2\right),

and the area of that bell is e−n2π/(ne2)=e−n−12π/ne^{-n}\sqrt{2\pi/(n e^2)} = e^{-n-1}\sqrt{2\pi/n}. The figure divides the exact area n!/(n+1)n+1n!/(n+1)^{n+1} by this estimate and watches the ratio climb towards 1: 0.737 at n=1n = 1, 0.961 at n=10n = 10, 0.980 at n=20n = 20.

Now rearrange. The exact area times (n+1)n+1(n+1)^{n+1} is n!n!, and (n+1)n+1=nn+1(1+1/n)n+1(n+1)^{n+1} = n^{n+1}(1 + 1/n)^{n+1}, where the last factor tends to ee. So the ratio tending to 1 says

n!≈(n+1)n+1e−n−12π/n≈nne−n2πn,n! \approx (n+1)^{n+1} e^{-n-1}\sqrt{2\pi/n} \approx n^{n} e^{-n} \sqrt{2\pi n},

which is Stirling’s formula. The figure’s second curve is n!n! divided by nne−n2πnn^n e^{-n}\sqrt{2\pi n}, falling to 1 from above: 1.0844 at n=1n = 1 and 1.0042 at n=20n = 20, each time close to 1+1/(12n)1 + 1/(12n), the first of the corrections that refine Stirling’s formula into a series of its own. The layers carry those corrections too. A Gaussian is only the first approximation to the peak of xn(−ln⁡x)nx^n(-\ln x)^n; the peak is lopsided, falling more steeply towards x=0x = 0 than towards x=1x = 1, and expanding its logarithm to higher order around 1/e1/e reproduces the 1/(12n)1/(12n) term and the ones after it. The two ratios approach 1 from opposite sides because the two approximations make different small errors — one in the bell, one in (1+1/n)n+1(1 + 1/n)^{n+1} — but they carry the same information.

So the sophomore’s dream contains Stirling’s formula in a precise sense: the terms of its series are a sequence of Laplace integrals, each concentrated at 1/e1/e, and their sizes are the factorials’ growth rate written as areas. The constant that counts what does not happen found ee hiding in the count of derangements; here ee and 2π\sqrt{2\pi} appear together in the areas of humps that a curve on the unit interval is made of. This is the essay’s surprising connection, and it can be read in either direction: the curve x−xx^{-x} encodes the factorials, or the factorials encode a curve.

Seven terms against a thousand samples

Seven terms against a thousand samples. series 1:-0.54 2:-1.38 3:-2.37 4:-3.47 5:-4.64 6:-5.89 7:-7.21 8:-8.57 9:-9.98 10:-11.44 11:-12.94; midpoint 1:-0.91 2:-1.44 4:-1.98 8:-2.53 16:-3.07 32:-3.62 64:-4.18 128:-4.74 256:-5.30 512:-5.87 1024:-6.44
Fig. 5 The error in the area after n terms of the series, against the midpoint rule with 1, 2, 4 and up to 1,024 equally spaced samples. The series’ error falls faster than any power of the effort.

The practical consequence is speed. After nn terms the series is short by ∑k>nk−k\sum_{k > n} k^{-k}, which is dominated by its first term (n+1)−(n+1)(n+1)^{-(n+1)}: the error after seven terms is 8−88^{-8}, about 6×10−86 \times 10^{-8}, and after ten terms it is 3.6×10−123.6 \times 10^{-12}. That is faster than any geometric rate, since the ratio of successive terms itself goes to zero.

Sampling the curve does far worse. The midpoint rule with NN equally spaced samples has error falling roughly like 1/N21/N^2 for a smooth curve; where to take the samples measured that rate and found that it slows near a singularity. And x−xx^{-x} has one at the left end: its derivative involves ln⁡x\ln x, which blows up at zero, so the curve rises with infinite slope from (0,1)(0, 1). The figure’s midpoint errors fall by a factor of about 3.5 per doubling rather than the factor of 4 a smooth curve would give, and with 1,024 samples the error is still 3.7×10−73.7 \times 10^{-7} — six times worse than seven terms of the series.

That comparison is not quite fair, and it is worth saying why. The series knew something about the function that the samples did not: its exact algebraic form, which the substitution turned into factorials. A quadrature rule only sees values. Gauss–Legendre quadrature after the change of variable x=u2x = u^2, which the first figure used, removes the singular slope and converges as fast as the series does, and that is how this essay checks the identity independently. But no general-purpose rule knows to look for n−nn^{-n}, and the identity’s practical worth to Bernoulli, computing by hand, was exactly that it replaced a hard area by a sum whose terms he could write down.

The steep start that slows the samples

Why the midpoint rule converges so sluggishly is visible in the curve once it is examined near zero. Expanding the series to its first layer, x−x=1−xln⁡x+12(xln⁡x)2−⋯x^{-x} = 1 - x\ln x + \tfrac{1}{2}(x \ln x)^2 - \cdots, the curve leaves (0,1)(0, 1) along 1−xln⁡x1 - x \ln x, whose slope −ln⁡x−1-\ln x - 1 is infinite at zero. The tangent at the left end is vertical, though the curve’s height is perfectly finite and its rise over the first hundredth of the interval is only about 0.0470.047.

A midpoint rule estimates the area of each strip as the strip’s width times the curve’s height at its middle, and the error in a strip is governed by the curve’s second derivative there. For a smooth curve that derivative is bounded, the errors in the NN strips are each of order 1/N31/N^3, and they add up to order 1/N21/N^2. Here the second derivative behaves like −1/x-1/x near zero, so the first strip contributes an error of order 1/N21/N^2 on its own, the next ones a little less, and the total is of order (ln⁡N)/N2(\ln N)/N^2: the factor ln⁡N\ln N is the cost of the vertical tangent, and it is why each doubling of the samples buys a factor of about 3.5 instead of 4.

The series sees none of this. Each layer (−xln⁡x)n(-x \ln x)^n has the same steep start in a milder form, but the steepness has been absorbed into the exact formula for the layer’s area, and nothing is ever sampled. The comparison is between a method that has to discover the singularity, one strip at a time, and a method that was handed it.

The alternating companion, bracketed

The area under x^x, bracketed. 1:1.000000000 2:0.750000000 3:0.787037037 4:0.783130787 5:0.783450787 6:0.783429354 7:0.783430568 8:0.783430508
Fig. 6 The partial sums of 1 − 1/4 + 1/27 − 1/256 + …, which converge to the area under xxx^x. They land on alternate sides of the area, so consecutive sums bracket it.

For xxx^x the series alternates, and an alternating series whose terms shrink to zero has a useful extra property: its partial sums fall alternately above and below the limit, so each pair of consecutive sums brackets it, and the bracket’s width is the next term. The figure shows the sums 1, 0.75, 0.7870, 0.78313, 0.78345, … closing on 0.783431 from both sides. After eight terms the area is pinned between two numbers that differ by 9−99^{-9}, about 2.6×10−92.6 \times 10^{-9}, and the bracket is a proof: no quadrature error estimate is needed, because the sums themselves are rigorous upper and lower bounds.

The companion also shows the difference between the two areas: ∫01(x−x−xx) dx=2(14+1256+146,656+⋯ )\int_0^1 (x^{-x} - x^x)\,dx = 2\left(\frac{1}{4} + \frac{1}{256} + \frac{1}{46{,}656} + \cdots\right), twice the sum of n−nn^{-n} over even nn. The even layers are the ones where the two curves differ in sign, and the area between the curves is made entirely of them.

What the picture cannot show

The hero shows two curves and two shaded areas. Nothing in it suggests the numbers 1/nn1/n^n: the picture of a hump of height 1.44 over the unit interval is the picture of a thousand different functions, and the area’s decimal expansion carries no visible trace of the sum it equals. The identity is invisible to the eye in the way that most exact evaluations are. The layers figure is the closest the drawings come to showing it, and even there the layers’ areas have to be computed and printed; the eye sees humps getting smaller, not the numbers 4, 27, 256 and 3,125.

The pictures also hide what made the proof legal. Term-by-term integration is often wrong, and the reason it is right here — a uniform bound 1/e1/e on −xln⁡x-x \ln x — is a fact about the maximum of a function that a figure shows only as a height. The same expansion attempted on an interval where −xln⁡x-x\ln x is unbounded, such as [0,∞)[0, \infty), fails at once: the layers’ areas are infinite. Nothing drawn on [0,1][0, 1] warns of that. And a sum read from inside and settling in order settles everywhere at once are reminders that whether a limit may be passed through an integral is always a separate question from whether the limit exists.

Still open: what kind of number it is

Nobody knows whether ∑n−n=1.29128…\sum n^{-n} = 1.29128\ldots is rational, algebraic or transcendental, and the same is true of ∫01xx dx\int_0^1 x^x\,dx. The series converges much faster than the series for ee, which is the kind of speed that irrationality proofs exploit — Liouville’s numbers are transcendental precisely because they are approximated too well by fractions — but the partial sums of ∑n−n\sum n^{-n} have denominators that grow as fast as the approximations improve, and the standard arguments come out exactly balanced. The constant has no known closed form in terms of other constants either; it is defined by its integral, its series, and nothing else. The power tower of root two studied the infinite iterate xxx⋯x^{x^{x^{\cdots}}}, whose behaviour on the real line is known completely. The humbler question of what kind of number the area under a single xxx^x is remains, three centuries after Bernoulli, unanswered.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

Convergence rateGamma functionNumerical integrationPower seriesRiemann sumStirling approximationUniform convergence