Solve recurrence relations (solve_recurrence)
Solve a recurrence relation for a sequence.
How to write it
solve_recurrence(equations, unknown, variable)
Solve for the sequence in terms of its index. With t(n/b), n is a power of b and the answer states it.
- equations
- The recurrence, or a list that includes initial values such as a(0) = 1. Takes an equation, or a list of equations in brackets.
- unknown
- The unknown to solve for, such as y. Takes a variable, or a list of variables.
- variable
- The variable to work with, a name such as x. Takes a variable, or a list of variables.
Examples
solve_recurrence([a(n+1) = 2 a(n), a(0) = 1], a, n)In the solver,
Open in the solversolve_recurrence([a(n+1) = 2 a(n), a(0) = 1], a, n)gives[[a(n) -> 2^n]].solve_recurrence([t(n) = 2 t(n/2) + n, t(1) = 1], t, n)In the solver,
Open in the solversolve_recurrence([t(n) = 2 t(n/2) + n, t(1) = 1], t, n)gives[[t(n) -> n + n*ln(n)/ln(2) if n >= 1 and ln(n)/ln(2) : integer]].
Related functions
- recurrence_growth
The order of growth of a divide-and-conquer recurrence, as big_theta of a simple function.
- solve_ode
Solve a differential equation, or a system, with optional initial conditions.