%I #7 Nov 25 2013 20:25:26
%S 1,1,-1,1,1,1,-1,1,-1,-1,-1,-1,1,1,-1,1,-1,-1,-1,-1,1,-1,1,1,-1,-1,1,
%T -1,1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,-1,-1,1,1,1,1,1,1,1,1,-1,1,1,1,-1,
%U -1,1,1,1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,-1,1,-1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,-1,-1,-1
%N G.f. is the limit of n-th degree polynomial P(n,x) = P(n-1,x) + a(n)*x^n that yields the least sum of squares of coefficients in P(n,x)^n, where a(n) = {-1,+1}, starting with a(0) = a(1) = 1.
%C It appears that if the value of a(n) results in the least sum of squares of coefficients in P(n,x)^n, then it also results in the least sum of squares of coefficients in P(n,x)^k for all k>n.
%e G.f.: A(x) = 1 + x - x^2 + x^3 + x^4 + x^5 - x^6 + x^7 - x^8 - x^9 - x^10 - x^11 + x^12 + x^13 - x^14 + x^15 - x^16 - x^17 - x^18 - x^19 + x^20 +...
%e Illustrate generating method.
%e Given P(1,x) = 1+x, to determine a(2), we compare the coefficients in (P(1,x) + x^2)^2 to (P(1,x) - x^2)^2 to see which has the least sum of squares of coefficients:
%e (1+x+x^2)^2 = 1 + 2*x + 3*x^2 + 2*x^3 + x^4;
%e (1+x-x^2)^2 = 1 + 2*x - x^2 - 2*x^3 + x^4;
%e the sum of squares of coefficients is 19 and 11, respectively; thus a(2) = -1 since it yields the least sum of squares.
%e Then since P(2,x) = 1+x-x^2, to determine a(3), we compare the coefficients in (P(2,x) + x^3)^3 to (P(2,x) - x^3)^3 to see which has the least sum of squares of coefficients:
%e (1+x-x^2+x^3)^3 = 1 + 3*x - 2*x^3 + 6*x^4 - 4*x^6 + 6*x^7 - 3*x^8 + x^9;
%e (1+x-x^2-x^3)^3 = 1 + 3*x - 8*x^3 - 6*x^4 + 6*x^5 + 8*x^6 - 3*x^8 - x^9;
%e the sum of squares of coefficients is 112 and 220, respectively; thus a(3) = +1 since it yields the least sum of squares. (Should they ever equal, choose +1 as the new term.)
%e Continuing in this way generates all the terms of this sequence.
%o (PARI) {A=[1,1];print1("1,1,"); for(i=1,60,
%o A=concat(A,y);P=truncate(Ser(A));
%o SUMSQ=Vec(P^(#A))*Vec(P^(#A))~;
%o SNEG=subst(SUMSQ,y,-1);SPOS=subst(SUMSQ,y,1);
%o if(SNEG>=SPOS,t=1,t=-1);A[#A]=t;print1(t,",");)}
%K sign
%O 0
%A _Paul D. Hanna_, Nov 25 2013