%I #55 Mar 26 2022 17:46:47
%S 1,0,0,0,2,2,0,0,4,8,4,0,8,24,24,8,32,64,96,64,192,192,320,320,1024,
%T 768,1024,1280,4608,3584,3584,4608,18432,16384,14336,16384,69632,
%U 69632,61440,61440,262144,278528,262144,245760,1015808,1081344,1081344,1015808,4063232,4194304,4325376,4194304
%N Array read by rows: T(n,k) is the number of solutions to the equation Sum_{i=1..n} x_i^2 == k (mod 4) with x_i in 0..3, where n >= 0 and 0 <= k <= 3.
%C Let v(n) = [T(n,0), T(n,1), T(n,2), T(n,3)]' for n >= 0, where ' denotes transpose, and M = [[2,0,0,2], [2,2,0,0], [0,2,2,0], [0,0,2,2]]. We claim that v(n+1) = M*v(n) for n >= 0.
%C To see why this is the case, let j in 0..3, and consider the expressions 0^2 + j, 1^2 + j, 2^2 + j, and 3^2 + j modulo 4. It can be easily proved that these four numbers contain M[0,j] 0's, M[1,j] 1's, M[2,j] 2's, and M[3,j] 3's. (This is how the transfer matrix M was constructed. The idea is similar to _Jianing Song_'s ideas for sequences A101990, A318609, and A318610.)
%C It follows that v(n) = M^n * v(0), where v(0) = [1,0,0,0]'.
%C The minimal polynomial for M is z*(z - 4)*(z^2 - 4*z + 8) = z^4 - 8*z^3 + 24*z^2 - 32*z. Thus, M^4 - 8*M^3 + 24*M^2 - 32*M = 0, and so M^n*v(0) - 8*M^(n-1)*v(0) + 24*M^(n-2)*v(0) - 32*M^(n-3)*v(0) = 0 for n >= 4. This implies v(n) - 8*v(n-1) + 24*v(n-2) - 32*v(n-3) = 0 for n >= 4. Hence each sequence (T(n,k): n >= 0) satisfies the same recurrence b(n) - 8*b(n-1) + 24*b(n-2) - 32*b(n-3) = 0 for n >= 4. (For all k in 0..3, the recurrence is not satisfied for n = 3.)
%C Clearly, for each k in 0..3, we may find constants c_k, d_k, e_k such that T(n,k) = c_k*(2 + 2*i)^n + d_k*(2 - 2*i)^n + e_k*4^n for n >= 0 (where i = sqrt(-1)). We omit the details.
%H Colin Barker, <a href="/A330619/b330619.txt">Table of n, a(n) for n = 0..1000</a>
%H <a href="/index/Rec#order_12">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,8,0,0,0,-24,0,0,0,32).
%F T(n,k) = 8*T(n-1,k) - 24*T(n-2,k) + 32*T(n-3,k) for n >= 4 with initial conditions for T(1,k), T(2,k), and T(3,k) (for each value of k in 0..3) given in the example below. (The recurrence is not true for n = 3.)
%F T(n,k) = 4*T(n-1,k) - 8*T(n-2,k) + 2^(2*n-3) for n >= 3.
%F T(n,k) ~ 4^(n-1) for each k in 0..3.
%F Sum_{k = 0..3} T(n,k) = 4^n.
%F v(n+1) = M*v(n) and v(n) = M^n * [1,0,0,0]' for n >= 0, where M = [[2,0,0,2], [2,2,0,0], [0,2,2,0], [0,0,2,2]] and v(n) = [T(n,0), T(n,1), T(n,2), T(n,3)]'.
%F From _Colin Barker_, Dec 21 2019: (Start)
%F If we consider this array as a single sequence (a(n): n >= 0), then:
%F G.f.: (1 - 2*x^4 + 2*x^5)*(1 - 4*x^4 + 4*x^8 + 4*x^10) / ((1 - 2*x^2)*(1 + 2*x^2)*(1 - 4*x^4 + 8*x^8)).
%F a(n) = 8*a(n-4) - 24*a(n-8) + 32*a(n-12) for n > 15. (End)
%e Array T(n,k) (with rows n >= 0 and columns 0 <= k <= 3) begins as follows:
%e 1, 0, 0, 0;
%e 2, 2, 0, 0;
%e 4, 8, 4, 0;
%e 8, 24, 24, 8;
%e 32, 64, 96, 64;
%e 192, 192, 320, 320;
%e 1024, 768, 1024, 1280;
%e 4608, 3584, 3584, 4608;
%e ...
%e T(n=2,k=0) = 4 because we have the following solutions (x_1, x_2) to the equation x_1^2 + x_2^2 == 0 (mod 4) (with x_1, x_2 in 0..3): (0,0), (0,2), (2,0), and (2,2).
%e T(n=2,k=1) = 8 because we have the following solutions (x_1, x_2) to the equation x_1^2 + x_2^2 == 1 (mod 4) (with x_1, x_2 in 0..3): (0,1), (0,3), (1,0), (1,2), (2,1), (2,3), (3,0), and (3,2).
%e T(n=2,k=2) = 4 because we have the following solutions (x_1, x_2) to the equation x_1^2 + x_2^2 == 2 (mod 4) (with x_1, x_2 in 0..3): (1,1), (1,3), (3,1), and (3,3).
%e T(n=2,k=3) = 0 because we have no solutions (x_1, x_2) to the equation x_1^2 + x_2^2 == 3 (mod 4) (with x_1, x_2 in 0..3).
%p with(LinearAlgebra);
%p v := proc(n) local M, v0;
%p M := Matrix([[2, 0, 0, 2], [2, 2, 0, 0], [0, 2, 2, 0], [0, 0, 2, 2]]);
%p v0 := Matrix([[1], [0], [0], [0]]); if n = 0 then v0; else MatrixMatrixMultiply(MatrixPower(M, n), v0); end if;
%p end proc;
%p seq(seq(v(n)[k, 1], k = 1 .. 4), n = 0 .. 10);
%o (PARI) a(n) = ([2,0,0,2; 2,2,0,0; 0,2,2,0; 0,0,2,2]^n*mattranspose([1, 0, 0, 0]));
%o for(n=0, 30, print1(a(n), ", ")); /* after _Michel Marcus_'s program for A101990 */
%o (PARI) Vec((1 - 2*x^4 + 2*x^5)*(1 - 4*x^4 + 4*x^8 + 4*x^10) / ((1 - 2*x^2)*(1 + 2*x^2)*(1 - 4*x^4 + 8*x^8)) + O(x^50)) \\ _Colin Barker_, Dec 21 2019
%Y Columns include A228920 (k = 0), A229136 (k = 1).
%Y Cf. A101990, A228921, A229138, A318609, A318610, A330607, A330635.
%K nonn,tabf,easy
%O 0,5
%A _Petros Hadjicostas_, Dec 20 2019