# When a heat pulse switches color

Henry Shin · Refactor · Mathematical companion · November 27, 2026

Remove the holding step from a heat grid and the thermometer error grows like the square of the wall distance. Follow the two checkerboard colors to prove the exact law, then recover the logarithmic doubling cost in higher dimensions when holding returns.

Remove the holding step. A cell now sends a quarter of its heat to each of its four neighbors and keeps none. Put one unit at the center of a checkerboard. After one tick all the surviving heat is on the other color. After two ticks it is back on the starting color. How much cancellation can the thermometer get from subtracting those two pulses?

## Follow the heat across two colors

Keep the [original thermometer](https://refactor.press/refactors/heat-grid#choose-three-weights). It reads the center cell minus the average of its four immediate neighbors. The square has odd side 2d − 1, so a zero wall sits d lattice steps from the center in each direction. Start the computation with exact temperatures. Each subsequent cell update can add any signed error between −ε and +ε. We want the smallest error allowance for the final reading that works at every run length.

Try just nine cells. After the first tick, each of the four edge cells holds 1/4. After the second, the center holds 1/4 and each corner holds 1/8. The remaining 1/4 has crossed a wall. Subtract the second pulse from the first. The positive entries sum to 1 and the magnitudes of the negative entries sum to 3/4. If errors choose their signs to match those entries, one tick back contributes (7/4)ε to the reading. With half the heat held at each cell, the same lag contributed only (5/8)ε because the two pulses agreed at the edges.

[Compare the two pulse arrays with and without holding](https://refactor.press/refactors/heat-grid-checkerboard#checkerboard-pulses).

## Read the error as surviving heat

Call the new averaging rule B. Let e₀ be the unit pulse at the center and p_{t} = B^{t}e₀ its distribution after t ticks on the finite square. At the first tick Be₀ assigns 1/4 to each neighbor. Thus the thermometer’s weight vector is q = e₀ − Be₀. Since the update is symmetric, moving these weights back t ticks applies B another t times. The weights become

w_{t} = B^{t}q = p_{t} − p_{t+1}.

The sign pattern now tells us as much as the individual weights. Every step changes the parity of the sum of the cell’s coordinates. Deleting the heat that leaves the square preserves this property for the heat still inside. So p_{t} and p_{t+1} have disjoint supports at every tick. Write S_{t} for the total surviving heat and ‖v‖₁ for the sum of absolute entries. Then ‖w_{t}‖₁ = S_{t} + S_{t+1}. We can attain the sum of these contributions over any finite run by assigning +ε on each positive backward weight and −ε on each negative one.

To add up the surviving heat, regard the pulse as a random walker started at the center. Let τ be the first tick at which it hits a zero wall. The mass left after t ticks is just S_{t} = Pr(τ > t). A path that lasts k ticks contributes 1 to exactly k of the survival counts, at times 0 through k − 1. Hence ∑_{t≥0} S_{t} = E₀τ, the expected time to exit from the center. The sharp all-run factor C(d), in units of ε, follows immediately.

C(d) = ∑_{t≥0} (S_{t} + S_{t+1})

= 2 E₀τ − 1.

The missing unit is S₀. Every finite partial sum is attainable, and the sums increase to this value. On the 3 × 3 square, we can compute the whole allowance with just three more numbers. Write c, b, k for the mean time to exit starting at a center, edge, or corner. Count one tick and then average the time still to go. A step to the wall leaves zero.

c = 1 + b,

b = 1 + (c + 2k)/4,

k = 1 + b/2.

These equations give b = 7/2 and c = 9/2. The sharp all-run allowance is therefore 8ε on these nine cells. The same thermometer with half holding had allowance [(77/16)ε](https://refactor.press/refactors/heat-grid#where-77-over-16-comes-from).

## A quadratic to fit the walls

On a line the two walls sit at −d and d. Try a quadratic for the mean time to exit from location j. It should vanish at both walls, and counting one tick should recover its present value from the average of the two neighboring values. The function u(j) = d² − j² meets both requirements.

1 + [u(j − 1) + u(j + 1)]/2 = u(j).

The mean exit time is finite. On a finite interval there is a positive chance to exit within 2d steps from every interior point, uniformly over starting points. The averaging equation with these wall values has a unique solution, since a difference attaining a positive interior maximum must take the same value at both its neighbors and eventually at a wall. Thus E₀τ = d² on the line, and C(d) = 2d² − 1. Doubling the wall distance adds exactly 6d²ε to the worst-case allowance.

Now work in n dimensions, with walls at ±d on every axis. Let a_{i} > 0 be the chance of selecting axis i, with ∑ a_{i} = 1, and choose either direction on that axis with equal probability. Read the center minus the neighbor average with those same directional weights. Each step still switches the color, so the exact formula 2E₀τ − 1 survives in every dimension.

We can bound E₀τ from both sides. On axis i the mean exit time from coordinate j alone is (d² − j²)/a_{i}. That coordinate moves with probability a_{i}, and the same quadratic decreases by one in expectation each tick. The whole walk may exit sooner on another axis. Taking the fastest axis gives E₀τ ≤ d²/max_{i} a_{i}. For the other direction, the expected increase in the squared distance |x|² per tick is exactly one. Sum those increases up to exit, first stopping after at most N ticks and then letting N grow. The stopped squared distance is bounded by nd², and the upper bound just proved gives a finite mean exit time. We obtain E₀τ = E₀|x_{τ}|² ≥ d², because some coordinate reached a wall.

2d² − 1 ≤ C(d) ≤ 2d²/(max_{i} a_{i}) − 1.

For fixed dimension and axis probabilities the all-run factor therefore grows quadratically in wall distance. On the line we saw the precise cost of a doubling. In a box the mean exit time supplies the exact factor for the chosen geometry.

## Put the holding step back

Let a fixed fraction h stay at each cell, with 0 < h < 1, and distribute the rest by the same rule B. One tick is now A = hI + (1 − h)B. Keep the thermometer q = (I − B)e₀, where I is the identity. The same subtraction still finds its weights in the pulse, with a different normalization. For p_{t} = A^{t}e₀ on the box,

q = (I − A)e₀/(1 − h),

w_{t} = (p_{t} − p_{t+1})/(1 − h).

Assign the value +1 to one color and −1 to the other. Every neighbor has the opposite value, so averaging over neighbors flips the sign. The new update multiplies this checkerboard pattern by 2h − 1 at interior cells whose neighbors are all inside. On the free lattice it does so everywhere. With no holding the pattern reverses sign indefinitely. With positive holding its amplitude shrinks as |2h − 1|^{t}. We can now ask which patterns survive long enough to determine the doubling law.

## What survives in higher dimensions?

For the n-dimensional update just constructed, a pulse on the unrestricted lattice has one-tick coordinate variances σ_{i}² = (1 − h)a_{i}.

Try a Fourier wave with frequency θ. One update multiplies it by λ(θ) = h + (1 − h) ∑_{i} a_{i} cos θ_{i}. The checkerboard is the wave with frequency (π, …, π). For 0 < h < 1 the only frequency on the torus with |λ| = 1 is zero. At frequencies θ = η/√t, expanding each cosine gives

λ(η/√t)^{t} → exp(−½ ∑_{i} σ_{i}² η_{i}²).

This is the Fourier transform of a Gaussian. After t ticks its coordinate widths are σ_{i}√t. Call its density g_{t}(x), and measure position in those widths by setting z_{i} = x_{i}/(σ_{i}√t). Differentiating both the height and the exponential of this density gives

−∂g_{t}(x)/∂t = [g_{t}(x)/(2t)] (n − ∑_{i} z_{i}²).

To add the absolute change over all space, integrate against g_{t}. Under that density the z_{i} are independent standard normal variables. The squared radius X = ∑_{i} z_{i}² therefore has the chi-squared distribution with n degrees of freedom. The Gaussian therefore predicts E|X − n|/(2t) for the absolute change of the free pulse. The thermometer divides this change by 1 − h. Dimension changes the coefficient. The power 1/t survives because the increase in the pulse’s volume cancels the fall in its height.

### What the walls contribute

The lattice and boundary estimates extend to the centered box with walls x_{i} = ±d. Here are the steps that make the doubling limit precise. Write D_{t} = p_{t} − p_{t+1} for the free pulse difference. Its Fourier multiplier is (1 − λ)λ^{t}. In the scaled frequency variable η, the n-dimensional volume element contributes t^{−n/2} and 1 − λ contributes t^{−1}. The next Taylor term is smaller by a further factor 1/t. Outside a neighborhood of zero, |λ| is bounded strictly below one. Thus the pointwise error in replacing D_{t} by −∂g_{t}/∂t is O(t^{−n/2−2}), uniformly over the cells.

Sum first over |x|² ≤ B t log(t + 1). The number of cells there is O((t log(t + 1))^{n/2}). Outside, the probability of a displacement that large is smaller than any prescribed inverse power of t if B is chosen large enough, by the bounded increments on each axis. The mesh in scaled space has spacing of order t^{−1/2}, so replacing the sum of the absolute Gaussian profile by its integral costs O(t^{−3/2}) in the pulse norm. These estimates give

‖D_{t}‖₁ = E|X − n|/(2t) + O(t^{−3/2}),

∑_{x} |x|² |D_{t}(x)| ≤ K.

Each axis may be reflected separately, since the two directions on it have equal weights and a step cannot jump over a wall. Folding the free difference with alternating signs therefore gives the box difference exactly. At most twice the free absolute mass outside the box is lost. The second estimate bounds that loss by 2K/d² per tick through time d². For the later ticks, choose any axis i. The mean time for that coordinate to hit ±d from j is (d² − j²)/σ_{i}², as one checks by substitution into the one-step recurrence. This bounds the mean exit time of the box by d²/σ_{i}². Applied to the difference at time d², which has absolute mass O(d^{−2}), it bounds the entire later sum by a constant.

For a definite cost per doubling, the bounded boundary correction also has to converge. Scale space by d and time by d² so the walls stay fixed at ±1. For each positive scaled time, the Gaussian approximation makes every finite group of reflected copies converge in the spatial Riemann sum. Copies more than M box widths away add at most O(M^{−2}) to the scaled norm by the same second-moment estimate. Before scaled time one the correction is uniformly bounded. After it, a block of twice the maximum mean exit time leaves at most half the mass, so successive blocks give an integrable exponential bound. Dominated convergence now gives one limiting boundary correction. This is the [doubling argument on the square](https://refactor.press/refactors/heat-grid-size#why-doubling-has-a-limit), with a reflected copy for each index in ℤ^{n}.

Write C(d) for the sharp factor valid for every run length. The free terms sum through time d², and their O(t^{−3/2}) remainders are summable. Restoring the thermometer factor gives, with a constant β independent of d,

C(d) = [E|X − n|/(1 − h)] log d + β + o(1),

C(2d) − C(d) → [E|X − n|/(1 − h)] log 2.

The constants in the estimates above may depend on n, h, and the axis probabilities, all held fixed as the box grows. Changing the preference among axes stretches the pulse along some directions and compresses it along others. Measuring each coordinate in its own Gaussian width removes those preferences from the limiting doubling coefficient for this matched thermometer.

### Three doubling costs

The coefficient can be evaluated from one integral. Put k = n/2. The variable X/2 has density u^{k−1} exp(−u)/Γ(k), mean k, and equal total positive and negative deviations from its mean. Integrating the deficit up to k, using the derivative of u^{k} exp(−u), gives E|X − n| = 4k^{k} exp(−k)/Γ(k). Here is the result with h = 1/2 and equally likely axes.

Increase in the sharp all-run factor when the wall distance doubles. The finite column comes from exact backward propagation on boxes of sides 31 and 63. Multiply either column by the local tolerance ε for an error allowance.

| Dimension | d = 16 to 32 | Large-box limit |
| --- | --- | --- |
| 1 | 1.34308 | 1.34177 |
| 2 | 2.04367 | 2.03996 |
| 3 | 2.57049 | 2.56487 |

In two dimensions the squared radius has mean two and E|X − 2| = 4/e. With h = 1/2 this recovers the original (8/e) log 2. At h = 0 the checkerboard frequency has magnitude one, so the Gaussian calculation about frequency zero alone loses a whole surviving mode. The exact exit-time calculation at the start of this article tells us what that mode costs.

## Related reading

What if larger grids hold less heat on each tick? Set h = 1/d, where d is the wall distance, and the sharp error grows linearly. The companion follows the color until it fades, then adds up the smooth part that remains. [When a shrinking hold gives linear error growth](https://refactor.press/refactors/shrinking-hold).

The square proof checks the Gaussian against the update at the moment it is proposed and then bounds the contribution from the walls. [What does doubling the distance to the wall cost?](https://refactor.press/refactors/heat-grid-size#where-the-logarithm-comes-from)

The finite-difference form of the local Gaussian estimate used here is treated by Gregory Lawler and Vlada Limic. [Random Walk: A Modern Introduction, Chapter 2, Exercise 2.11](https://math.uchicago.edu/~lawler/srwbook10.pdf#page=61).
