Recurrence Relation Solver
Type a recurrence such as a(n) = 5a(n-1) - 6a(n-2) + 2^n with its initial terms. The solver finds the characteristic roots, the general and particular solutions, the constants and a checked closed form.
Funziona nel tuo browser. I tuoi file non lasciano mai il dispositivo. Scopri come verificarlo
…
Come si usa
- 1Type the recurrence
Enter the relation with an equals sign, or load an example.
- 2Add initial terms
List a(0), a(1) and so on, separated by commas.
- 3Read the roots
See the characteristic equation and its exact roots.
- 4Follow the method
Read the homogeneous and particular solutions and the constants.
- 5Use the closed form
Copy the formula or evaluate it at any n.
- 6Check the table
Compare iteration with the closed form and view the chart.
Informazioni su questo strumento
A recurrence relation defines each term of a sequence from earlier ones. The Fibonacci numbers satisfy a(n) = a(n−1) + a(n−2), the number of moves in the Towers of Hanoi satisfies a(n) = 2a(n−1) + 1, and a loan balance with monthly interest and a fixed payment follows a(n) = 1.01a(n−1) − 200. When the recurrence is linear with constant coefficients there is a complete method for finding a closed form, a formula for a(n) that does not need the earlier terms. Substitute a(n) = rⁿ into the homogeneous part to get the characteristic equation, find its roots, and combine the powers rⁿ with constants. A repeated root r contributes rⁿ, n·rⁿ and so on, and a pair of complex roots ρe^(±iθ) contributes ρⁿ cos nθ and ρⁿ sin nθ. A forcing term g(n) such as 2ⁿ or n² needs a particular solution of the same shape, multiplied by a power of n when its base is already a characteristic root. Finally the initial terms fix the constants. This solver follows exactly that method and shows every step. You type the recurrence as you would write it, using a(n−1), a_(n−2) or a[n−3], or in shifted form such as a(n+2) = 3a(n+1) − 2a(n). It reads the coefficients exactly, factors the characteristic polynomial over the rationals, and expresses irrational roots as surds like (1 + √5)/2 and complex roots by their modulus and angle, such as √2 and π/4. Particular solutions are found by undetermined coefficients with exact fractions, the constants by solving the initial-value system, and surd constants such as √5/5 are recognised. The closed form is checked term by term against direct iteration of the recurrence, which is done with exact fractions as long as the numbers stay manageable.
What the table and chart show
The table lists n, the value obtained by iterating the recurrence from your initial terms, the value of the closed form and whether they match. Exact iteration keeps fractions such as 969699/100 for the loan example until the denominators grow too large, then switches to decimals. A separate box evaluates the closed form at any n, which is how you get a(30) or a(100) without iterating. The chart plots the terms and has a signed log scale for sequences that grow exponentially. If the forcing term is not a sum of polynomial × sⁿ pieces, for example 1/n or sin n, the solver still iterates the recurrence and says that no closed form was built.
Worked example
Solve a(n) = 5a(n−1) − 6a(n−2) with a(0) = 1 and a(1) = 4. The characteristic equation is r² − 5r + 6 = 0 with roots 2 and 3, so a(n) = C1·2ⁿ + C2·3ⁿ. The initial terms give C1 + C2 = 1 and 2C1 + 3C2 = 4, so C1 = −1 and C2 = 2, and a(n) = 2·3ⁿ − 2ⁿ. The first terms are 1, 4, 14, 46, 146 and 454, and all 13 table rows match. Adding the forcing term 2ⁿ makes 2 a resonant root: the trial form is B0·n·2ⁿ, the coefficient is B0 = −2, and the closed form becomes −5·2ⁿ + 6·3ⁿ − 2n·2ⁿ, giving 1, 4, 18, 74 and 278.
Limits
Only linear recurrences with constant coefficients and order up to 8 are solved; n·a(n−1), a(n−1)² or divide-and-conquer recurrences such as T(n) = 2T(n/2) + n are not. Characteristic polynomials of degree three or more without rational roots are solved numerically, so their closed forms use decimal constants. Exact iteration falls back to decimals when the fractions become too large.
Esempio svolto
a(n) = 5a(n−1) − 6a(n−2), a(0) = 1, a(1) = 4: roots 2 and 3, a(n) = 2·3ⁿ − 2ⁿ, terms 1, 4, 14, 46, 146.
In breve
- Categoria: Matematica e scienze
- Funziona nel browser, senza registrazione né caricamento.
- Le informazioni che inserisci restano sul tuo dispositivo.
- Disponibile in inglese.
- Contenuto rivisto l'ultima volta il:
- Fonte ufficiale: Discrete Mathematics: An Open Introduction (O. Levin), section 2.4
Domande frequenti
How do I type the recurrence?
Write it with an equals sign and terms like a(n-1), a_(n-2) or a[n-3], for example a(n) = a(n-1) + a(n-2). Shifted forms such as a(n+2) = a(n+1) + a(n) work too.
How many initial terms do I need?
As many as the order of the recurrence: two for a(n−1) and a(n−2), three if a(n−3) appears. Extra terms are checked against the recurrence.
What happens with a repeated root?
A root r repeated m times gives the terms rⁿ, n·rⁿ, up to n^(m−1)·rⁿ, each with its own constant. The solver shows this in the homogeneous solution.
What is resonance in a particular solution?
If the base s of a forcing term sⁿ is already a characteristic root, the usual trial form solves the homogeneous equation and fails. Multiplying it by n, or by a higher power of n, fixes this.
How are complex roots handled?
A complex pair with modulus ρ and angle θ is written as ρⁿ(C cos nθ + D sin nθ), so the closed form stays real. The angle is shown as a multiple of π when it is one.
Can I start the sequence at n = 1?
Yes. Choose a(1) first and the initial terms are read as a(1), a(2) and so on. The constants are solved with those indices.
