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,
Differencesto them, you do get a periodic sequence. – Szabolcs Oct 27 '15 at 15:06{1,2,4,5,7,8,10,11}could be viewed as the coordinates of atoms in 1d crystal – matheorem Oct 27 '15 at 15:20FunctionPeriod[FindSequenceFunction[Differences[{1, 2, 4, 5, 7, 8, 10, 11}], k], k]. – J. M.'s missing motivation Oct 27 '15 at 15:22period[list_] := (list[[# + 1]] - list[[1]]) &@ Length[Tally[Differences[list]]].period[{1, 2, 4, 5, 7, 8, 10, 11}]gives 3 – matheorem Oct 27 '15 at 15:47Tallywill not work for{1,1,3,1,1,3,1,1,3}. In my previous post quite related to this one http://mathematica.stackexchange.com/a/69128/4742 , bill suggest me to use "FindLinearRecurrence`. It works, but I don't understand this function, does it always give the right period? – matheorem Oct 28 '15 at 01:55FindLinearRecurrence. I should use this. I have modified my answer. – matheorem Oct 28 '15 at 06:30