IdentifySequence - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


IdentifySequence

find a formula for the nth term of a given integer sequence

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

IdentifySequence(L)

IdentifySequence(L,n)

IdentifySequence(L,options)

Parameters

L

-

list of integers

n

-

symbol

output

-

(optional) output = "expression", "procedure", or "nextterm"

start

-

(optional) start = 0 or 1

Description

• 

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.

Examples

IdentifySequence1,3,5,7,9,n

2n1

(1)

IdentifySequence1,3,5,7,9,output=nextterm

11

(2)

fIdentifySequence1,3,5,7,9,output=procedure

fprocnlocali1&comma;loc0&comma;loc1&comma;loc2&comma;tmp2&comma;tmp1&comma;i2&semi;ifn<=44thenloc01&semi;loc13&semi;ifn<1thenerrorindex must be %1 or greater&comma;1elifn&equals;1thenreturnloc0elifn&equals;2thenreturnloc1end if&semi;fori1from2ton1doloc2&minus;loc0&plus;2&ast;loc1&semi;loc0loc1&semi;loc1loc2end do&semi;loc1elsetmp22110&semi;tmp131&semi;i2convertn2&comma;base&comma;2&semi;ifi2&lsqb;1&rsqb;&equals;1thentmp153end if&semi;fori1insubsop1&equals;&comma;i2dotmp2LinearAlgebra:-MatrixMatrixMultiplytmp2&comma;tmp2&semi;ifi1&equals;1thentmp1LinearAlgebra:-MatrixVectorMultiplytmp2&comma;tmp1end ifend do&semi;tmp1&lsqb;1&rsqb;end ifend proc

(3)

f6

11

(4)

seqfi&comma;i=1..10

1&comma;3&comma;5&comma;7&comma;9&comma;11&comma;13&comma;15&comma;17&comma;19

(5)

gIdentifySequence1&comma;3&comma;5&comma;7&comma;9&comma;output=procedure&comma;start=0

gprocnlocali1&comma;loc0&comma;loc1&comma;loc2&comma;tmp2&comma;tmp1&comma;i2&semi;ifn<=44thenloc01&semi;loc13&semi;ifn<0thenerrorindex must be %1 or greater&comma;0elifn&equals;0thenreturnloc0elifn&equals;1thenreturnloc1end if&semi;fori1ton1doloc2&minus;loc0&plus;2&ast;loc1&semi;loc0loc1&semi;loc1loc2end do&semi;loc1elsetmp22110&semi;tmp131&semi;i2convertn1&comma;base&comma;2&semi;ifi2&lsqb;1&rsqb;&equals;1thentmp153end if&semi;fori1insubsop1&equals;&comma;i2dotmp2LinearAlgebra:-MatrixMatrixMultiplytmp2&comma;tmp2&semi;ifi1&equals;1thentmp1LinearAlgebra:-MatrixVectorMultiplytmp2&comma;tmp1end ifend do&semi;tmp1&lsqb;1&rsqb;end ifend proc

(6)

seqgi&comma;i=0..9

1&comma;3&comma;5&comma;7&comma;9&comma;11&comma;13&comma;15&comma;17&comma;19

(7)

IdentifySequence6&comma;3&comma;0&comma;3&comma;6&comma;x

3x+9

(8)

IdentifySequence1&comma;2&comma;4&comma;8&comma;16&comma;t

2t1

(9)

IdentifySequence1&comma;2&comma;4&comma;8&comma;16&comma;t&comma;start=0

2t

(10)

IdentifySequence1&comma;5&comma;13&comma;29&comma;61&comma;125&comma;y&comma;start=0

42y3

(11)

IdentifySequence1&comma;1&comma;2&comma;3&comma;5&comma;8&comma;13&comma;n

1251052+12n1+12+51052+12n1

(12)

Compatibility

• 

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