Skip to content
QFT.org

Search QFT.org

Enter a word or phrase.

    You can also browse the main navigation and chapter contents.

    A field can be approximated by minimizing its energy instead of squaring its differential equation. For a positive linear operator, this gives an exact relation between functional error and field error. A neural parameterization preserves that relation only when its trial functions satisfy the boundary conditions and the integral being evaluated is the correct one.

    We will minimize a scalar energy with a small neural network, compare it with spectral Galerkin, and deliberately underintegrate the neural functional. The last calculation produces a value below the true minimum, exposing which part of the variational argument failed.

    Preparation: The sourced scalar example in residual minimization, integration by parts and constrained optimization. The model is a classical positive elliptic problem; the energy functional here is not a quantum Hamiltonian expectation value.

    The functional and its admissible space

    On 0<x<10<x<1, define

    aϵ(v,w)=∫01(ϵ2v′w′+vw)dx,Iϵ(v)=12aϵ(v,v)−∫01v dx,a_\epsilon(v,w)=\int_0^1 \left(\epsilon^2v'w'+vw\right)dx, \qquad I_\epsilon(v)=\frac12a_\epsilon(v,v)-\int_0^1v\,dx,

    with ϵ>0\epsilon>0 and v∈H01(0,1)v\in H_0^1(0,1). The space specifies square-integrable first derivatives and zero endpoint traces. The source term has the negative sign appropriate to the static energy with a positive source in the field equation.

    Vary vv by δv∈H01\delta v\in H_0^1. Then

    δIϵ=∫01(ϵ2v′δv′+vδv−δv)dx=∫01(−ϵ2v′′+v−1)δv dx.\delta I_\epsilon =\int_0^1\left(\epsilon^2v'\delta v'+v\delta v-\delta v\right)dx =\int_0^1(-\epsilon^2v''+v-1)\delta v\,dx.

    The endpoint term vanishes because the variation has zero traces. Stationarity therefore gives

    −ϵ2u′′+u=1,u(0)=u(1)=0.-\epsilon^2u''+u=1,\qquad u(0)=u(1)=0.

    The positive bilinear form makes this minimizer unique in the full function space. The exact solution and integrated response are

    u(x)=1−cosh⁡[(x−12)/ϵ]cosh⁡[1/(2ϵ)],R(ϵ)=∫01u dx=1−2ϵtanh⁡ ⁣12ϵ.u(x)=1- \frac{\cosh[(x-\tfrac12)/\epsilon]}{\cosh[1/(2\epsilon)]}, \qquad R(\epsilon)=\int_0^1u\,dx =1-2\epsilon\tanh\!\frac1{2\epsilon}.

    Neural Ritz methods replace the admissible function by a parameterized trial and then approximate the integral. These are separate steps. E and Yu, §2, Eqs. (1)–(11) explicitly distinguish the trial representation, quadrature and optimizer.

    An exact identity, rather than a small-loss heuristic

    Write v=u+ev=u+e, where both uu and vv satisfy the zero endpoints. Expanding the functional gives

    Iϵ(v)−Iϵ(u)=12aϵ(e,e)+aϵ(u,e)−∫01e dx.I_\epsilon(v)-I_\epsilon(u) =\frac12a_\epsilon(e,e) +a_\epsilon(u,e)-\int_0^1e\,dx.

    The weak equation is aϵ(u,e)=∫ea_\epsilon(u,e)=\int e, so

    Iϵ(v)−Iϵ(u)=12∥v−u∥a2,∥e∥a2=ϵ2∥e′∥22+∥e∥22.I_\epsilon(v)-I_\epsilon(u) =\frac12\|v-u\|_a^2, \qquad \|e\|_a^2=\epsilon^2\|e'\|_2^2+\|e\|_2^2.

    The right side is nonnegative. This proves the variational bound and identifies the error it measures. It does not require the parameter optimizer to reach its minimum: every admissible trial satisfies the identity when the integrals are exact.

    Taking e=ue=u in the weak equation gives aϵ(u,u)=∫u=Ra_\epsilon(u,u)=\int u=R, hence

    Iϵ(u)=−R2.I_\epsilon(u)=-\frac{R}{2}.

    Consequently the corrected response

    Rlow(v)=2∫01v dx−aϵ(v,v)=−2Iϵ(v)R_{\mathrm{low}}(v) =2\int_0^1v\,dx-a_\epsilon(v,v) =-2I_\epsilon(v)

    obeys

    R−Rlow(v)=∥v−u∥a2≥0.R-R_{\mathrm{low}}(v)=\|v-u\|_a^2\ge0.

    The ordinary approximation ∫v\int v has no such sign restriction. Multiplying the exact solution by a constant larger than one immediately makes its integral exceed RR. The quadratic correction removes the first-order error.

    By contrast, minimizing ∥Lϵv−1∥22\|L_\epsilon v-1\|_2^2 weights an eigenfunction error with the square of its operator eigenvalue. The energy difference weights it with one power. Both objectives have the same exact solution in suitable spaces, but their finite-trial optimization problems and sensitivity to derivatives differ.

    Training a genuinely admissible neural trial

    Use the same one-hidden-layer family as the residual calculation:

    vθ(x)=x(1−x)nθ(2x−1),nθ(z)=c+∑j=116ajtanh⁡(wjz+bj).v_\theta(x)=x(1-x)n_\theta(2x-1), \qquad n_\theta(z)=c+\sum_{j=1}^{16}a_j\tanh(w_jz+b_j).

    All 4949 parameters are trained. The factor x(1−x)x(1-x) enforces the essential boundary condition before optimization; it does not insert the exact solution. If Jα(x)=∂θαvθ(x)J_\alpha(x)=\partial_{\theta_\alpha}v_\theta(x), the energy gradient is

    ∂θαIϵ(vθ)=∫01[ϵ2vθ′∂xJα+(vθ−1)Jα]dx.\partial_{\theta_\alpha}I_\epsilon(v_\theta) =\int_0^1\left[ \epsilon^2v_\theta'\partial_xJ_\alpha +(v_\theta-1)J_\alpha\right]dx.

    Only first spatial derivatives enter this objective. A residual-square method needs second spatial derivatives, though neither observation alone establishes which finite training problem is easier.

    The retained study uses ϵ=1\epsilon=1, 0.10.1 and 0.0250.025, a 6464-point Gauss–Legendre training rule and three prescribed starts at each value. It reuses the parameter initialization, bounds and optimizer budget of the residual page. Each fit has at most 15001500 accepted iterations and 60006000 objective-and-gradient calls. No validation value selects a restart or a preferred seed.

    Independent 256256- and 512512-point rules evaluate every final state; the designated start-zero models also receive adaptive integration. For those models:

    ϵ\epsilonRelative L2L^2 errorI(v)−I(u)I(v)-I(u)Rlow−RR_{\mathrm{low}}-R
    117.05×10−67.05\times10^{-6}4.38×10−104.38\times10^{-10}−8.77×10−10-8.77\times10^{-10}
    0.10.11.55×10−51.55\times10^{-5}1.51×10−91.51\times10^{-9}−3.03×10−9-3.03\times10^{-9}
    0.0250.0257.01×10−47.01\times10^{-4}6.57×10−76.57\times10^{-7}−1.31×10−6-1.31\times10^{-6}

    The two error columns satisfy the expected factor of −2-2. At ϵ=0.025\epsilon=0.025, the ordinary response error is −3.87×10−6-3.87\times10^{-6}; the corrected response error is smaller and has a prescribed sign in the exact-integral theory.

    The same thin-layer model's three starts have relative field errors 0.0007010.000701, 0.006600.00660 and 0.001230.00123. The last reaches the iteration cap; none of the three meets the independent projected-gradient target 10−710^{-7}. Across all nine primary Ritz fits, only five meet that gradient target. A function-decrease success flag therefore does not establish stationarity or global optimality. Convexity of II as a functional of vv does not make its composition with nonlinear neural parameters convex.

    The variational statement itself remains useful even for an imperfect fit. What must be controlled is admissibility and the true value of the integral, not a promise that every neural optimizer succeeds.

    Spectral Galerkin and an exact response tail

    Expand in normalized zero-boundary modes

    en(x)=2sin⁡(nπx),Lϵen=λnen,λn=1+ϵ2n2π2.e_n(x)=\sqrt2\sin(n\pi x),\qquad L_\epsilon e_n=\lambda_ne_n,\qquad \lambda_n=1+\epsilon^2n^2\pi^2.

    The source coefficients are

    bn=∫01en dx={22/(nπ),n odd,0,n even.b_n=\int_0^1e_n\,dx = \begin{cases} 2\sqrt2/(n\pi),&n\text{ odd},\\ 0,&n\text{ even}. \end{cases}

    Stationarity in the span of the first KK odd modes gives cn=bn/λnc_n=b_n/\lambda_n. This is a conventional linear Galerkin solve with diagonal stiffness matrix, independent of the neural approximation.

    Its integrated response is

    RK=∑n=1,3,…n≤2K−18n2π2(1+ϵ2n2π2).R_K=\sum_{\substack{n=1,3,\ldots\\n\le2K-1}} \frac{8}{n^2\pi^2(1+\epsilon^2n^2\pi^2)}.

    Because the Galerkin solution is stationary within its linear subspace, aϵ(uK,uK)=∫uKa_\epsilon(u_K,u_K)=\int u_K. Therefore its ordinary and corrected responses coincide, and

    Iϵ(uK)=−RK2,∥u−uK∥a2=R−RK.I_\epsilon(u_K)=-\frac{R_K}{2},\qquad \|u-u_K\|_a^2=R-R_K.

    Every omitted term is positive. A conservative integral comparison gives

    0<R−RK≤83ϵ2π4(2K−1)3.0<R-R_K \le\frac{8}{3\epsilon^2\pi^4(2K-1)^3}.

    To see the bound, replace each denominator by ϵ2n4π4\epsilon^2n^4\pi^4, include the omitted even integers as well, and bound the resulting decreasing sum by the integral from 2K−12K-1 to infinity. It is deliberately not an optimized tail estimate.

    At ϵ=0.025\epsilon=0.025, K=4K=4 gives response error −0.01828-0.01828; K=32K=32 gives −8.16×10−5-8.16\times10^{-5} and K=128K=128 gives −1.30×10−6-1.30\times10^{-6}. The latter is similar to the designated neural corrected-response error, but obtained through a simple diagonal linear calculation with an analytic positive tail.

    The numerical quadrature controls also reveal a useful limitation. At K=128K=128, the 256256- and 512512-point validation rules do not agree at the prescribed tolerance for several rapidly oscillating error integrals. Those misses are retained. The response sum and Galerkin energy identity above are available algebraically, so they need not be inferred from the underresolved validation rule. Increasing an integration order is not the same operation as increasing the trial-space dimension.

    A quadrature minimum below the true minimum

    An extra frozen diagnostic uses the same ϵ=0.025\epsilon=0.025 network and start zero, but trains its energy on only eight Gauss points. The continuum minimum is

    Iϵ(u)=−0.475I_\epsilon(u)=-0.475

    to the displayed precision. The fit reports the training value

    I8(v)=−0.4954602,I_8(v)=-0.4954602,

    which is lower. Independently integrating that same retained function gives

    I(v)=−0.4603058,∥v−u∥2∥u∥2=0.084665.I(v)=-0.4603058, \qquad \frac{\|v-u\|_2}{\|u\|_2}=0.084665.

    There is no contradiction with the variational principle: the function is admissible, but I8I_8 is a different functional. The nonlinear trial has exploited the quadrature rather than accurately minimizing the continuum energy. Fifteen parameters contact their prescribed bounds, and the independent gradient target is missed; both facts remain in the output.

    The retained neural Ritz functions and their independently evaluated errors, including the coarse-quadrature false minimum and spectral Galerkin response convergence.

    At ϵ=0.025\epsilon=0.025, a fixed eight-point training rule yields a misleading low energy. The left panel compares the same retained functions with the exact field; the right compares independently evaluated response errors with the analytic Galerkin sum. The continuum minimum is not estimated from the training rule.

    The independently adaptive and 512512-point energy integrals differ by at most 2.6×10−142.6\times10^{-14} across the designated models, including this diagnostic. This is strong refinement evidence for those computed integrals, not a rigorous quadrature enclosure. The paper introducing Deep Ritz already warns that a functional minimized at fixed nodes may not be minimized between them: E and Yu, §2.2.

    The full shared study performs 2828 prescribed fits, including residual models and this diagnostic, with 23 45423\,454 objective-and-gradient calls and 1 464 0961\,464\,096 interior-node evaluations. On the recorded host the fits took about 3.393.39 seconds and validation about 1.581.58 seconds. These totals exclude the separately run deterministic checks; they are implementation-specific observations, not a general speed comparison. The small conventional solves remain inexpensive.

    Summary

    A legitimate neural Ritz method minimizes a known functional over admissible trial functions. Its exact energy error is a squared field-error norm, and a corrected response inherits a useful lower bound. These statements survive incomplete optimization but require the correct integral and boundary space. Fixed quadrature, parameter bounds and optimizer stopping introduce additional approximations, each of which the retained calculation tests separately.

    Exercises

    1. One-function Ritz approximation

    Use the trial v(x)=c x(1−x)v(x)=c\,x(1-x). Find its optimal coefficient, energy and corrected response for any ϵ>0\epsilon>0. Explain which comparisons with the exact response have a definite sign.

    Solution

    For b=x(1−x)b=x(1-x),

    ∫01b dx=16,∫01b2 dx=130,∫01(b′)2 dx=13.\int_0^1b\,dx=\frac16,\qquad \int_0^1b^2\,dx=\frac1{30},\qquad \int_0^1(b')^2\,dx=\frac13.

    Hence

    Iϵ(cb)=c22(ϵ23+130)−c6.I_\epsilon(cb) =\frac{c^2}{2}\left(\frac{\epsilon^2}{3}+\frac1{30}\right)-\frac c6.

    The coefficient of c2c^2 is positive. Differentiating gives

    c∗=51+10ϵ2,Iϵ(c∗b)=−512(1+10ϵ2).c_*=\frac5{1+10\epsilon^2}, \qquad I_\epsilon(c_*b)=-\frac5{12(1+10\epsilon^2)}.

    At this stationary coefficient, aϵ(v,v)=∫va_\epsilon(v,v)=\int v, so

    Rlow(v)=∫01v dx=56(1+10ϵ2)≤1−2ϵtanh⁡ ⁣12ϵ.R_{\mathrm{low}}(v)=\int_0^1v\,dx =\frac5{6(1+10\epsilon^2)} \le1-2\epsilon\tanh\!\frac1{2\epsilon}.

    The inequality follows from admissibility and the variational identity, not from a fitted numerical pattern. For an arbitrary nonstationary coefficient cc, the corrected response is still a lower bound, but the ordinary integral c/6c/6 need not be.

    2. Which boundary problem does a penalty minimize?

    Allow free endpoint values and minimize

    Iϵ,β(v)=Iϵ(v)+β[v(0)2+v(1)2],β≥0.I_{\epsilon,\beta}(v)=I_\epsilon(v) +\beta[v(0)^2+v(1)^2], \qquad \beta\ge0.

    Derive the boundary conditions at finite β\beta. Find the symmetric solution and compare β=0\beta=0 with the Dirichlet limit.

    Solution

    The bulk variation again gives −ϵ2v′′+v=1-\epsilon^2v''+v=1. The endpoint terms now remain:

    δIϵ,β∣∂=[−ϵ2v′(0)+2βv(0)]δv(0)+[ϵ2v′(1)+2βv(1)]δv(1).\delta I_{\epsilon,\beta}\big|_{\partial} =\bigl[-\epsilon^2v'(0)+2\beta v(0)\bigr]\delta v(0) +\bigl[\epsilon^2v'(1)+2\beta v(1)\bigr]\delta v(1).

    Independent endpoint variations therefore impose Robin conditions

    ϵ2∂nv+2βv=0\epsilon^2\partial_n v+2\beta v=0

    at each end, where ∂n=−∂x\partial_n=-\partial_x at zero and +∂x+\partial_x at one.

    Reflection symmetry and uniqueness give

    vβ(x)=1−Aβcosh⁡[(x−12)/ϵ],Aβ=2β2βcosh⁡[1/(2ϵ)]+ϵsinh⁡[1/(2ϵ)].v_\beta(x)=1-A_\beta\cosh[(x-\tfrac12)/\epsilon], \qquad A_\beta= \frac{2\beta} {2\beta\cosh[1/(2\epsilon)] +\epsilon\sinh[1/(2\epsilon)]}.

    At β=0\beta=0, Aβ=0A_\beta=0, so v=1v=1 satisfies the Neumann problem and has energy −1/2-1/2. It is not a Dirichlet trial. As β→∞\beta\to\infty, AβA_\beta tends to 1/cosh⁡[1/(2ϵ)]1/\cosh[1/(2\epsilon)], recovering the zero-boundary solution. Finite penalties solve a different variational problem; a value below the Dirichlet minimum is not a violation of the Dirichlet theorem.

    References

    • W. E and B. Yu, “The Deep Ritz method: A deep learning-based numerical algorithm for solving variational problems,” Communications in Mathematics and Statistics 6, 1–12 (2018), doi:10.1007/s40304-018-0127-z; arXiv:1710.00211v1. Consulted §2, §3.1 Eq. (13) and §3.3.
    • I. E. Lagaris, A. Likas and D. I. Fotiadis, “Artificial neural networks for solving ordinary and partial differential equations,” IEEE Transactions on Neural Networks 9, 987–1000 (1998), doi:10.1109/72.712178; arXiv:physics/9705023v1, §§2–2.1 for boundary-adapted trial functions and their derivatives.
    • SciPy developers, L-BFGS-B options, SciPy 1.13.1. Optimization status is reported separately from functional quadrature and continuum error.

    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.