Skip to content

Esta página también está en español.

Léela en español

このページは日本語でも読めます。

日本語で読む

本页也有简体中文版本。

阅读简体中文版本

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

  • {a(n+1)=2a(n)a(0)=1⇒a(n)=2n\displaystyle \begin{cases} a(n+1) = 2 a(n) \\ a(0) = 1 \end{cases} \Rightarrow a(n) = 2^{n}
    solve_recurrence([a(n+1) = 2 a(n), a(0) = 1], a, n)

    In the solver, solve_recurrence([a(n+1) = 2 a(n), a(0) = 1], a, n) gives [[a(n) -> 2^n]].

    Open in the solver
  • {t(n)=2t(n2)+nt(1)=1⇒t(n)=n+nln⁡(n)ln⁡(2), n≥1, ln⁡(n)ln⁡(2)∈Z\displaystyle \begin{cases} t(n) = 2 t\left(\frac{n}{2}\right)+n \\ t(1) = 1 \end{cases} \Rightarrow t(n) = n+\frac{n \ln(n)}{\ln(2)},\ n \ge 1,\ \frac{\ln(n)}{\ln(2)} \in \mathbb{Z}
    solve_recurrence([t(n) = 2 t(n/2) + n, t(1) = 1], t, n)

    In the solver, solve_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]].

    Open in the solver
  • 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.