1
$\begingroup$

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,

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

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},
  If[Head[recurrence] === FindLinearRecurrence, 
   Print["The period contained in the list is not enough"]; 
   Abort[], (list[[# + 1]] - list[[1]]) &@Length[recurrence]]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.