# Table of values and graph of a recurrent sequence: tableseq

### 5.13.4 Table of values and graph of a recurrent sequence: tableseq

The tableseq command fills a column of a spreadsheet with a recurrence relation. The spreadsheet can be opened with Alt+t (see Section 3.5).

tableseq takes three arguments, which can be different depending on how many terms are involved in the recurrence relation.

For a one term recurrence relation:

- tableseq takes three arguments:
  - f(x), a formula which defines the recurrence, through un+1=f(un).
  - x, the variable.
  - u0, the initial term of the sequence.
- tableseq(f(x),x,u0) fills the current column of the spreadsheet, starting with the selected cell (or cell 0 if the entire column is selected), with the formula f(x), the next cell with the variable x, followed by the terms u0, u1, … of the sequence. (If the current cell is column C, row n, these latter cells will actually contain (if in row k) =evalf(subst(C$n,C$(n+1),C(k−1))), which means if you change the value in one cell, the values in the later cells will change accordingly.) See also plotseq, Section 7.17, for a graphic representation of a one-term recurrence sequence.

#### Example.

Display the values of the sequence u0=3.5, un+1=sin(un)
Select a cell of the spreadsheet (for example B0) and input in the command line:

tableseq(sin(x),x,3.5)

Output:

row | B
0 | sin(x)
1 | x
2 | 3.5
3 | -0.35078322769
4 | -0.343633444925
5 | -0.336910330426
… | …

More generally, for a recurrence relation where each term depends on the previous k terms:

- tableseq takes three arguments:
  - f(x1,x2,…,xk), a formula which defines the recurrence, through un+1=f(un,…,un−k).
  - [x1,…,xk], a list of variables.
  - [u0,…,uk−1], a list of the beginning k terms.
- tableseq(f(x1,…,xk),[x1,…,xk],[u0,…,uk−1]) fills the current column of the spreadsheet, starting with the selected cell (or cell 0 if the entire column is selected), with the formula f(x1,x2,…,xk), followed by the variables x1,…,xk, followed by the terms u0, u1, … of the sequence.

#### Example.

Display the values of the Fibonacci sequence u0=1, u1=1,…, un+2=un+un+1
Select a cell, say B0, and:
Input:

tableseq(x+y,[x,y],[1,1])

Output:

row | B
0 | x+y
1 | x
2 | y
3 | 1
4 | 1
5 | 2
… | …