# What should you store when two modes merge?

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

A formula returns zero for a term that equals two. Trace the error to the choice of coordinates and build an update that works through a double root.

Keep the Fibonacci starting values 0 and 1, but change the recurrence. This time the next term is 2. A formula that separates the sequence into two independent motions can give 0 on a computer at that very step. Where did the 2 go, and what should we have kept?

## Two or zero?

Take a real parameter δ and the recurrence

s_{n+1} = 2s_{n} + (δ² − 1)s_{n−1} (n ≥ 1).

With s₀ = 0 and s₁ = 1, substitution gives s₂ = 2 for every δ. For δ ≠ 0 the two multipliers are 1 + δ and 1 − δ. Separating their motions gives

s_{n} = ((1 + δ)^{n} − (1 − δ)^{n})/(2δ).

At n = 2 the numerator expands to 4δ. Try evaluating the displayed formula as written with δ = 2^{−55} in binary64 arithmetic, rounding each operation to nearest. The adjacent representable numbers below and above 1 are 1 − 2^{−53} and 1 + 2^{−52}. Both proposed multipliers lie closer to 1 than to either neighbor. Both round to 1.

Squaring now gives two identical ones. Their difference is exactly zero, and the denominator 2^{−54} is representable. The division returns zero. The information was lost when the two multipliers were stored. We can reproduce the failure before taking a large power or accumulating a long string of rounding errors.

## What the two modes almost agree on

The [Fibonacci refactor](https://refactor.press/refactors/recurrence.html) found a linear quantity that updates by multiplication. Applied here, its two choices give the following weighted differences.

  u_{n} = s_{n} − (1 + δ)s_{n−1}, u_{n+1} = (1 − δ)u_{n},

  v_{n} = s_{n} − (1 − δ)s_{n−1}, v_{n+1} = (1 + δ)v_{n}.

What do these measurements actually record? They share the ordinary difference d_{n} = s_{n} − s_{n−1}. Write p_{n} = s_{n−1} for the previous term. Then

u_{n} = d_{n} − δp_{n}, v_{n} = d_{n} + δp_{n}.

Their average gives d_{n}. Their difference gives 2δp_{n}. As δ shrinks, the previous term is encoded in a smaller and smaller discrepancy. At δ = 0, any two states with the same ordinary difference have identical modal readings. For instance, the pairs of successive terms (0, 1) and (10, 11) both give u = v = 1. Their next terms are 2 and 12. An update that retains only the common reading has lost the level of the sequence.

## Carry the difference forward

Keep the previous term and the ordinary difference directly. This asks for one addition to read the current term, s_{n} = p_{n} + d_{n}. To update the difference, subtract s_{n} from the original recurrence and collect the terms that survive.

  d_{n+1} = s_{n+1} − s_{n}

  = (s_{n} − s_{n−1}) + δ²s_{n−1}.

Moving forward shifts the current term into the previous-term slot. Together the two moves are

  p_{n+1} = p_{n} + d_{n},

  d_{n+1} = d_{n} + δ²p_{n}.

Both right-hand sides use the old state. These equations work for arbitrary initial values, starting from (p₁, d₁) = (s₀, s₁ − s₀). At every step they retain both stored terms, s_{n−1} = p_{n} and s_{n} = p_{n} + d_{n}. The conversion uses the same addition even when the roots meet.

In the opening example the state starts at (0, 1) and advances to (1, 1). Reading the new term gives 1 + 1 = 2, exactly in binary64 as well. For a step where both parts interact, take δ = 1/4 and start the sequence at 2 and 3. The state (2, 1) advances to (3, 1 + 2/16) = (3, 9/8). It gives s₂ = 33/8, the same value as 2 · 3 − (15/16) · 2 in the original recurrence.

[Compare the two calculations in the web edition](https://refactor.press/refactors/when-two-modes-merge#carry-the-difference).

## At the double root

Set δ = 0 in the two moves. The difference stays fixed and the previous term increases by that difference. After k steps a state (p, d) has become (p + kd, d). Thus for arbitrary s₀, s₁,

s_{n} = s₀ + n(s₁ − s₀) (n ≥ 0).

This is the two-step operator chain in concrete form. Subtract the identity from one update of the state. The remainder sends (p, d) to (d, 0), and applying that remainder twice gives zero. Each full update can therefore contribute the same increment once more. This is where the factor n comes from.

In the Fibonacci example the ordinary difference still needed input from the previous term. Here that dependence is exactly δ²p_{n}. At the double root it vanishes, and the ordinary difference becomes the quantity that moves on its own. The level is still needed to locate the sequence.

## The price of reconstructing a term

Suppose δ ≠ 0 is known exactly. Someone hands us readings u_{n} + e_{u} and v_{n} + e_{v}, each with absolute error at most ε. Subtracting the readings and dividing by 2δ reconstructs the previous term with error

|(e_{v} − e_{u})/(2δ)| ≤ ε/|δ|.

The bound is attained when the two errors are +ε and −ε. Equal errors cancel in the subtraction. This is a sharp absolute bound for recovering one term from separately perturbed modal readings. It describes exactly which errors the inverse change of coordinates amplifies.

There is also genuine growth in time. At the double root, increasing s₁ by η with s₀ fixed changes s_{n} by nη, even in exact arithmetic. For fixed n and fixed initial data, the two update rules make s_{n} a polynomial in δ², so the term itself has a regular limit as the roots meet. Carrying (p, d) avoids the small divisor in recovery. Accuracy over many steps still depends on the initial data, the growth of the recurrence, and rounding during those steps.

Continue with [Compute Hofstadter G by shifting Fibonacci digits](https://refactor.press/refactors/hofstadter-g.html). There a rounded real number can miss an integer by one. A change in how we write the input gives an exact answer and shows how close the calculation comes to a rounding boundary.

### Notes and sources

The first article derives the weighted differences and their inverse for a general second-order recurrence. [Find the quantity that moves on its own](https://refactor.press/refactors/recurrence.html#when-separation-needs-more).

David Goldberg explains how subtracting nearby rounded quantities exposes the errors already present in the operands, and describes the 53-bit significand of IEEE double precision. [What Every Computer Scientist Should Know About Floating-Point Arithmetic, especially “Cancellation” and “Formats”](https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html).
