Maths & numbers

Second-order linear recurrence calculator

Calculate a term of a second-order recurrence from two starting values.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

The recurrence determines later terms from the two starting values. Choosing index zero or one returns a supplied starting value.

THE FORMULAuₙ = a uₙ₋₁ + b uₙ₋₂

A worked example

Starting at 2 and 3 with uₙ = 2uₙ₋₁ − uₙ₋₂ gives u₅ = 7.

Good to know

The first term is indexed by zero.

Carry two earlier values through each update

Start with u₀ = 2 and u₁ = 3, then apply uₙ = 2uₙ₋₁ − uₙ₋₂. The next terms are u₂ = 2 × 3 − 2 = 4 and u₃ = 2 × 4 − 3 = 5. Continuing gives u₄ = 6 and u₅ = 7. The target index five therefore identifies the sixth listed term.

The SVG labels the sequence from index zero and highlights the two inputs used to produce a later term. Updating both stored values together matters because the earlier value must still be available when the next expression is evaluated.

The recurrence starting at two and three produces successive values four through seven2u₀3u₁4u₂5u₃6u₄7u₅Each new value = 2 × previous − earlierExample u₂ = 2 × 3 − 2 = 4
For uₙ = 2uₙ₋₁ − uₙ₋₂, the target u₅ is 7. Indices start at zero.

Use characteristic roots to understand the sequence shape

For constant coefficients A and B, substitute a trial solution uₙ = rⁿ into uₙ = Auₙ₋₁ + Buₙ₋₂. The resulting characteristic equation is r² − Ar − B = 0. The default coefficients give (r − 1)² = 0, which permits a linear-in-index solution. The initial values fix it as uₙ = 2 + n.

Different coefficients can produce growth, alternating signs or oscillation. The Quadratic root sum and product calculator helps inspect the characteristic equation, while two starting values determine the specific sequence. Target indices zero and one return the initial values directly. Repeated iteration uses numerical arithmetic, so rounding errors can grow when the recurrence amplifies small changes in its earlier terms.

A few questions, answered

Why are two initial terms required?

Each update depends on two preceding terms. Both starting values are needed to determine all later terms.

Can this represent Fibonacci numbers?

Yes. Use initial values zero and one, with both recurrence coefficients equal to one.

Find your calculator

Start typing to explore the library.