Donatella Merlini
Massimo Nocentini

October 27, 2016: fix fetching error, refactoring
October 20, 2016: some Riordan patterns


Abstract
A notebook to support an ongoing work Algebraic generating functions for languages avoiding Riordan patterns.

In [1]:
from sympy import *

from IPython.display import Markdown, Latex
from oeis import oeis_search

init_printing()

In [71]:
%run ~/Developer/working-copies/programming-contests/competitive-programming/python-libs/oeis.py

defs


In [39]:
j = symbols('j', positive=True)
t = symbols('t')

j_range = range(1, 10)

In [4]:
def make_expander(gf, t, terms_in_expansion = 15):
    
    def worker(j_index):
        term = Subs(gf, j, j_index)
        return Eq(j, j_index), Eq(term, term.doit().series(t, n=terms_in_expansion)) 

    return worker

def coeffs(res, t, limit):
    return [res.rhs.coeff(t, n) for n in range(limit)]

def match_table(results, gf_col_width="12cm"):
    rows = []
    for j_eq, res in results:
        j, j_index = j_eq.lhs, j_eq.rhs
        terms_in_expansion = res.rhs.getn()
        searchable = oeis_search(seq=coeffs(res, t, limit=terms_in_expansion), 
                                 only_possible_matchings=True, progress_indicator=None)
        row_src = searchable(term_src=latex(res.lhs))
        rows.append(row_src)

    header_row = r'<tr><th style="width:{width};" >gf</th><th>matches</th></tr>'.format(width=gf_col_width)
    return Markdown('<table style="width:100%">\n {header}\n {rows}\n </table>'.format(
            header=header_row, rows='\n'.join(rows)))

def coeffs_table(results):

    def coeffs_table_rows():

        rows = []
        for j_eq, res in results:
            j, j_index = j_eq.lhs, j_eq.rhs
            terms_in_expansion = res.rhs.getn()
            coefficients = coeffs(res, t, limit=terms_in_expansion)
            rows.append(latex(j_eq) + ' & ' + latex(coefficients))

        return rows
    
    return Latex(r'\begin{{array}}{{r|l}} {rows} \end{{array}}'.format(rows=r'\\'.join(coeffs_table_rows())))

testing


In [5]:
def fib(t):
    return t/(1-t-t**2)

In [6]:
f = fib(t)
f


Out[6]:
$$\frac{t}{- t^{2} - t + 1}$$

In [7]:
s = f.series(t, n=10)
s


Out[7]:
$$t + t^{2} + 2 t^{3} + 3 t^{4} + 5 t^{5} + 8 t^{6} + 13 t^{7} + 21 t^{8} + 34 t^{9} + \mathcal{O}\left(t^{10}\right)$$

In [8]:
s.getn()


Out[8]:
$$10$$

In [9]:
results = list(map(make_expander(fib(t), t), [1]))

In [10]:
results


Out[10]:
$$\left [ \left ( j = 1, \quad \left. \frac{t}{- t^{2} - t + 1} \right|_{\substack{ j=1 }} = t + t^{2} + 2 t^{3} + 3 t^{4} + 5 t^{5} + 8 t^{6} + 13 t^{7} + 21 t^{8} + 34 t^{9} + 55 t^{10} + 89 t^{11} + 144 t^{12} + 233 t^{13} + 377 t^{14} + \mathcal{O}\left(t^{15}\right)\right )\right ]$$

In [11]:
coeffs_table(results)


Out[11]:
\begin{array}{r|l} j = 1 & \left [ 0, \quad 1, \quad 1, \quad 2, \quad 3, \quad 5, \quad 8, \quad 13, \quad 21, \quad 34, \quad 55, \quad 89, \quad 144, \quad 233, \quad 377\right ] \end{array}

In [12]:
match_table(results)


Out[12]:
gfmatches
$$\left. \frac{t}{- t^{2} - t + 1} \right|_{\substack{ j=1 }}$$A000045, A212804, A147316, A248740, A025086, A039834, A152163, A236191

$\mathfrak{p}={1^{j+1}0^{j}}$


In [14]:
def S(t):
    radix_term = sqrt(1-4*t+4*t**(j+1))
    return 2/(radix_term * (1 + radix_term))

In [15]:
S(t)


Out[15]:
$$\frac{2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}}$$

In [16]:
results = list(map(make_expander(S(t), t), j_range))
# results

In [17]:
coeffs_table(results)


Out[17]:
\begin{array}{r|l} j = 1 & \left [ 1, \quad 3, \quad 7, \quad 15, \quad 31, \quad 63, \quad 127, \quad 255, \quad 511, \quad 1023, \quad 2047, \quad 4095, \quad 8191, \quad 16383, \quad 32767\right ]\\j = 2 & \left [ 1, \quad 3, \quad 10, \quad 32, \quad 106, \quad 357, \quad 1222, \quad 4230, \quad 14770, \quad 51918, \quad 183472, \quad 651191, \quad 2319626, \quad 8288135, \quad 29691760\right ]\\j = 3 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 123, \quad 442, \quad 1611, \quad 5931, \quad 22010, \quad 82187, \quad 308427, \quad 1162218, \quad 4394603, \quad 16665771, \quad 63361962\right ]\\j = 4 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 459, \quad 1696, \quad 6330, \quad 23806, \quad 90068, \quad 342430, \quad 1307138, \quad 5006576, \quad 19231518, \quad 74057340\right ]\\j = 5 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1713, \quad 6415, \quad 24205, \quad 91874, \quad 350406, \quad 1341782, \quad 5155265, \quad 19863925, \quad 76728114\right ]\\j = 6 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6432, \quad 24290, \quad 92273, \quad 352212, \quad 1349768, \quad 5190004, \quad 20013255, \quad 77364290\right ]\\j = 7 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6435, \quad 24307, \quad 92358, \quad 352611, \quad 1351574, \quad 5197990, \quad 20048004, \quad 77513715\right ]\\j = 8 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6435, \quad 24310, \quad 92375, \quad 352696, \quad 1351973, \quad 5199796, \quad 20055990, \quad 77548464\right ]\\j = 9 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6435, \quad 24310, \quad 92378, \quad 352713, \quad 1352058, \quad 5200195, \quad 20057796, \quad 77556450\right ] \end{array}

In [18]:
match_table(results)


Out[18]:
gfmatches
$$\left. \frac{2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=1 }}$$A000225, A126646, A168604, A255047, A239678, A060152, A225883
$$\left. \frac{2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=2 }}$$A261058
$$\left. \frac{2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=3 }}$$
$$\left. \frac{2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=4 }}$$
$$\left. \frac{2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=5 }}$$
$$\left. \frac{2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=6 }}$$
$$\left. \frac{2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=7 }}$$
$$\left. \frac{2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=8 }}$$
$$\left. \frac{2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=9 }}$$

$\mathfrak{p}={0^{j+1}1^{j}}$


In [19]:
def S(t):
    radix_term = sqrt(1-4*t+4*t**(j+1))
    return 2*(1-t**j)/(radix_term * (1 + radix_term))

In [20]:
S(t)


Out[20]:
$$\frac{- 2 t^{j} + 2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}}$$

In [21]:
results = list(map(make_expander(S(t), t), j_range))

In [22]:
coeffs_table(results)


Out[22]:
\begin{array}{r|l} j = 1 & \left [ 1, \quad 2, \quad 4, \quad 8, \quad 16, \quad 32, \quad 64, \quad 128, \quad 256, \quad 512, \quad 1024, \quad 2048, \quad 4096, \quad 8192, \quad 16384\right ]\\j = 2 & \left [ 1, \quad 3, \quad 9, \quad 29, \quad 96, \quad 325, \quad 1116, \quad 3873, \quad 13548, \quad 47688, \quad 168702, \quad 599273, \quad 2136154, \quad 7636944, \quad 27372134\right ]\\j = 3 & \left [ 1, \quad 3, \quad 10, \quad 34, \quad 120, \quad 432, \quad 1576, \quad 5808, \quad 21568, \quad 80576, \quad 302496, \quad 1140208, \quad 4312416, \quad 16357344, \quad 62199744\right ]\\j = 4 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 125, \quad 456, \quad 1686, \quad 6295, \quad 23680, \quad 89609, \quad 340734, \quad 1300808, \quad 4982770, \quad 19141450, \quad 73714910\right ]\\j = 5 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 461, \quad 1710, \quad 6405, \quad 24170, \quad 91748, \quad 349944, \quad 1340069, \quad 5148850, \quad 19839720, \quad 76636240\right ]\\j = 6 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1715, \quad 6429, \quad 24280, \quad 92238, \quad 352086, \quad 1349306, \quad 5188288, \quad 20006823, \quad 77340000\right ]\\j = 7 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6434, \quad 24304, \quad 92348, \quad 352576, \quad 1351448, \quad 5197528, \quad 20046288, \quad 77507280\right ]\\j = 8 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6435, \quad 24309, \quad 92372, \quad 352686, \quad 1351938, \quad 5199670, \quad 20055528, \quad 77546748\right ]\\j = 9 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6435, \quad 24310, \quad 92377, \quad 352710, \quad 1352048, \quad 5200160, \quad 20057670, \quad 77555988\right ] \end{array}

In [23]:
match_table(results)


Out[23]:
gfmatches
$$\left. \frac{- 2 t^{j} + 2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=1 }}$$A000079, A011782, A131577, A034008, A118655, A247208, A138882, A166444, A139248, A220493
$$\left. \frac{- 2 t^{j} + 2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=2 }}$$
$$\left. \frac{- 2 t^{j} + 2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=3 }}$$
$$\left. \frac{- 2 t^{j} + 2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=4 }}$$
$$\left. \frac{- 2 t^{j} + 2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=5 }}$$
$$\left. \frac{- 2 t^{j} + 2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=6 }}$$
$$\left. \frac{- 2 t^{j} + 2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=7 }}$$
$$\left. \frac{- 2 t^{j} + 2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=8 }}$$
$$\left. \frac{- 2 t^{j} + 2}{\left(\sqrt{- 4 t + 4 t^{j + 1} + 1} + 1\right) \sqrt{- 4 t + 4 t^{j + 1} + 1}} \right|_{\substack{ j=9 }}$$

$\mathfrak{p}={1^{j}0^{j}}$


In [24]:
def S(t):
    radix_term = sqrt(1-4*t+2*t**j+t**(2*j))
    return 2/(radix_term * (1 -t**j + radix_term))

In [25]:
S(t)


Out[25]:
$$\frac{2}{\left(- t^{j} + \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1} + 1\right) \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1}}$$

In [26]:
results = list(map(make_expander(S(t), t), j_range))

In [27]:
coeffs_table(results)


Out[27]:
\begin{array}{r|l} j = 1 & \left [ 1, \quad 2, \quad 3, \quad 4, \quad 5, \quad 6, \quad 7, \quad 8, \quad 9, \quad 10, \quad 11, \quad 12, \quad 13, \quad 14, \quad 15\right ]\\j = 2 & \left [ 1, \quad 3, \quad 9, \quad 27, \quad 82, \quad 253, \quad 791, \quad 2499, \quad 7960, \quad 25520, \quad 82248, \quad 266221, \quad 864818, \quad 2817963, \quad 9206339\right ]\\j = 3 & \left [ 1, \quad 3, \quad 10, \quad 34, \quad 118, \quad 417, \quad 1493, \quad 5400, \quad 19684, \quad 72196, \quad 266122, \quad 985003, \quad 3658441, \quad 13628032, \quad 50894650\right ]\\j = 4 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 125, \quad 454, \quad 1671, \quad 6211, \quad 23261, \quad 87641, \quad 331821, \quad 1261398, \quad 4811427, \quad 18405703, \quad 70585514\right ]\\j = 5 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 461, \quad 1708, \quad 6390, \quad 24086, \quad 91328, \quad 347965, \quad 1331072, \quad 5108906, \quad 19665318, \quad 75884110\right ]\\j = 6 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1715, \quad 6427, \quad 24265, \quad 92154, \quad 351666, \quad 1347326, \quad 5179280, \quad 19966795, \quad 77165064\right ]\\j = 7 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6434, \quad 24302, \quad 92333, \quad 352492, \quad 1351028, \quad 5195548, \quad 20037279, \quad 77467241\right ]\\j = 8 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6435, \quad 24309, \quad 92370, \quad 352671, \quad 1351854, \quad 5199250, \quad 20053548, \quad 77537739\right ]\\j = 9 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6435, \quad 24310, \quad 92377, \quad 352708, \quad 1352033, \quad 5200076, \quad 20057250, \quad 77554008\right ] \end{array}

In [28]:
match_table(results)


Out[28]:
gfmatches
$$\left. \frac{2}{\left(- t^{j} + \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1} + 1\right) \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1}} \right|_{\substack{ j=1 }}$$A000027, A001477, A028310, A067080, A038566, A053645, A194029, A023443, A053186, A271980
$$\left. \frac{2}{\left(- t^{j} + \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1} + 1\right) \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1}} \right|_{\substack{ j=2 }}$$
$$\left. \frac{2}{\left(- t^{j} + \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1} + 1\right) \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1}} \right|_{\substack{ j=3 }}$$
$$\left. \frac{2}{\left(- t^{j} + \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1} + 1\right) \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1}} \right|_{\substack{ j=4 }}$$
$$\left. \frac{2}{\left(- t^{j} + \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1} + 1\right) \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1}} \right|_{\substack{ j=5 }}$$
$$\left. \frac{2}{\left(- t^{j} + \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1} + 1\right) \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1}} \right|_{\substack{ j=6 }}$$
$$\left. \frac{2}{\left(- t^{j} + \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1} + 1\right) \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1}} \right|_{\substack{ j=7 }}$$
$$\left. \frac{2}{\left(- t^{j} + \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1} + 1\right) \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1}} \right|_{\substack{ j=8 }}$$
$$\left. \frac{2}{\left(- t^{j} + \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1} + 1\right) \sqrt{- 4 t + t^{2 j} + 2 t^{j} + 1}} \right|_{\substack{ j=9 }}$$

$\mathfrak{p}={(10)}^{j}1$


In [29]:
def S(t):
    radix_term = sqrt(1-4*t+2*t**(j+1)+4*t**(j+2)-3*t**(2*j+2))
    return 2*(1-t**j)/(1-4*t**j+3*t**(j+1)+radix_term)

In [30]:
S(t)


Out[30]:
$$\frac{- 2 t^{j} + 2}{- 4 t^{j} + 3 t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1}$$

In [31]:
results = list(map(make_expander(S(t), t), j_range))

In [32]:
coeffs_table(results)


Out[32]:
\begin{array}{r|l} j = 1 & \left [ 1, \quad 2, \quad 5, \quad 13, \quad 35, \quad 96, \quad 267, \quad 750, \quad 2123, \quad 6046, \quad 17303, \quad 49721, \quad 143365, \quad 414584, \quad 1201917\right ]\\j = 2 & \left [ 1, \quad 1, \quad 3, \quad 6, \quad 18, \quad 48, \quad 147, \quad 444, \quad 1407, \quad 4503, \quad 14718, \quad 48657, \quad 162831, \quad 549939, \quad 1872993\right ]\\j = 3 & \left [ 1, \quad 1, \quad 2, \quad 6, \quad 15, \quad 44, \quad 138, \quad 437, \quad 1433, \quad 4801, \quad 16330, \quad 56333, \quad 196547, \quad 692304, \quad 2458680\right ]\\j = 4 & \left [ 1, \quad 1, \quad 2, \quad 5, \quad 15, \quad 43, \quad 134, \quad 433, \quad 1438, \quad 4862, \quad 16723, \quad 58293, \quad 205478, \quad 731132, \quad 2622675\right ]\\j = 5 & \left [ 1, \quad 1, \quad 2, \quad 5, \quad 14, \quad 43, \quad 133, \quad 431, \quad 1434, \quad 4868, \quad 16796, \quad 58710, \quad 207511, \quad 740339, \quad 2662594\right ]\\j = 6 & \left [ 1, \quad 1, \quad 2, \quad 5, \quad 14, \quad 42, \quad 133, \quad 430, \quad 1432, \quad 4866, \quad 16802, \quad 58784, \quad 207936, \quad 742396, \quad 2671871\right ]\\j = 7 & \left [ 1, \quad 1, \quad 2, \quad 5, \quad 14, \quad 42, \quad 132, \quad 430, \quad 1431, \quad 4864, \quad 16800, \quad 58792, \quad 208010, \quad 742822, \quad 2673936\right ]\\j = 8 & \left [ 1, \quad 1, \quad 2, \quad 5, \quad 14, \quad 42, \quad 132, \quad 429, \quad 1431, \quad 4863, \quad 16798, \quad 58790, \quad 208018, \quad 742898, \quad 2674362\right ]\\j = 9 & \left [ 1, \quad 1, \quad 2, \quad 5, \quad 14, \quad 42, \quad 132, \quad 429, \quad 1430, \quad 4863, \quad 16797, \quad 58788, \quad 208016, \quad 742906, \quad 2674438\right ] \end{array}

In [33]:
match_table(results)


Out[33]:
gfmatches
$$\left. \frac{- 2 t^{j} + 2}{- 4 t^{j} + 3 t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1} \right|_{\substack{ j=1 }}$$A005773
$$\left. \frac{- 2 t^{j} + 2}{- 4 t^{j} + 3 t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1} \right|_{\substack{ j=2 }}$$
$$\left. \frac{- 2 t^{j} + 2}{- 4 t^{j} + 3 t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1} \right|_{\substack{ j=3 }}$$
$$\left. \frac{- 2 t^{j} + 2}{- 4 t^{j} + 3 t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1} \right|_{\substack{ j=4 }}$$
$$\left. \frac{- 2 t^{j} + 2}{- 4 t^{j} + 3 t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1} \right|_{\substack{ j=5 }}$$
$$\left. \frac{- 2 t^{j} + 2}{- 4 t^{j} + 3 t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1} \right|_{\substack{ j=6 }}$$
$$\left. \frac{- 2 t^{j} + 2}{- 4 t^{j} + 3 t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1} \right|_{\substack{ j=7 }}$$
$$\left. \frac{- 2 t^{j} + 2}{- 4 t^{j} + 3 t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1} \right|_{\substack{ j=8 }}$$
$$\left. \frac{- 2 t^{j} + 2}{- 4 t^{j} + 3 t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1} \right|_{\substack{ j=9 }}$$

$\mathfrak{p}={(01)}^{j}0$


In [34]:
def S(t):
    radix_term = sqrt(1-4*t+2*t**(j+1)+4*t**(j+2)-3*t**(2*j+2))
    return 2*(1-t**j-t**(j+1)+t**(2*j+1))/(radix_term * (1 -2*t**j +t**(j+1) + radix_term))

In [35]:
S(t)


Out[35]:
$$\frac{- 2 t^{j} - 2 t^{j + 1} + 2 t^{2 j + 1} + 2}{\left(- 2 t^{j} + t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1\right) \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1}}$$

In [36]:
results = list(map(make_expander(S(t), t), j_range))

In [37]:
coeffs_table(results)


Out[37]:
\begin{array}{r|l} j = 1 & \left [ 1, \quad 3, \quad 8, \quad 22, \quad 61, \quad 171, \quad 483, \quad 1373, \quad 3923, \quad 11257, \quad 32418, \quad 93644, \quad 271219, \quad 787333, \quad 2290200\right ]\\j = 2 & \left [ 1, \quad 3, \quad 10, \quad 33, \quad 113, \quad 393, \quad 1384, \quad 4920, \quad 17618, \quad 63456, \quad 229642, \quad 834342, \quad 3041474, \quad 11118903, \quad 40748389\right ]\\j = 3 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 124, \quad 449, \quad 1647, \quad 6099, \quad 22754, \quad 85394, \quad 322022, \quad 1219205, \quad 4631572, \quad 17645242, \quad 67391439\right ]\\j = 4 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 460, \quad 1703, \quad 6366, \quad 23974, \quad 90818, \quad 345691, \quad 1321092, \quad 5065645, \quad 19479631, \quad 75093420\right ]\\j = 5 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1714, \quad 6422, \quad 24241, \quad 92042, \quad 351156, \quad 1345049, \quad 5169273, \quad 19923353, \quad 76978309\right ]\\j = 6 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6433, \quad 24297, \quad 92309, \quad 352380, \quad 1350518, \quad 5193271, \quad 20027269, \quad 77423772\right ]\\j = 7 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6435, \quad 24308, \quad 92365, \quad 352647, \quad 1351742, \quad 5198740, \quad 20051271, \quad 77527729\right ]\\j = 8 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6435, \quad 24310, \quad 92376, \quad 352703, \quad 1352009, \quad 5199964, \quad 20056740, \quad 77551731\right ]\\j = 9 & \left [ 1, \quad 3, \quad 10, \quad 35, \quad 126, \quad 462, \quad 1716, \quad 6435, \quad 24310, \quad 92378, \quad 352714, \quad 1352065, \quad 5200231, \quad 20057964, \quad 77557200\right ] \end{array}

In [38]:
match_table(results, gf_col_width="18cm")


Out[38]:
gfmatches
$$\left. \frac{- 2 t^{j} - 2 t^{j + 1} + 2 t^{2 j + 1} + 2}{\left(- 2 t^{j} + t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1\right) \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1}} \right|_{\substack{ j=1 }}$$A025566
$$\left. \frac{- 2 t^{j} - 2 t^{j + 1} + 2 t^{2 j + 1} + 2}{\left(- 2 t^{j} + t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1\right) \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1}} \right|_{\substack{ j=2 }}$$
$$\left. \frac{- 2 t^{j} - 2 t^{j + 1} + 2 t^{2 j + 1} + 2}{\left(- 2 t^{j} + t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1\right) \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1}} \right|_{\substack{ j=3 }}$$
$$\left. \frac{- 2 t^{j} - 2 t^{j + 1} + 2 t^{2 j + 1} + 2}{\left(- 2 t^{j} + t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1\right) \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1}} \right|_{\substack{ j=4 }}$$
$$\left. \frac{- 2 t^{j} - 2 t^{j + 1} + 2 t^{2 j + 1} + 2}{\left(- 2 t^{j} + t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1\right) \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1}} \right|_{\substack{ j=5 }}$$
$$\left. \frac{- 2 t^{j} - 2 t^{j + 1} + 2 t^{2 j + 1} + 2}{\left(- 2 t^{j} + t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1\right) \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1}} \right|_{\substack{ j=6 }}$$
$$\left. \frac{- 2 t^{j} - 2 t^{j + 1} + 2 t^{2 j + 1} + 2}{\left(- 2 t^{j} + t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1\right) \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1}} \right|_{\substack{ j=7 }}$$
$$\left. \frac{- 2 t^{j} - 2 t^{j + 1} + 2 t^{2 j + 1} + 2}{\left(- 2 t^{j} + t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1\right) \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1}} \right|_{\substack{ j=8 }}$$
$$\left. \frac{- 2 t^{j} - 2 t^{j + 1} + 2 t^{2 j + 1} + 2}{\left(- 2 t^{j} + t^{j + 1} + \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1} + 1\right) \sqrt{- 4 t + 2 t^{j + 1} + 4 t^{j + 2} - 3 t^{2 j + 2} + 1}} \right|_{\substack{ j=9 }}$$