Although it is okay to use the ":=" or SetDelayed
command, the plain Set
command "=" may be simpler for the first few statements, because they have constants on the RHS. So, we begin with
ClearAll["Global`*"]
s[1, 1] = 1 - a;
s[1, 2] = a;
For the next two statements we need to use the Blank[]
expression, which is abbreviated with the underscore, as
s[_, 0] = 1;
s[0, _] = 1;
In the above, there is no need to name the blank, since the name does not appear on the RHS.
Now we can code
s[i_, j_] := Simplify[Sum[s[1, k] s[i - k, j], {k, 1, 2}]]
Here, we need to name the blanks and use the the ":=" symbol, because $i$ and $j$ appear on the RHS. Also, we could have coded this SetDelayed
before the Set
statements, but the more general cases are usually defined after the more specific cases.
Now we can try to find s[1,3], but if we do we will get an error, because we have left something out. When $i$ is 1 and $k$ is 2, we get an s[-1,3] in our sum, and that is a problem.
So, we can add the statement s[-1,_] = 0;
Now we can make a table of values of $s_{ij}$ like this
t = Table[s[irow, jcol], {irow, 0, 4}, {jcol, 1, 3}]
t // TableForm
$\begin{array}{ccc}
1 & 1 & 1 \\
1-a & a & 1-a \\
a^2-a+1 & -(a-2) a & a^2-a+1 \\
-a^3+a^2-a+1 & a \left(a^2-2
a+2\right) & -a^3+a^2-a+1 \\
a^4-a^3+a^2-a+1 & -a \left(a^3-2
a^2+2 a-2\right) & a^4-a^3+a^2-a+1
\\
\end{array}$
Edit 1:
Also, since the expression for s[i,j]
is a recursion relation, to avoid recalculating the values of $s_{ij}$ you may want to use
s[i_, j_] := s[i, j] = Sum[s[1, k] s[i - k, j], {k, 1, 2}] // Simplify
instead of the first definition. This new definition tells MMA to save the intermediate values, which uses more memory, but will be faster if you need to calculate many values $s_{ij}$ for large $i$ and $j$.
Edit 2:
Now claim there are only two unique columns in any table t
with any number of rows and columns calculated as above. This conjecture seems obvious by inspection using a large number of rows and column. Here's how we can verify the claim for a few rows and columns. First take the transpose, which gives a list of the columns. Then drop the second element and use Union
to get a list of unique columns. There is only one element, so there is only one unique column, except for the second column. Here's the code:
t = Table[s[irow, jcol], {irow, 0, 50}, {jcol, 1, 30}];
Drop[Transpose[t], 2] // Union // Length
A second conjecture is the $i$-th row of the first column can be written as $s_{i,1}=\Sigma_{k=0}^i(-a)^k$. We can find another form for this expression with
Sum[(-a)^k, {k, 0, i}]//Factor
$\frac{a (-a)^i+1}{a+1}$
That's the closed form for the $s_{i,j\neq 2}$. We can get a closed form for $s_{i2}$ by a third conjecture that the $i$-th row of the second column of table $t$ is $s_{i,2}=2+(-a)^i-2\Sigma_{k=0}^i(-a)^k$. Here's the code
Factor[ 2 + (-a)^i - 2 Sum[(-a)^k, {k, 0, i}] ]
$\frac{(-a)^i+(-a)^{i+1}+2 a}{a+1}$
To prove the conjectures using Mathematica, searching this forum for "induction" would be a good first step. Also, replacing $a$ with $-b$ from the beginning could make the expressions simpler in an induction proof.