Challenge
We once had a challenge to count domino tilings of m by n grid, and we all know that, for any fixed number of rows, the number of domino tilings by columns forms a linear recurrence. Then why not have a challenge to compute the linear recurrence?!
Let's define \$D_m(n)\$ as the number of domino tilings on a grid of \$m\$ rows and \$n\$ columns. Then the task is: given a single integer \$m \ge 1\$ as input, output the linear recurrence relation for \$D_m(n)\$.
If the relation has order \$k\$ (that is, \$D_m(n+k)\$ depends on \$k\$ previous terms), you need to output the coefficients \$a_i\$ of the recurrence relation
$$ D_m(n+k)=a_{k-1}D_m(n+k-1) + a_{k-2}D_m(n+k-2) + \cdots + a_0 D_m(n) $$
in the order of \$a_0\$ to \$a_{k-1}\$ or the reverse. There are infinitely many correct such relations; you don't need to minimize the order of the relation. But, to ensure that the result is at least minimally useful, the order \$k\$ cannot exceed \$2^m\$ for any input value of \$m\$.
(Side note: An actual sequence is defined only if the initial \$k\$ terms are given along with the recurrence equation. That part is omitted for simplicity of output, and to give incentive to approaches not using the brute-forced terms.)
Note that, for odd \$m\$, every odd-column term will be zero, so you will get a recurrence different from the OEIS entries which strip away zeroes (e.g. 3 rows, 5 rows, 7 rows).
Standard code-golf rules apply. The shortest code in bytes wins.
Examples
Here are the representations from the OEIS, adjusted for odd \$m\$. Initial terms start at \$D_m(0)\$, and the coefficients are presented from \$a_{k-1}\$ to \$a_0\$. Again, your program only needs to output the coefficients. To empirically check the correctness of your output of length \$k\$, plug in the \$k\$ initial terms from the respective OEIS entry, and see if the next \$k\$ terms agree.
m = 1
Initial terms [1, 0] # D(0) = 1, D(1) = 0
Coefficients [0, 1] # D(n+2) = D(n)
m = 2
Initial terms [1, 1]
Coefficients [1, 1]
m = 3
Initial terms [1, 0, 3, 0]
Coefficients [0, 4, 0, -1] # D(n+4) = 4D(n+2) - D(n)
m = 4
Initial terms [1, 1, 5, 11]
Coefficients [1, 5, 1, -1]
m = 5
Initial terms [1, 0, 8, 0, 95, 0, 1183, 0]
Coefficients [0, 15, 0, -32, 0, 15, 0, -1]
m = 6
Initial terms [1, 1, 13, 41, 281, 1183, 6728, 31529]
Coefficients [1, 20, 10, -38, -10, 20, -1, -1]
Possible approaches
There is at least one way to find the recurrence without brute forcing the tilings, outlined below:
- Compute the transition matrix \$A\$ of \$2^m\$ states, so that the target sequence is in the form of \$D_m(n) = u^T A^n v\$ for some column vectors \$u,v\$.
- Find the characteristic polynomial or minimal polynomial of \$A\$ as
$$x^k - a_{k-1}x^{k-1} - a_{k-2}x^{k-2} - \cdots - a_0 $$
- Then the corresponding recurrence relation is
$$s_{n+k} = a_{k-1}s_{n+k-1} + a_{k-2}s_{n+k-2} + \cdots + a_0s_n$$
An example algorithm of computing the minimal polynomial of a matrix can be found on this pdf.
(Of course, you can just brute force the domino tilings for small \$n\$ and plug into a recurrence finder.)