OFFSET
1,9
COMMENTS
Shift is the measure of the position of the palindromic subsequence within the corresponding sequence of first differences, defined as the number of terms being dropped from the left end of the sequence of first differences minus those dropped from its right end. When shift is a positive number, it indicates the number of steps that the palindrome has moved to the right from its symmetric position.
LINKS
V.J. Pohjola, Table of n, a(n) for n = 1..10000
V.J. Pohjola, Line plot for n=1...10000
V.J. Pohjola, Line plot for n=1...100
EXAMPLE
For n = 1, differences = 3; longest palindrome = 3; a(1) = 0 - 0 = 0.
For n = 2, differences = 3, 19; longest palindrome = 3; a(2) = 0 - 1 = -1.
For n = 14, differences = 3, 19, 3, 19, 3, 19, 3, 3, 16, 3, 3, 16, 3, 3; longest palindrome = 3, 3, 16, 3, 3, 16, 3, 3; a(14) = 6 - 0 = 6.
MATHEMATICA
rootsn = Flatten[Position[Table[Floor[Tan[-i]], {i, 1, 10^4}], 1]];
difn = Differences[rootsn];
ldn = Length[difn];
kmax = 500; palsn = {}; lenpalsn = {0}; shiftn = {}; posn = {};
Do[diffin = difn[[1 ;; k]]; lendiffin = Length[diffin];
pmax = k - Last[lenpalsn];
t = Table[difn[[p ;; k]], {p, 1, pmax}];
sn = Flatten[Select[t, # == Reverse[#] &]];
If[sn == {},
AppendTo[palsn, Last[palsn]] && AppendTo[lenpalsn, Last[lenpalsn]],
AppendTo[palsn, sn] && AppendTo[lenpalsn, Length[Flatten[sn]]]];
AppendTo[posn, Position[t, Last[palsn]]]; pp = Last[Flatten[posn]] - 1;
qq = lendiffin - (pp + Last[lenpalsn]);
AppendTo[shiftn, pp - qq], {k, 1, kmax}];
shiftn (*a(n)=shiftn[[n]]*)
CROSSREFS
KEYWORD
sign
AUTHOR
V.J. Pohjola, Oct 21 2017
STATUS
approved
