Skip to content
QFT.org

Search QFT.org

Enter a word or phrase.

    You can also browse the main navigation and chapter contents.

    Convergence of a Gaussian Integral

    A Gaussian variance computed on successively finer meshes settles at 0.97334. How many of those digits describe the original Gaussian? Compare the calculation against two exact answers, one for the integration window and one for the whole line. They isolate errors a mesh-refinement test alone cannot see.

    Preparation. A definite integral, a weighted mean and a short Python loop suffice. The Gaussian integral with a source gives an analytic calculation of the variance.

    A numerical expectation with an exact baseline

    For a dimensionless variable xx with action S(x)=x2/2S(x)=x^2/2, define

    ⟨x2⟩=∫−∞∞x2e−x2/2 dx∫−∞∞e−x2/2 dx=1.\langle x^2\rangle =\frac{\int_{-\infty}^{\infty}x^2e^{-x^2/2}\,\mathrm dx} {\int_{-\infty}^{\infty}e^{-x^2/2}\,\mathrm dx}=1.

    To verify the last equality, take the derivative of xe−x2/2xe^{-x^2/2}. It gives (1−x2)e−x2/2(1-x^2)e^{-x^2/2}, whose integral vanishes by the endpoint values. The unit variance supplies the full-line benchmark.

    Restrict the integration to [−L,L][-L,L] and divide it into NN equal intervals of width h=2L/Nh=2L/N. At the midpoints

    xj=−L+(j+12)h,j=0,…,N−1,x_j=-L+(j+\tfrac12)h,\qquad j=0,\ldots,N-1,

    approximate the ratio by

    VL,N=∑jxj2e−xj2/2∑je−xj2/2.V_{L,N}=\frac{\sum_jx_j^2e^{-x_j^2/2}} {\sum_je^{-x_j^2/2}}.

    The factor hh cancels between numerator and denominator. This Python program varies the window and the mesh independently.

    from math import exp, fsum
    
    def variance(L, N):
        h = 2 * L / N
        x = [-L + (j + 0.5) * h for j in range(N)]
        w = [exp(-y * y / 2) for y in x]
        return fsum(y * y * z for y, z in zip(x, w)) / fsum(w)
    
    for L, counts in [(3, (32, 64, 128)), (4, (128,)),
                      (5, (128,)), (6, (128, 256))]:
        for N in counts:
            print(L, N, f"{variance(L, N):.12f}")
    

    The midpoint nodes are deterministic. Repeating the calculation with the same nodes gives the same answer.

    First refine the mesh, then enlarge the domain

    Integrating by parts on the finite interval retains the endpoint term.

    VL=1−2Le−L2/2ZL,ZL=∫−LLe−x2/2 dx.V_L=1-\frac{2Le^{-L^2/2}}{Z_L},\qquad Z_L=\int_{-L}^L e^{-x^2/2}\,\mathrm dx.

    For L=3L=3, this is VL≃0.973336924663V_L\simeq0.973336924663. Here is the mesh error relative to that finite-window value.

    NNV3,NV_{3,N}Mesh error
    320.9735720487462.35×10−42.35\times10^{-4}
    640.9733957547995.88×10−55.88\times10^{-5}
    1280.9733516352131.47×10−51.47\times10^{-5}

    Here mesh error means ∣V3,N−V3∣|V_{3,N}-V_3|. Doubling NN reduces it by about four, consistent with the midpoint rule's second-order error for a smooth integrand on a fixed interval.

    Even exact integration over this window underestimates the full variance by about 2.67%2.67\%. Keep N=128N=128 and enlarge the window.

    LLVL,128V_{L,128}
    40.998931553854
    50.999985215715
    60.999999927964

    Changing LL also changes hh, so check the final mesh again. At L=6L=6, doubling NN to 256 gives 0.9999999273090.999999927309. The finite-window limit is 0.9999999270890.999999927089. The remaining discrepancy from one comes mainly from the omitted tail.

    A misleading plateau

    A calculation at L=3L=3 reports 0.973340.97334 and barely changes when the mesh is refined. Is it accurate to four decimal places for the full Gaussian variance? State the next check and the direction in which the missing tail changes the answer.

    Solution

    No. It accurately approximates a different, truncated distribution. The target variance is one. The removed region has x2≥9x^2\geq9, so restoring it increases the normalized second moment. Enlarge LL and independently recheck the mesh at that new window. The finite-window integration-by-parts formula predicts both the sign and size of the tail bias.

    From quadrature to a lattice observable

    Translate the window test to a narrow peak with density e−(x−μ)2/σ2/(π σ)e^{-(x-\mu)^2/\sigma^2}/(\sqrt\pi\,\sigma) on [0,1][0,1]. Here σ\sigma is 2\sqrt2 times the standard deviation of the full Gaussian. Setting y=2(x−μ)/σy=\sqrt2(x-\mu)/\sigma restores our weight e−y2/2e^{-y^2/2}. If the peak is well inside the interval, increasing the window does little when the initial nodes miss the peak entirely. Compare the estimated integral and its own error indicator before and after resolving the peak. A narrow Gaussian missed by adaptive quadrature.

    For many field variables, direct quadrature becomes expensive. Importance sampling replaces the two integrals by a ratio of sample averages. When a Markov chain generates those samples, measure the autocorrelation of the observable to estimate the uncertainty of its mean. The lattice spacing and volume still have to be varied separately.

    With a correlated fit and an error estimate in hand, extract a lattice energy from an interacting scalar correlator. For a variational calculation, compare the neural spin-state energy with the independently diagonalized Hamiltonian.

    Scrollable formula. Use Left and Right arrow keys to reveal hidden content.

    Scrollable table. Use Left and Right arrow keys to reveal hidden columns.

    Scrollable figure. Use Left and Right arrow keys to reveal hidden content.