%I #20 Feb 24 2018 03:11:22
%S 0,-1,0,-1,0,-1,0,-1,-2,-3,-4,-5,-6,6,5,7,6,5,7,6,5,4,3,2,1,0,-1,-2,
%T -3,-4,-5,-6,-7,-8,-9,-10,-11,-12,-13,-14,-15,-16,-17,-18,18,17,16,15,
%U 14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,-1,-2,-3,-4,-5
%N a(n) is the shift of the longest palindromic subsequence in the first n terms of A293699.
%C 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.
%H V.J. Pohjola, <a href="/A293705/b293705.txt">Table of n, a(n) for n = 1..10000</a>
%H V.J. Pohjola, <a href="https://palindromesdotblog.files.wordpress.com/2018/02/shiftn-1-10000-a293705.pdf">Line plot for n=1...10000</a>
%H V.J. Pohjola, <a href="https://palindromesdotblog.files.wordpress.com/2018/02/shiftn-1-100-293705.pdf">Line plot for n=1...100</a>
%e For n = 1, differences = 3; longest palindrome = 3; a(1) = 0 - 0 = 0.
%e For n = 2, differences = 3, 19; longest palindrome = 3; a(2) = 0 - 1 = -1.
%e 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.
%t rootsn = Flatten[Position[Table[Floor[Tan[-i]], {i, 1, 10^4}], 1]];
%t difn = Differences[rootsn];
%t ldn = Length[difn];
%t kmax = 500; palsn = {}; lenpalsn = {0}; shiftn = {}; posn = {};
%t Do[diffin = difn[[1 ;; k]]; lendiffin = Length[diffin];
%t pmax = k - Last[lenpalsn];
%t t = Table[difn[[p ;; k]], {p, 1, pmax}];
%t sn = Flatten[Select[t, # == Reverse[#] &]];
%t If[sn == {},
%t AppendTo[palsn, Last[palsn]] && AppendTo[lenpalsn, Last[lenpalsn]],
%t AppendTo[palsn, sn] && AppendTo[lenpalsn, Length[Flatten[sn]]]];
%t AppendTo[posn, Position[t, Last[palsn]]]; pp = Last[Flatten[posn]] - 1;
%t qq = lendiffin - (pp + Last[lenpalsn]);
%t AppendTo[shiftn, pp - qq], {k, 1, kmax}];
%t shiftn (*a(n)=shiftn[[n]]*)
%Y Cf. A293698, A293751, A293700, A293702, A293704, A293699, A293701, A293706, A293703.
%K sign
%O 1,9
%A _V.J. Pohjola_, Oct 21 2017
|