Toolvito

Processed online by Toolvito

Recurrence Relation Solver

Type a recurrence such as a(n) = 5a(n-1) - 6a(n-2) and its initial conditions to get the closed form with every step, the first terms and a check against the recurrence itself. Divide-and-conquer recurrences such as T(n) = 2T(n/2) + n get the master theorem and the exact unrolled form.

Recurrence relation

Recurrence relation

Write a(n), a_n, a_{n-1}, a[n-1] or T(n/2).

One per step back; for T(n/2) one start value such as T(1) = 1.

Optional: found from the recurrence.

Optional (n).

1 to 200.

More options

Significant digits of decimal values, 2 to 30.

When you run a task here, Toolvito receives the information you submit for processing. Download the result within one hour after the job finishes. Choose Delete files now to request earlier removal. The hourly cleanup normally removes files within one to two hours after completion.

How to solve a recurrence

  1. Type the recurrence: a(n) = a(n-1) + a(n-2), a_n = 3a_{n-1} + 4a_{n-2}, a[n+2] = a[n+1] + 2a[n] or T(n) = 2T(n/2) + n.
  2. Type the initial conditions, such as a(0) = 0, a(1) = 1 (one for each step back). Without them you get the general solution with constants C1, C2, ….
  3. Select Solve. Read the closed form, the steps, the table of the first terms and the checks.

Methods

  • Linear, constant coefficients (a(n) = c₁a(n−1) + … + cₖa(n−k) + g(n), up to order 8): try rⁿ to get the characteristic equation; each root r gives rⁿ, a repeated root also n·rⁿ, n²·rⁿ …, and complex roots give rⁿcos(nθ) and rⁿsin(nθ). The generating function is shown for the homogeneous case.
  • Non-homogeneous terms g(n) made of polynomials, exponentials such as 2ⁿ, and sines and cosines: a particular solution by undetermined coefficients, multiplied by nᵐ where the form already solves the homogeneous part (resonance).
  • Other linear recurrences, such as a(n) = n·a(n−1) or a(n) = a(n−1) + 1/n: SymPy's rsolve, or unrolling into a product and a sum.
  • Divide and conquer, T(n) = a·T(n/b) + f(n): the master theorem compares f(n) with n^(log_b a) (with the log-factor case and the regularity condition), and unrolling T(n) = a·T(n/b) + f(n) = a²·T(n/b²) + a·f(n/b) + f(n) = … gives the exact form for n = n₀·bᵐ (the substitution or iteration method). Different divisions in one recurrence (T(n/2) and T(n/3)) are not solved.
  • Nonlinear recurrences, such as a(n) = 2.5·a(n−1)·(1 − a(n−1)): the terms and, for a(n) = F(a(n−1)), the fixed points L = F(L) and whether they attract (|F′(L)| < 1).

How the answers are checked

The closed form is compared with the terms computed straight from the recurrence with exact fractions (40 terms), put back into the recurrence, and compared with SymPy's rsolve as a second solver. For divide and conquer the exact form is compared with the recursion itself for n = n₀·bᵐ, m = 0 … 20. If a check disagrees, no answer is given.

Related tools