Skip to content

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

Léela en español

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

日本語で読む

本页也有简体中文版本。

阅读简体中文版本

Formula of a sequence from its terms (find_sequence_function)

The formula of a sequence from its first terms, given only when it also predicts two more.

How to write it

find_sequence_function(terms, variable)

A formula a(n) that gives every term, with the terms that follow it; one term short, the rule as a hint.

terms
The first terms, whole numbers or fractions, the first being a(1). Takes a list.
variable
The index of the formula, a name such as n. Takes a variable, or a list of variables.

Examples

  • 1,4,9,16,25,…⇒n2\displaystyle 1, 4, 9, 16, 25, \ldots \Rightarrow n^{2}
    find_sequence_function([1, 4, 9, 16, 25], n)

    In the solver, find_sequence_function([1, 4, 9, 16, 25], n) gives n^2.

    Open in the solver
  • 1,1,2,3,5,8,13,21,…⇒fibonacci⁡(n)\displaystyle 1, 1, 2, 3, 5, 8, 13, 21, \ldots \Rightarrow \operatorname{fibonacci}(n)
    find_sequence_function([1, 1, 2, 3, 5, 8, 13, 21], n)

    In the solver, find_sequence_function([1, 1, 2, 3, 5, 8, 13, 21], n) gives fibonacci(n).

    Open in the solver
  • 1,2,6,24,120,…⇒n!\displaystyle 1, 2, 6, 24, 120, \ldots \Rightarrow n!
    find_sequence_function([1, 2, 6, 24, 120], n)

    In the solver, find_sequence_function([1, 2, 6, 24, 120], n) gives n!.

    Open in the solver
  • 2,3,5,5,8,7,…⇒{3n+12if n mod 2=1n+1otherwise\displaystyle 2, 3, 5, 5, 8, 7, \ldots \Rightarrow \begin{cases} \frac{3 n+1}{2} & \text{if } n \bmod 2 = 1 \\ n+1 & \text{otherwise} \end{cases}
    find_sequence_function([2, 3, 5, 5, 8, 7], n)

    In the solver, find_sequence_function([2, 3, 5, 5, 8, 7], n) gives piecewise((3n + 1)/2 if n % 2 = 1, n + 1 otherwise).

    Open in the solver
  • 3,8,17,32,57,100,177,…⇒n2+2n\displaystyle 3, 8, 17, 32, 57, 100, 177, \ldots \Rightarrow n^{2}+2^{n}
    find_sequence_function([3, 8, 17, 32, 57, 100, 177], n)

    In the solver, find_sequence_function([3, 8, 17, 32, 57, 100, 177], n) gives n^2 + 2^n.

    Open in the solver
  • find_linear_recurrence

    The recurrence a list of terms obeys, given only when it also holds on two more.

  • next_terms

    The terms that follow a list, given only when a rule explains it and predicts two more.

  • numeric_product

    Multiply an expression over a range, as a decimal.

  • differences

    The differences between neighbouring elements of a list.

  • numeric_sum

    Add up an expression over a range, as a decimal.

  • sum_convergence

    Test whether the sum of an expression over a variable converges.