IdentifySequence
find a formula for the nth term of a given integer sequence
Calling Sequence
Parameters
Description
Examples
Compatibility
IdentifySequence(L)
IdentifySequence(L,n)
IdentifySequence(L,options)
L
-
list of integers
n
symbol
output
(optional) output = "expression", "procedure", or "nextterm"
start
(optional) start = 0 or 1
Given an integer sequence, this command attempts to find a formula for the nth term of that sequence.
Behind the scenes, this command uses gfun[listtorec] and rsolve to identify the sequence and generate the formula.
Only sequences that can be represented as a a linear recurrence with polynomial coefficients are supported. Not all computed formulas will lead to integer sequences when computed beyond the given number of terms; care must be taken to understand and assess the generated result.
The output option can be used to control the expression returned.
output="expression": This is the default; an expression is returned
output="procedure": Using this option will cause IdentifySequence to return a univariate procedure, which when invoked with a positive integer n, will return the nth term in the sequence.
output="nextterm": This will cause the next integer term in the sequence to be returned.
A second argument is only required for the default output. It specifies the variable to be used in the generated expression.
When the start=0 option is supplied, the first entry of the sequence will be considered as n=0 instead of the default, n=1.
IdentifySequence1,3,5,7,9,n
2n−1
IdentifySequence1,3,5,7,9,output=nextterm
11
f≔IdentifySequence1,3,5,7,9,output=procedure
f ≔ procnlocali1,loc0,loc1,loc2,tmp2,tmp1,i2;ifn<=44thenloc0 ≔ 1;loc1 ≔ 3;ifn<1thenerrorindex must be %1 or greater,1elifn=1thenreturnloc0elifn=2thenreturnloc1end if;fori1from2ton − 1doloc2 ≔ −loc0+2*loc1;loc0 ≔ loc1;loc1 ≔ loc2end do;loc1elsetmp2 ≔ 2−110;tmp1 ≔ 31;i2 ≔ convertn − 2,base,2;ifi2[1]=1thentmp1 ≔ 53end if;fori1insubsop1=,i2dotmp2 ≔ LinearAlgebra:-MatrixMatrixMultiplytmp2,tmp2;ifi1=1thentmp1 ≔ LinearAlgebra:-MatrixVectorMultiplytmp2,tmp1end ifend do;tmp1[1]end ifend proc
f6
seqfi,i=1..10
1,3,5,7,9,11,13,15,17,19
g≔IdentifySequence1,3,5,7,9,output=procedure,start=0
g ≔ procnlocali1,loc0,loc1,loc2,tmp2,tmp1,i2;ifn<=44thenloc0 ≔ 1;loc1 ≔ 3;ifn<0thenerrorindex must be %1 or greater,0elifn=0thenreturnloc0elifn=1thenreturnloc1end if;fori1ton − 1doloc2 ≔ −loc0+2*loc1;loc0 ≔ loc1;loc1 ≔ loc2end do;loc1elsetmp2 ≔ 2−110;tmp1 ≔ 31;i2 ≔ convertn − 1,base,2;ifi2[1]=1thentmp1 ≔ 53end if;fori1insubsop1=,i2dotmp2 ≔ LinearAlgebra:-MatrixMatrixMultiplytmp2,tmp2;ifi1=1thentmp1 ≔ LinearAlgebra:-MatrixVectorMultiplytmp2,tmp1end ifend do;tmp1[1]end ifend proc
seqgi,i=0..9
IdentifySequence6,3,0,−3,−6,x
−3x+9
IdentifySequence1,2,4,8,16,t
2t−1
IdentifySequence1,2,4,8,16,t,start=0
2t
IdentifySequence1,5,13,29,61,125,y,start=0
42y−3
IdentifySequence1,1,2,3,5,8,13,n
12−510−52+12n−1+12+51052+12n−1
The IdentifySequence command was introduced in Maple 2025.
For more information on Maple 2025 changes, see Updates in Maple 2025.
See Also
GAMMA
gfun
gfun[listtorec]
identify
rsolve
Download Help Document