cert-machine · report · exact arithmetic on a published model, re-derived at every build

The clearing price, as a proved band

In the Gomes–Saúde model the electricity price is not a function anyone writes down: it is the Lagrange multiplier that makes a fleet of batteries absorb exactly what the grid produces. For the linear-quadratic case the paper solves it by a Volterra equation and a Laplace transform, up to one implicit constant. With quadratic terminal data that constant is explicit, the price closes in three lines, and it is affine in the supply path with every coefficient non-positive. So a forecast given as a box — this much supply, give or take — turns into a price band that is a theorem: every path inside the box prices inside the band, both edges are reached, and the whole thing is decided in exact rationals. The page then holds the source lab's own finite-difference kernel against the closed form and finds where its market clears and its batteries do not.

tl;dr
  • The finding. On the lab's supply scenario the price-supply line is ϖ = Θ − cQ with Θ = -1.6564 exactly (the paper's (25)/(30), re-decided), and a 15 % box on the supply gives a price band 2.7747 wide at its widest, 89 % of which is the day's total energy rather than the hour's. The lab's kernel clears its market in the agents' controls to 1e−14 and still ends the day with 0.0848 of the 0.6861 it cleared missing — 12 % vanishes at the wall. Clearing on the flux instead conserves, and then converges to the closed form at first order.
  • The mechanism. Π = ∫u_x m and Ξ = ∫x m obey Ξ̇ = Q and Π̇ = −η(Ξ − κ) (the paper's §6.2); quadratic terminal data gives Π(T) = γ(Ξ(T) − ζ), so ϖ = −cQ − γ(Ξ(T) − ζ) − η∫ₜᵀ(Ξ − κ). Every quantity is a rational number of the data and is computed as one. The lab's kernel is ported bit for bit (fd.js) and run three ways.
  • Check it. node instruments/price/battery.js (23 checks, 5 red controls, about 20 s) re-derives the record, decides the identities exactly, checks the closed form against an independent Riccati route to 1e−14, and measures the kernel.
Θ, the price-supply offset
-1.6564
decided exactly: Π_n = −Θ at all 241 grid times as a rational identity; Θ = −γ(∫Q + x̄₀ − ζ), the paper's (30)
the widest band
2.7747
at 12 h, for a 15 % box; twenty random paths inside the box priced inside it, exactly; both edges attained
the day, not the hour
89 %
of the widest band is γ·2ρ∫Q, the uncertainty in the day's total energy; the hour's own forecast error is c·2ρQ(t) ≤ 0.305
a band one unit wide
5.41 %
the box that would buy it: the width is linear in ρ, so ρ = 15 % × 1/2.775. The threshold a forecaster is asked to meet
the lab's wall
−12.4 %
of the day's cleared energy never enters a battery: Ξ(T) = 0.9032 against 0.9880; the density at x = 1 reaches 22.915
first order, once it conserves
1.880
error ratio for H halved on a domain where the walls do not bind, flux-cleared; the lab's walls give 0.720 — the error grows with refinement
§1 · the model

A price that is a multiplier

Each agent holds a charge x and chooses a rate α of buying (α > 0) or selling. The running cost is c α²/2 + ϖ(t) α + η (x − κ)²/2 — wear, payment at the spot price, and a set-point preference — and the terminal cost is γ (x − ζ)²/2. The price ϖ(t) is whatever makes the fleet's total purchase equal the grid's production Q(t):

−u_t + (ϖ + u_x)²/(2c) − η(x − κ)²/2 = 0, m_t − (m (ϖ + u_x))_x / c = 0, (1/c) ∫ (ϖ + u_x) m dx = −Q(t).

Gomes and Saúde prove existence and uniqueness of (u, m, ϖ) with ϖ Lipschitz, then work the linear-quadratic case. Two averages carry the price: Π(t) = ∫u_x m and Ξ(t) = ∫x m. The paper derives Ξ̇ = Q — the fleet's mean charge rises by exactly what the grid produces, conservation of energy — and Π̇ = −η(Ξ − κ), then solves for Π by a Volterra equation with a separable kernel and a Laplace transform, leaving Π(0) to be fixed implicitly. With quadratic terminal data Π(T) = ∫γ(x − ζ) m(T) = γ(Ξ(T) − ζ) is explicit, and the pair integrates in closed form:

Ξ(t) = x̄₀ + ∫₀ᵗ Q, Π(t) = γ (Ξ(T) − ζ) + η ∫ₜᵀ (Ξ(s) − κ) ds, ϖ(t) = −c Q(t) − Π(t).

This is elementary, and for η = 0 it is the paper's own line ϖ = Θ − cQ with Θ = −γ(∫₀ᵀQ + x̄₀ − ζ). What it buys is the shape: the price is affine in the supply path, and every coefficient is ≤ 0 when c, γ, η ≥ 0. More supply at any hour lowers the price at every hour, never raises it. Supply on the grid is a step function, Q_n on [t_n, t_{n+1}), so with rational data every quantity above is a rational number, and the instrument computes it as one. The battery checks the closed form against an independent route — the quadratic ansatz u = a x² + b x + e, a Riccati equation for a and a linear one for b, integrated in float — and the two agree to 1e−14.

0 0.5 1 0 4 8 12 16 20 24 hour of the day (the lab's T = 1 drawn as 24 h) supply Q(t) the box's upper edge, Q (1 + ρ) — assumed, not decided the lab's supply scenario Q (its default sliders), the nominal path the box's lower edge, Q (1 − ρ) — assumed, not decided
Figure 1 · The supply scenario of the source lab at its default sliders — a dawn cut, a midday plateau, a dip at the end of the day — and the forecast box Q(1 ± ρ), ρ = 15 %, drawn dashed because it is assumed. Nothing is claimed about which path inside the box the day will follow; the box is the weakest thing one can say about a forecast.
§2 · the band

Every path in the box prices inside it

Because the price falls with supply coordinate-wise, the band over the box is attained at its corners: the lowest price at every hour is the price of the upper edge Q(1 + ρ), the highest is the price of the lower edge, and these are prices of actual paths, so the band is tight. The certificate says exactly that, carries five falsifiers, and is decided by exact arithmetic: twenty random paths inside the box price inside the band at all 241 grid times, and a path a tenth above the box prices below it.

-4.5 -0.5 -1 -2 -3 -4 0 4 8 12 16 20 24 hour of the day clearing price ϖ(t) widest: 2.7747 at 12 h the band: every supply path inside the box prices inside it; both edges attained (decided, exact) the price of the nominal path (decided, exact)
Figure 2 · The price band for the 15 % box, η = 0. The fill is the set of prices the box admits; the two solid edges are the prices of the box's edges; the middle line is the price of the nominal path. Widest at 12 h, where the supply peaks: 2.7747, decided as the rational 4998384929455593201/18….

The width has an anatomy, and it is the finding of this section. At hour t the width is c·2ρQ(t) + γ·2ρ∫₀ᵀQ + (the η term): the hour's own forecast error, the day's total forecast error, and the set-point term. On this scenario the day term is 2.4699 and the instant term never exceeds 0.305: 89 % of the band at its widest is uncertainty about how much energy the whole day will bring, not about this hour. A forecaster who wants the band one price unit wide needs a box of 5.41 %, and needs it on the integral more than on the hour. That is the threshold the page publishes: the disclosure that would narrow the price.

0 1 2 3 0 4 8 12 16 20 24 hour of the day width of the band the width, exact: c·2ρQ(t) + γ·2ρ∫Q the day term γ·2ρ∫Q = 2.4699: the whole day's energy, the same at every hour the instant term c·2ρQ(t): what this hour's forecast error costs
Figure 3 · The width of the band and its parts. The flat line is the day term, the same at every hour; the lower curve is the instant term, the supply's shape scaled by 2ρc. The width is their sum exactly, checked as a rational identity at every grid time.

With a set-point preference η > 0 the price-supply relation stops being a line. Π(t) picks up η∫ₜᵀ(Ξ − κ): while the fleet's mean is above the set point the offset grows toward the past, and the price the market clears at depends on where the fleet is going to be, not only on how much it will have absorbed. The band is still attained at the corners — the η term has non-positive coefficients too — and its set-point part is tabulated.

1 1.5 2 2.5 3 0 4 8 12 16 20 24 hour of the day Π(t), the offset −(ϖ + cQ) η = 0: the paper's constant Θ = -1.6564 η = 3, κ = 3/5 η = 12, κ = 3/5
Figure 4 · The offset Π(t) = −(ϖ + cQ) for three set-point strengths on the same supply. At η = 0 it is the constant Θ of the paper; at η > 0 with κ = 0.6 it bends, by more as η grows. All three are exact.
ηκΠ(0)Π(T)widest bandatinstant · day · set-point parts of itverdict
01.65641.65642.774712 h0.305 · 2.470 · 0.000PROVED
33/51.75391.65643.023511 h0.297 · 2.470 · 0.256PROVED
123/52.04661.65643.82928 h0.251 · 2.470 · 1.108PROVED
§3 · the lab's kernel

A market that clears and batteries that do not fill

The source lab solves this model on the battery box [0, 1] with an implicit upwind scheme, Anderson-accelerated on the clearing map, and reports a residual measured before the step it judges. That kernel is ported here bit for bit — the same 49 iterations to the same residual, the same price to the last binary digit — with the domain, the walls and the clearing rule made parameters. It clears: the fleet's purchase matches Q to 1e−14 at every time step. And the fleet ends the day at Ξ(T) = 0.9032 when conservation says 0.9880. The gap, 0.0848, is 12.4 % of the day's energy, and it is at the wall: the density at x = 1 reaches 22.915 by nightfall.

The mechanism is two lines of the scheme. At a wall the missing neighbour counts as u_x = 0, so an agent at full charge still sees the price and may point its control into the wall; the payment enters the Lagrangian and the purchase enters the clearing sum. The Fokker–Planck step then sets the flux through the wall to zero. Energy is bought, counted as cleared, and never stored. Forbid the wall-pointing control — the state-constraint boundary condition — and the loss falls to 0.0645 but does not vanish, because the clearing sum still counts controls at cells the flux cannot leave. Clear on the discrete flux of the Fokker–Planck step itself, one bisection per time step, and Ξ(T) matches the exact model to 1e−14.

0.25 0.5 0.75 1 0 4 8 12 16 20 24 hour of the day Ξ(t), the fleet's mean charge Ξ(t) = x̄₀ + ∫₀ᵗQ — what clearing requires (decided, exact) the lab's kernel: cleared in the controls, 0.0848 short by nightfall (computed) walls made state constraints, still clearing on the controls: 0.0645 short (computed) clearing on the Fokker–Planck flux: conserves to 1e−14 (computed)
Figure 5 · The fleet's mean charge through the day. Solid: what clearing requires, Ξ = x̄₀ + ∫Q, exact. Dashed: three runs of the same kernel — as the lab wrote it, with state-constraint walls, and with flux clearing. Only the last conserves. Dashed is computed: none of the three is an authority here.
the scheme on the lab's boxΞ(T), the fleet at nightfallenergy lostΠ at noondensity at the wall, Titerations · residual
the lab's kernel as it is (walls: u_x = 0 outside; clearing on the controls)0.90320.0848 (12.4 % of the day)0.039122.91549 · 8.0e-10
walls as state constraints (no control into a wall); clearing on the controls0.92350.06450.56568.05936 · 9.8e-10
state-constraint walls; clearing on the Fokker–Planck flux (ours)0.98801.0e-141.280270.50052 · 8.6e-10
the exact model on the whole line0.98800, by identity1.6564none: closed form

Once the scheme conserves, the box's price can be read against the whole line's. At noon the flux-cleared box gives Π ≈ 1.280 where the closed form gives 1.656: a gap of 0.376 that is the wall's shadow price, the model's own statement that a fleet that cannot exceed full charge does not need to be paid as much to absorb the day. The lab's kernel put the same number at 0.039, and that was the leak talking, not the wall. Whether the wall's shadow price is 0.376 or something near it is a float statement at one mesh; what is decided is the whole-line value and the fact that only the conserving scheme is measuring the model.

-3 -2 -1 0 0 4 8 12 16 20 24 hour of the day clearing price ϖ(t) the exact price on the whole line, ϖ = Θ − cQ (decided) the lab's kernel on its box [0, 1] (computed): Π ≈ 0.039 at noon the flux-cleared box (computed): Π ≈ 1.280 at noon — the wall's shadow price is the gap to Θ
Figure 6 · Three prices on the lab's scenario. Solid: the exact whole-line price ϖ = Θ − cQ. Dashed: the lab's kernel and the flux-cleared box, both computed on [0, 1] at NX = 120, NT = 240. The three share the supply's shape; they differ by their offsets. The hook at 24 h on the dashed curves is the kernel's own last grid point, where its price is read from the terminal condition rather than from the iteration.
§4 · convergence

The closed form, approached from the mesh

Move the walls to [−1, 2], where the fleet never reaches them, and the flux-cleared scheme must approach the closed form as the mesh refines. It does, at first order: the maximal price error halves when H halves, at η = 0 and with the set-point potential on. The lab's wall treatment on the same domain does not approach it — its error grows with refinement — because the wall cell's free purchase lowers u there and the backward equation carries the cheaper value inward. That is a red control on the page's own claim: if the closed form were wrong, the conserving scheme would not converge to it either. Every run in the table converged to its 1e−9 clearing residual.

scheme on [−1, 2], walls far from the fleetmeshmax |ϖ_fd − ϖ_exact|max |Ξ_fd − Ξ_exact|Π at noon, fd vs exact
state-constraint walls + flux clearing, η = 0150 × 240, H = 0.02010.08161.2e-141.6449 vs 1.6332
state-constraint walls + flux clearing, η = 0300 × 480, H = 0.01000.04342.4e-141.6390 vs 1.6332
the same with η = 6, κ = 0.6150 × 240, H = 0.02010.08821.0e-142.3528 vs 2.3387
the lab's walls and clearing150 × 240, H = 0.02011.69986.6e-20.4420 vs 1.6332
the lab's walls and clearing300 × 480, H = 0.01002.36156.2e-20.3937 vs 1.6332
§5 · the honest boundary

What is claimed, and what is not

  • Decided. Θ; Π_n = −Θ at every grid time for η = 0; Ξ(T) = x̄₀ + ∫Q; the terminal identity and the step identity for η > 0; the band, its attainment at the corners, twenty interior paths inside it; the width's decomposition. All as rational identities on the lab's supply entered losslessly (a double is m·2^e).
  • Assumed. The model is the paper's (33) on the whole line, first order (ε = 0), with quadratic terminal data; the closed form rests on the paper's averaged dynamics, an identity for C² solutions with decaying density, cited not re-proved. Supply is a step function on the grid; the price at t_n is its right limit. The box is a box: no correlation between hours is assumed, which is why the corners are attained.
  • Measured, not decided. Everything about the finite-difference kernel: the leak, the wall density, the shadow price, the convergence ratios. Floats at fixed meshes, drawn dashed. The port reproduces the lab bit for bit at the lab's parameters; the two generalisations — state-constraint walls and flux clearing — are this instrument's, and they are a diagnosis of a scheme, not a statement about the source lab's other results.
  • Not claimed. Novelty of the closed form (it is three lines from the paper's own §6.2 and may well be known to its authors); anything for non-quadratic terminal data, where Π(T) needs the whole terminal density; anything about ε > 0; that a 15 % box is a realistic forecast — it is a worked example of the certificate, with the lab's scenario as data.
  • Occupied, and cited. The monotone semi-Lagrangian discretisation of this model with a convergence proof is Ashrafyan–Gomes (2024/25); the kernel measured here is the source lab's, not theirs.
§6 · check it

Twenty seconds on your machine

node instruments/price/battery.js       # 23 checks, 5 red controls: identities exact, band attained, Riccati to 1e-14, the kernel measured
node instruments/price/run.js --check   # the record, re-derived and compared byte for byte

The instrument is instruments/price/price.js (exact) with fd.js (the port) and derive.js; the record is certs/price-band.json. The certificate's falsifiers, as recorded: η < 0: a sensitivity ∂ϖ_n/∂Q_k turns positive and a path inside the box prices outside the corner band (the battery shows it); a supply path inside the box whose exact price leaves the band at any grid time; η = 0: Π_n ≠ −Θ at some n, Θ the paper's (30) — the closed form would not be the paper's line; the Riccati route (u = a x² + b x + e, float ODE) disagreeing with the closed form beyond 1e−9; the wide-domain finite-difference solve of the same system disagreeing beyond first order in the mesh.

references

Sources

  • D. A. Gomes, J. Saúde, A mean-field game approach to price formation in electricity markets, arXiv:1807.07088 (2018); Dynamic Games and Applications 11 (2021) — the model, Theorem 1, and §6 (linear-quadratic: (25), (30), (32), the Volterra route of §6.2).
  • Y. Ashrafyan, D. A. Gomes, A fully-discrete semi-Lagrangian scheme for a price formation MFG model, arXiv:2403.02785 (2024, revised 2025) — a monotone discretisation with a convergence proof; cited as the occupied method, not measured here.
  • The source lab: sin-mfg research/mfg-lab/mfg-lab.html, module MPR (kernel sha256 65c89093…, artifact sha256 37c0e3bd…), read-only; ported in instruments/price/fd.js and reproduced bit for bit on 2026-09-07.
  • The first-order game by its current, the monotone flow that is not a gradient, the maximal value function — the other reports of this series on the same group's work.