Recurrence Relation Solver
Use a(n-1), a(n-2), numbers, n,
common functions, and + - * / ^. Enter exactly one initial
value per recurrence order, starting at a(0).
Use this Recurrence Relation Solver to enter values, adjust options, and review results in a compact responsive workspace.
Results are calculated automatically as you enter data.
Use a(n-1), a(n-2), numbers, n,
common functions, and + - * / ^. Enter exactly one initial
value per recurrence order, starting at a(0).
▼ See explanations and tips below ▼
A recurrence relation is a rule that defines each new term of a sequence from earlier terms. Instead of giving one direct formula for the value of \(a(n)\), it gives a step-by-step rule for building the sequence.
For example, the recurrence relation
says that each new term is \(5\) more than the previous term. If the starting value is \(a(0)=3\), the sequence begins:
The starting value matters because the recurrence rule alone does not tell you where the sequence begins. With \(a(0)=3\), the next term is \(8\); with \(a(0)=10\), the same rule would produce \(10, 15, 20, 25,\ldots\) instead.
In this calculator, sequence indexes are zero-based. That means the first term is labeled \(a(0)\), the second is \(a(1)\), and the selected term \(a(n)\) refers to the term at index \(n\) in that zero-based sequence.
Recurrence relations are useful whenever a pattern is easier to describe by “what happens next” than by a direct formula. They appear in algebra, discrete mathematics, computer science, combinatorics, algorithm analysis, population models, finance examples, and many classroom sequence problems.
They are especially helpful for:
A recurrence relation is not always the fastest way to compute a far-away term by hand, but it is often the clearest way to define the pattern.
A recurrence relation starts with one or more known terms, then applies a rule repeatedly. A general way to write this idea is:
The function \(f\) represents the rule. It might use only the previous term, or it might use several earlier terms. It may also use the index \(n\) itself.
For example:
uses the two previous terms, so it needs exactly two starting values. If \(a(0)=0\) and \(a(1)=1\), then:
The sequence begins:
An arithmetic sequence can be described recursively as:
where \(d\) is the common difference. With zero-based indexing, the matching closed form is:
A geometric sequence can be described recursively as:
where \(r\) is the common ratio. With zero-based indexing, the matching closed form is:
These two special cases are common because their patterns are easy to recognize: arithmetic sequences grow by repeated addition, while geometric sequences grow by repeated multiplication.
A first-order affine recurrence has the form:
Here, \(r\) multiplies the previous term and \(c\) adds a constant. When \(r\ne 1\), one common closed form is:
When \(r=1\), the rule becomes arithmetic:
so the closed form is:
A second-order homogeneous linear recurrence has the form:
A standard method for many such recurrences is to form the characteristic equation:
When the characteristic equation has two distinct real roots \(\lambda_1\) and \(\lambda_2\), the closed form often has this structure:
The constants \(C_1\) and \(C_2\) are determined from the initial values. This is why initial values are not optional: they select one sequence from the family of sequences that follow the same recurrence rule.
Not every recurrence relation has a simple closed form, and not every closed form is easy to detect. A generated table of terms can still be useful even when no closed form is shown.
Suppose the rule is:
with initial value:
Generate terms one at a time:
The first few terms are:
The common difference is \(5\), so the closed form is:
Suppose the rule is:
with initial value:
Then:
The first few terms are:
The common ratio is \(3\), so the closed form is:
Suppose the rule is:
with initial values:
Because the rule refers to \(a(n-2)\), it needs two initial values. The next terms are:
The sequence begins:
This is a second-order recurrence because each new term depends on the two previous terms.
Suppose the recurrence rule is:
If the only initial value is \(a(0)=3\), the sequence begins:
Because this is a first-order recurrence, entering \(3, 10\) is ambiguous: the rule itself should determine \(a(1)\) from \(a(0)\).
The calculator therefore requires exactly one initial value for this rule and rejects extra values. A second-order rule such as \(a(n)=a(n-1)+a(n-2)\) requires exactly two initial values.
Matching the number of initial values to the order keeps the generated sequence and any closed form consistent.
The selected term result shows the value of \(a(n)\) at the currently selected zero-based index. For example, \(a(4)=23\) means the term at index \(4\) is \(23\). Since indexing starts at \(0\), this is the fifth displayed term in ordinary counting language.
The order tells you the largest lag used in the rule. A rule using only \(a(n-1)\) is first order. A rule using \(a(n-2)\) is second order. Higher order rules require more initial values.
A detected arithmetic pattern means the generated terms have a constant difference. A detected geometric pattern means the generated terms have a constant ratio, with checks to avoid dividing by zero. Integer patterns are checked exactly; floating-point patterns use a numerical tolerance.
A detected closed form means the expression was structurally verified as a supported first-order affine or second-order homogeneous constant-coefficient recurrence. Irrational characteristic roots are kept in exact radical form. If no closed form is detected, the sequence may still have one outside these supported families.
The last term is \(a(\text{count}-1)\), because the generated list begins at \(a(0)\). If you generate \(20\) terms, the last displayed index is \(19\).
The chart and table are best used together. The chart helps reveal overall growth, decay, oscillation, or sudden changes, while the table gives exact displayed values for each generated term. Expansion steps show how early terms were substituted from previous values, which is often the clearest way to check whether the rule was entered as intended.
Integer-only rules are evaluated exactly, even beyond JavaScript’s ordinary safe-integer range. Rules using decimals, division, mathematical functions, or negative powers use floating-point approximation and are labeled accordingly. Approximate scientific notation follows the selected display precision. To keep the page responsive, an exact term may contain at most 10,000 digits.
Use a recurrence relation when a sequence is naturally described by how each term follows from earlier terms.
Common use cases include:
Recurrence relations are also useful when a direct formula is unknown, difficult to derive, or less intuitive than the step-by-step rule.
This calculator generates a finite list of terms. It does not prove every long-term property of the sequence. A pattern detected from generated terms is evidence about those displayed terms, not a universal proof unless it is supported by separate algebraic reasoning.
The recurrence rule must use supported notation and operations. Previous terms should be written with \(a(n-k)\) notation, where \(k\) is a positive integer. Rules may use numbers, arithmetic operations, parentheses, previous-term references, and the index \(n\). Decimal numbers should use a period, not a decimal comma.
The number of generated terms is limited to \(3\) through \(80\). Display precision can be set to \(4\), \(8\), or \(12\) decimal places. Floating-point values may be rounded or shown in scientific notation; exact integers are displayed in full up to the 10,000-digit safety limit.
The closed-form display is intentionally limited. It is designed for supported first-order affine rules and supported second-order homogeneous linear rules with real characteristic roots. Many valid recurrence relations, including higher-order recurrences, complex-root cases, nonhomogeneous second-order cases, and rules involving unsupported functions, may still generate terms but will not show a detected closed form.
If a recurrence involves division by zero, overflow, or another operation that produces a non-finite value, the generated sequence is not valid for display. For coursework, proofs, engineering, finance, or scientific work, treat generated values as a checking aid and verify important conclusions with exact algebra, appropriate software, or a qualified expert.
A recurrence rule tells you how to continue a sequence, but it does not always tell you where to start. The initial values supply the starting point. Different initial values can produce different sequences even when the recurrence rule is the same.
The order is the largest number of steps backward that the rule references. A rule using \(a(n-1)\) is first order, while a rule using \(a(n-2)\) is second order. The calculator requires exactly that many initial values.
This calculator uses zero-based indexing, so the first displayed term is \(a(0)\). That means \(a(1)\) is the second displayed term, \(a(2)\) is the third, and so on. Always check the index before comparing results with a textbook that starts at \(a_1\).
No. It only means the rule did not match one of the supported closed-form detection patterns. Some recurrences have closed forms that require methods beyond the supported cases, and some do not have simple closed forms at all.
The most common reasons are missing previous-term notation, too few initial values, unsupported symbols, decimal commas, non-integer lags, or unsupported function names. Use notation such as \(a(n-1)\), keep lags positive integers, and enter initial values as a numeric list.
Books and Open Textbooks