login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 


A293704
a(n) is the shift of the longest palindromic subsequence in the first n terms of A293700.
10
0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, 18, 17, 16
OFFSET
1,19
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. Thus, when shift is negative, the palindrome has moved leftward from its symmetric position.
EXAMPLE
For n = 1, first 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 = 22, differences = 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 3, 16, 3, 3, 16; longest palindrome = 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3; a(22) = 0 - 5 = -5.
MATHEMATICA
rootsp = Flatten[Position[Table[Floor[Tan[i]], {i, 1, 10^4}], 1]];
lrootsp = Length[rootsp];
difp = Differences[rootsp];
ldp = Length[difp];
kmax = 500; palsp = {}; lenpalsp = {0}; shiftp = {}; posp = {};
Do[diffip = difp[[1 ;; k]]; lendiffip = Length[diffip];
pmax = k - Last[lenpalsp];
t = Table[difp[[p ;; k]], {p, 1, pmax}];
sp = Flatten[Select[t, # == Reverse[#] &]];
If[sp == {},
AppendTo[palsp, Last[palsp]] && AppendTo[lenpalsp, Last[lenpalsp]],
AppendTo[palsp, sp] && AppendTo[lenpalsp, Length[Flatten[sp]]]];
AppendTo[posp, Position[t, Last[palsp]]]; pp = Last[Flatten[posp]] - 1;
qq = lendiffip - (pp + Last[lenpalsp]);
AppendTo[shiftp, pp - qq], {k, 1, kmax}];
lenpalsp;
shiftp (*a(n)=shiftp[[n]]*)
KEYWORD
sign
AUTHOR
V.J. Pohjola, Oct 21 2017
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified September 22 11:40 EDT 2024. Contains 376114 sequences. (Running on oeis4.)