Recurrence Relation Calculator and Sequence Generator

Generate an indexed sequence from a recursive formula and its initial values. Use earlier terms such as a(n-1), the current index n, arithmetic, powers, and common functions. Everything is parsed and calculated locally in your browser.

Define the recurrence

Enter only the expression after a(n) =. Explicit multiplication uses *.

Separate up to 50 numbers with commas, semicolons, or new lines.

Examples:

Private by design: the recurrence and initial values are processed on this device. They are not uploaded, stored, or added to the page URL.

Generated sequence

The Fibonacci example is generated below.

Advertisement

Recurrence syntax

Terms and index

a(n-1), a(n-2), … refer to earlier terms. Use n for the current integer index.

Forward references, a(n), and non-integer lags are not accepted.

Operators and grouping

+   −   *   /   %   ^   ( )

Powers are evaluated before multiplication, then addition. Use parentheses whenever the intended order may be unclear.

Numbers and constants

Integers, decimals, and scientific notation such as 2.5e-3 are accepted. Constants: pi and e.

Functions

abs(x), sqrt(x), floor(x), ceil(x), round(x), exp(x), ln(x), log10(x), min(x,y), and max(x,y).

What a recurrence relation needs

Recursive rule

aₙ = F(n, aₙ₋₁, …, aₙ₋ₖ)

The rule defines a new term from its index and one or more earlier terms.

Initial conditions

aₙ₀, aₙ₀₊₁, …, aₙ₀₊ₖ₋₁

At least k consecutive starting values are required when the largest lag is k.

Iteration

n = n₀ + k, n₀ + k + 1, …

The calculator moves forward one index at a time, making each calculated term available to the next step.

A recurrence determines a unique forward sequence only after sufficient initial conditions are supplied. This calculator checks that every backward reference is available when the first calculated term is evaluated.

Recurrence relation examples

Fibonacci sequence

With a(n) = a(n-1) + a(n-2), a(0) = 0, and a(1) = 1, the sequence begins 0, 1, 1, 2, 3, 5, 8, ….

Geometric sequence

With a(n) = 3a(n-1) and a(0) = 2, enter 3 * a(n-1) to generate 2, 6, 18, 54, ….

Factorials and index-dependent rules

With a(0) = 1 and a(n) = n·a(n-1), enter n * a(n-1) to generate factorials. The value of n always matches the index shown in the result table.

Method, assumptions, and limits

The parser accepts only the documented numbers, constants, term references, operators, parentheses, and functions. It does not execute JavaScript or arbitrary code. References must have the exact backward form a(n-k), where k is a positive integer no greater than 50. The first index must be an integer from −1,000,000 through 1,000,000.

The tool generates no more than 500 total terms from at most 50 initial values. It stops with an index-specific error if a calculation divides by zero, uses a function outside its real-number domain, or produces NaN or infinity. The remainder operator % follows JavaScript’s remainder convention, so a negative dividend can produce a negative remainder.

Calculations use IEEE 754 double-precision floating-point numbers. Table values are displayed with up to 12 significant digits, while copied and downloaded values use JavaScript’s round-trip numeric representation. Large integers beyond 2⁵³ − 1 and many decimal fractions may not be exact. This is a numerical sequence generator, not a symbolic solver: it does not derive closed forms, solve for unknown coefficients, or prove convergence.

Calculation note: the implementation follows the defining forward-iteration rule for recurrence relations and checks each example against its stated initial conditions. Last reviewed: .

Recurrence relation calculator FAQ

What is a recurrence relation?

A recurrence relation defines each new term of a sequence using its index and one or more earlier terms. Initial values provide the starting information needed to apply that rule.

How do I enter the Fibonacci recurrence?

Enter a(n-1) + a(n-2) as the recurrence, enter 0, 1 as the initial values, set the first index to 0, and choose the desired total number of terms.

How many initial values do I need?

You need at least as many consecutive initial values as the largest backward reference. For example, a recurrence containing a(n-3) needs at least three initial values so that reference exists at the first calculation.

Can the recurrence depend on n?

Yes. Use n anywhere in the formula, such as a(n-1) + n. The first calculated term uses the integer index immediately after the final initial value.

Can I use decimals and division?

Yes. Decimal and scientific-notation numbers, division, constants, and the documented functions are supported. Results use floating-point arithmetic and may be rounded for display.

Why did sequence generation stop?

The tool stops if a formula divides by zero, takes a square root or logarithm outside its real-number domain, or grows beyond the finite numeric range. The validation message identifies the affected index.

Does this calculator find a closed form?

No. It iterates the recurrence numerically to generate terms. It does not derive a symbolic closed-form expression, solve characteristic equations, or prove convergence.

Does the calculator store my formula or sequence?

No. Formula parsing, sequence generation, copying, and CSV creation happen locally in your browser. The tool does not transmit or save entered values.

Explore more tools