# How to find period of a discrete sequence?

For example,

{1,2,3,4,5,6,7,8}


has period 1, the base is {1}

{1,2,4,5,7,8,10,11}


has period 3, the base is {1,2}

I notice there is a built-in function FunctionPeriod, but it doesn't work. eg

l[n_]:={1,2,4,5,7,8,10,11}[[n]]
FunctionPeriod[l[n],n,Integers]


So how to write a function period to find the period of discrete sequence.

ps: The sequence could be non-integers, for example sqrt, reals,

• The sequences you show are not periodic at all. But if you apply Differences to them, you do get a periodic sequence. – Szabolcs Oct 27 '15 at 15:06
• In that case: FunctionPeriod[FindSequenceFunction[Differences[{1, 2, 4, 5, 7, 8, 10, 11}], k], k]. – J. M. is away Oct 27 '15 at 15:22
• Might I suggest answering your own question, if you think you've figured it out? :) – J. M. is away Oct 27 '15 at 15:48
• Modulo the already noted issue of taking successive differences, there is this prior related post. – Daniel Lichtblau Oct 27 '15 at 20:44
• closely related: 80163 – Kuba Oct 28 '15 at 8:06

Let

list={1, 2, 4, 5, 7, 8, 10, 11}


then Differences[list] transform is list to periodic form

{1, 2, 1, 2, 1, 2, 1}


Length@FindLinearRecurrence@Rationalize@Differences[list] gives the periodicity is 2

Rationalize is necessary for real number list

But we want the translation period, so we can make the following

list[[2+1]]-list[[1]]


this gives the result 3

So the function that serves this purpose can be defined as

Clear[discreteperiod];
discreteperiod[list_] := Module[
{recurrence = FindLinearRecurrence@Rationalize@Differences@list},