How this calculation works
A finite sequence can suggest a linear recurrence without proving that it is the true rule of an infinite sequence. This calculator fits the smallest supported constant-coefficient rational recurrence using only designated training terms. Trailing terms are held out for an independent exact check, and forecasts are shown only if that validation passes or no holdout was requested. Coefficients use newest lag first.
a_n=c₁a_(n−1)+…+c_d a_(n−d); infer the smallest supported d with a unique exact training solution, then validate held-out terms recursively.A worked example
For 1,1,2,3,5,8,13,21 with the last two values held out, the six training terms determine order two and coefficients (1,1). Recursive predictions from the training endpoint give 13 and 21, matching both reserved values. The next three predicted terms are 34,55 and 89. The successful check supports this recurrence for the supplied data; it does not prove every later observation must follow it.
Good to know
Exact rational sequences of length two through forty. Hold out zero to ten trailing terms while retaining at least two training terms. Candidate order is at most min(maxOrder,floor(trainingLength/2)), with maxOrder≤10. The coefficient system must be unique and consistent. All-zero training has an explicit order-zero model. Up to ten forecasts are suppressed when held-out validation fails. Nonlinear and variable-coefficient recurrences are outside the supported model.
Reference: SymPy — sequence recurrence inference (opens in a new tab) ↗
Training and held-out terms must play different roles
For a candidate order d, training equations express each available term as a combination of the previous d terms. Exact row reduction checks consistency and uniqueness of the coefficients. The solver tries orders in increasing order, so a returned order is minimal within the supported uniquely determined rational family, not among every imaginable sequence rule.
The holdout suffix is excluded from those equations. During validation, each subsequent prediction uses earlier predictions, not observed held-out values. That prevents an incorrect model from borrowing the answer at every step. A one-step conditional check using the true previous held-out term would be a different, less strict validation protocol.
The Second-order linear recurrence calculator evaluates a recurrence with known coefficients, while this page infers an unknown supported order and validates reserved sequence terms.
An exact fit is still an inference from finite information
Infinitely many rules can agree with a finite list and diverge afterward. A polynomial interpolation or a specially defined piecewise rule can always be constructed to match those same observations. The inferred recurrence is a compact model in the declared class, not a proof of the sequence’s provenance or future behavior.
Using a higher order can absorb more data without improving explanatory value. Requiring a unique coefficient solution and enough training terms limits that flexibility, while held-out checks expose some overfitting. When no supported unique recurrence fits, the calculator asks for more data or a different order bound rather than manufacturing one arbitrary continuation.
Zero training and failed validation need explicit outputs
If every training value is zero, the simplest supported model is order zero: every next value is zero. A later nonzero held-out observation immediately fails that model. Returning a positive-order recurrence with arbitrary coefficients would hide the fact that the training values do not identify those coefficients.
A failed held-out check leaves the inferred training coefficients visible, along with actual and predicted values, but suppresses future forecasts. This preserves the useful diagnostic without promoting an already contradicted continuation. Synthetic exact recurrences, deliberately corrupted holdout terms and independent symbolic linear solves verify these separate behaviors.
A few questions, answered
Does this prove the infinite sequence follows the recurrence?
No. It finds a uniquely determined model in a bounded rational class and checks the supplied holdout. Finite data cannot prove an unrestricted future rule.
Why are future values missing after a failed holdout?
The fitted model already contradicts reserved observations. The diagnostic remains visible, but the calculator does not present further predictions as a validated continuation.