# Pattern in a product of matrices

I am trying to figure out the elements of the $2\times 2$ matrix

$$B=A_nA_{n-1}A_{n-2}\cdots A_1,\;\; n=1,2,3,\ldots$$

where

$$A_k=\begin{bmatrix}a-2k&-k(k-1)-b\\1&0\end{bmatrix},$$

with $a,b>0$ fixed. I wrote the following script to see what's going on:

$Assumptions = a > 0 && b > 0; A[k_] := {{a - 2 k, -k (k - 1) - b}, {1, 0}}; kmax = 5; AA = Table[A[i], {i, 1, kmax}]; Apply[Dot, Reverse[AA]] // TraditionalForm  but the output is too cumbersome to infer the pattern. Can anyone suggest a way to have Mathematica 'massage' the result so as to make its general structure more transparent? • I found an occuring pattern. Im not able to exploit it, but this shows that there is a possible pattern. It builds up the first$n\$ matrices, expands them and looks at the polynomial coefficients for the (1,1) element matrices.matrices[n_]:=Rest[FoldList[Dot,IdentityMatrix,Table[{{a-2 k,-k (k-1)-b},{1,0}},{k,1,n}]]] Grid[{TraditionalForm[CoefficientList[#,{a,b}]]&/@matrices[[All,2,1]]}//Transpose] The first element in the coefficient matrices matches the recurrence {a(0)=1, a(1)=2, (n^2+n)*a(n)+(-4-2*n)*a(n+1)+a(n+2)}. OEIS A052897 – Julien Kluge Jan 28 '18 at 16:18
• Ohh sry, there should be an [[All,1,1]] instead of [[All,2,1]]. I wasn't able to find similar patterns for some other coefficients so this is probably a dead end. – Julien Kluge Jan 28 '18 at 16:30
• @JulienKluge: Thank you, I didn't know about OEIS. I had a typo in my question: the matrix product is actually supposed to be in the reverse order. I fixed it now. – Alex Jan 28 '18 at 23:04
• I wonder whether this link could be constructive or not. – Αλέξανδρος Ζεγγ Jan 29 '18 at 9:51

Here is a method that gets you a good way forward:

Set up the recursions and initial conditions first:

Transpose[Thread /@
{{a - 2 k, -k (k - 1) - b}, {1, 0}}.Array[C[##][k-1] &, {2, 2}]]]
{{C[1, 1][k] == (a - 2 k) C[1, 1][-1 + k] + (-b - (-1 + k) k) C[2, 1][-1 + k],
C[2, 1][k] == C[1, 1][-1 + k]},
{C[1, 2][k] == (a - 2 k) C[1, 2][-1 + k] + (-b - (-1 + k) k) C[2, 2][-1 + k],
C[2, 2][k] == C[1, 2][-1 + k]}}


and

Transpose[Thread /@ Thread[Array[C[##] &, {2, 2}] == {{-2 + a, -b}, {1, 0}}]]
{{C[1, 1] == -2 + a, C[2, 1] == 1},
{C[1, 2] == -b, C[2, 2] == 0}}


Note the form of the equations for C[2, 1][k] and C[2, 2][k]. As it turns out, since they are just expressible in terms of C[1, 1][k] and C[1, 2][k], we can convert the recurrences for C[1, 1][k] and C[1, 2][k] into three-term recurrences:

RSolve[{C[1, 1][k] == (a - 2 k) C[1, 1][-1 + k] + (-b - (-1 + k) k) C[1, 1][-2 + k],
C[1, 1] == -2 + a, C[1, 1] == 1}, C[1, 1], k]

RSolve[{C[1, 2][k] == (a - 2 k) C[1, 2][-1 + k] + (-b - (-1 + k) k) C[1, 2][-2 + k],
C[1, 2] == -b, C[1, 2] == 0}, C[1, 2], k]


In fact, you should now notice that both are just the same recurrence, but with different initial conditions. Unfortunately, if you try to execute any of those, you end up with a DifferenceRoot[] object, which does not give you new information. You might as well just set up the DifferenceRoot[] at the outset:

sol[a_, b_, p_, q_] := DifferenceRoot[Function[{y, n},
{(2 + 3 n + n^2 + b) y[n] + (4 + 2 n - a) y[1 + n] + y[2 + n] == 0,
y == p, y == q}]]


and then

left = sol[a, b, 1, a - 2]; right = sol[a, b, 0, -b];


Compare the result with evaluating the explicit product for the first 12 members:

And @@ Table[Array[Function[k, {{a - 2 (n - k + 1), -(n - k + 1) ((n - k + 1) - 1) - b},
{1, 0}}], n, 1, Dot] ==
{{left[n], right[n]}, {left[n - 1], right[n - 1]}} // Simplify,
{n, 12}]
True


As an aside, the sharp-eyed might recognize this to be a disguised version of the recurrence for evaluating the numerators and denominators of a continued fraction.

For instance:

With[{n = 10},
ContinuedFractionK[-k (k - 1) - b, a - 2 k, {k, 1, n}] ==
right[n]/left[n] // Simplify]
True


Not an answer, but I had an idea. You can write your sequence of matrix multiplications as a recursive system of equations

af[k_] := a - 2 k;
bf[k_] := -k (k - 1) - b;

Flatten /@ ({{m11[n + 1], m12[n + 1]}, {m21[n + 1],
m22[n + 1]}} == {{af[n + 1], bf[n + 1]}, {1, 0}}.{{m11[n],
m12[n]}, {m21[n], m22[n]}})];
reqFinal = oin[req, {m11 == af, m12 == bf, m21 == 1, m22 == 0}];


Now, my hope was the RSolve can be of help, but it is not. Nevertheless, we see that the recurrence table gives the correct values.

RecurrenceTable[reqFinal,{m11[n],m12[n],m21[n],m22[n]},{n,3}]//Column
(* {-2+a,-b,1,0}
{-2+(-4+a) (-2+a)-b,-(-4+a) b,-2+a,-b}
{(-2+a) (-6-b)+(-6+a) (-2+(-4+a) (-2+a)-b),-(-6+a) (-4+a) b-(-6-b) b,
-2+(-4+a) (-2+a)-b,-(-4+a) b} *)


If you define af and bf to give constant values 2 and 3 respectively, then RSolve can indeed solve this system

RSolve[reqFinal, {m11[n], m12[n], m21[n], m22[n]}, n]
(* {{m11[n] -> 1/4 ((-1)^n + 3^(1 + n)),
m21[n] -> 1/4 ((-1)^(1 + n) + 3^n), m12[n] -> -(3/4) ((-1)^n - 3^n),
m22[n] -> 1/4 (3 (-1)^n + 3^n)}} *)


However, as soon as there is an explicit k in your matrix elements, this no longer works. You should note that using unspecified values a and b

af[k_] := a;
bf[k_] := b;


is also solvable. Maybe this gives you some further ideas; maybe not.