linear_recurrence

std.seq.linear_recurrence · Level L2

The next s terms of a linear recurrence of order r: aₙ = constant + Σⱼ coeffsⱼ·aₙ₋ᵣ₊ⱼ, from the initial values a₀ … aᵣ₋₁, s the length of steps (only its length is read). A Scan of recurrence_step on the companion matrix. Fibonacci is r = 2, coefficients (1, 1), constant 0.

aₙ = c + Σⱼ coeffsⱼ·aₙ₋ᵣ₊ⱼ

Signature

linear_recurrence(init: f64[r], coeffs: f64[r], constant: f64[], steps: f64[s]) → f64[s]

Structure

The function as NOVA stores it: one box per input, operation and output, and arrows that carry values. A double border marks another library function this one runs — called once, or by Scan once per element; select it to open that function.

initf64[r]coeffsf64[r]constantf64[]stepsf64[s]Iotai1.0SizerReshapecrReshapeirReshapeicSubtractr1LessupSubtractdEquallast_rEquallastvEqualshiftMultiplybottomMultiplybvMultiplyshift_upAddCScan·recurrence_stepwindowsSlicenewestReshapeaaf64[s]
  • input
  • operation
  • constant
  • call
  • output

Verification

  • Signature proven by NOVA’s shape solver, for every size.
  • Equal to the reference window of the last r terms; new = constant + coeffs · window in exact rational arithmetic, on all 40 test cases.
  • All 175 float64 results inside the running error bound; the closest uses 72% of it.
  • Interpreter and NumPy backend return bit-identical results.
  • At float32 too: the 40 test cases rounded to float32, and 40 of them inside the running error bound at u = 2⁻²⁴; the closest uses 58% of it.
Accuracy in detail
correctly rounded (the float64 nearest the exact value)
60%
bit-equal to the NumPy formula in float64
76%
largest error, in units in the last place
180

Large ulp counts appear where a result is tiny next to the numbers it is computed from (after cancellation, for example), so one unit in the last place is tiny too; the absolute error is still inside the bound. Results within their own error of zero are not counted.

Identity

Calls
Called by
—
sha256:5bb9d7c1ec075edc4ea446343e86c87a97fcc36a1569c3c6e9137a98107a308e

The semantic hash of the graph. It changes when the program changes, and never when only its documentation does.

Control handle

Symbol
Ω:std.seq.linear_recurrence · Ω:linear_recurrence
Pins
sha256:3a3ea1103e80a488564b0c77fd74ddcbbde81be6c5810c3d6de613f412ebb6a9this graph and the 1 it reaches through calls
Evidence
sha256:b09b2e0c7ca82cdd9e4ae6ebf82703f48a654589e42f0720f966ee2839233116the hash of its verification record
Needs
no capability: a pure function

Through NOVA’s control layer, the symbol launches this function only while the program still matches what it pins: a change to this graph, or to any graph it reaches, needs a migration first.

ΣEML 2026

Efficient New Language — a high-density semantic overlay for humans and AI agents.

This site’s demos run on the real EML toolchain, in your browser.

© 2026 EveMissLab (一言諾科技有限公司) / Neo.K. All rights reserved.