login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Number of symmetrically unique Dyck paths of semilength 2n and height n.
2

%I #21 Apr 26 2021 08:01:20

%S 1,1,5,31,252,2117,18546,164229,1469596,13229876,119712521,1087573357,

%T 9914033252,90633332870,830621140260,7628813061585,70200092854044,

%U 647070588612140,5973385906039684,55217660246861884,511054426374819184,4735208302827742549

%N Number of symmetrically unique Dyck paths of semilength 2n and height n.

%H Alois P. Heinz, <a href="/A291885/b291885.txt">Table of n, a(n) for n = 0..1026</a>

%F a(n) = A291883(2n,n).

%p b:= proc(x, y, k) option remember; `if`(x=0, 1, `if`(y+1<=min(k,

%p x-1), b(x-1, y+1, k), 0)+`if`(y>0, b(x-1, y-1, k), 0))

%p end:

%p g:= proc(x, y, k) option remember; `if`(x=0, 1, `if`(y>0,

%p g(x-2, y-1, k), 0)+ `if`(y+1<=k, g(x-2, y+1, k), 0))

%p end:

%p a:= n-> `if`(n=0, 1, (b(4*n, 0, n) +g(4*n, 0, n)

%p -b(4*n, 0, n-1)-g(4*n, 0, n-1))/2):

%p seq(a(n), n=0..30);

%t b[x_, y_, k_] := b[x, y, k] = If[x == 0, 1, If[y + 1 <= Min[k, x - 1], b[x - 1, y + 1, k], 0] + If[y > 0, b[x - 1, y - 1, k], 0]];

%t g[x_, y_, k_] := g[x, y, k] = If[x == 0, 1, If[y > 0, g[x - 2, y - 1, k], 0] + If[y + 1 <= k, g[x - 2, y + 1, k], 0]];

%t a[n_] := If[n == 0, 1, (b[4n, 0, n] + g[4n, 0, n] - b[4n, 0, n - 1] - g[4n, 0, n - 1])/2];

%t Array[a, 30, 0] (* _Jean-François Alcover_, May 31 2019, after _Alois P. Heinz_ *)

%o (Python)

%o from sympy.core.cache import cacheit

%o @cacheit

%o def b(x, y, k): return 1 if x==0 else (b(x - 1, y + 1, k) if y + 1<=min(k, x - 1) else 0) + (b(x - 1, y - 1, k) if y>0 else 0)

%o @cacheit

%o def g(x, y, k): return 1 if x==0 else (g(x - 2, y - 1, k) if y>0 else 0) + (g(x - 2, y + 1, k) if y + 1<=k else 0)

%o def a(n): return 1 if n==0 else (b(4*n, 0, n) + g(4*n, 0, n) - b(4*n, 0, n - 1) - g(4*n, 0, n - 1))//2

%o print([a(n) for n in range(31)]) # _Indranil Ghosh_, Sep 06 2017

%Y Cf. A291883.

%K nonn

%O 0,3

%A _Alois P. Heinz_, Sep 05 2017