%I #43 May 24 2022 02:46:09
%S 0,1,1,2,3,4,3,7,10,9,4,13,24,29,16,5,21,50,77,74,25,6,31,92,177,228,
%T 173,36,7,43,154,361,582,629,382,49,8,57,240,669,1304,1793,1640,813,
%U 64,9,73,354,1149,2642,4401,5226,4093,1690,81,10,91,500,1857,4940,9685,14028,14545,9876,3461,100
%N A triangle formed like generalized Pascal's triangle. The rule is T(n,k) = 2*T(n-1,k-1) + T(n-1,k), the left border is n and the right border is n^2 instead of 1.
%H Boris Putievskiy, <a href="/A228576/b228576.txt">Rows n = 1..140 of triangle, flattened</a>
%H Rely Pellicer, David Alvo, <a href="http://www.academia.edu/956605/Modified_Pascal_Triangle_and_Pascal_Surfaces">Modified Pascal Triangle and Pascal Surfaces</a> p.4
%H Boris Putievskiy, <a href="http://arxiv.org/abs/1212.2732">Transformations [of] Integer Sequences And Pairing Functions</a> arXiv:1212.2732 [math.CO], 2012.
%H Rattanapol Wasutharat and Kantaphon Kuhapatanakul, <a href="http://www.m-hikari.com/ijcms/ijcms-2012/41-44-2012/wasutharatIJCMS41-44-2012.pdf">The Generalized Pascal-Like Triangle and Applications</a> Int. J. Contemp. Math. Sciences, Vol. 7, 2012, no. 41, pp. 1989 - 1992
%H <a href="/index/Pas#Pascal">Index entries for triangles and arrays related to Pascal's triangle</a>
%F T(n, k) = 2*T(n-1, k-1) + T(n-1, k) for n,k >=0, with T(n,0) = n, T(n,n) = n^2.
%F Closed-form formula for generalized Pascal's triangle. Let a,b be any numbers. The rule is T(n, k) = a*T(n-1, k-1) + b*T(n-1, k) for n,k >0. Let L(m) and R(m) be the left border and the right border generalized Pascal's triangle, respectively.
%F As table read by antidiagonals T(n,k) = Sum_{m1=1..n} a^(n-m1) * b^k*R(m1)*C(n+k-m1-1,n-m1) + Sum_{m2=1..k} a^n*b^(k-m2)*L(m2)*C(n+k-m2-1,k-m2); n,k >=0.
%F As linear sequence a(n) = Sum_{m1=1..i} a^(i-m1)*b^j*R(m1)*C(i+j-m1-1,i-m1) + Sum_{m2=1..j} a^i*b^(j-m2)*L(m2)*C(i+j-m2-1,j-m2), where i=n-t*(t+1)/2-1, j=(t*t+3*t+4)/2-n-1, t=floor((-1+sqrt(8*n-7))/2); n>0.
%F Some special cases. If a=b=1, then the closed-form formula for arbitrary left and right borders of Pascal like triangle see A228196.
%F If a=0, then as table read by antidiagonals T(n,k)=b*R(n), as linear sequence a(n)=b*R(i), where i=n-t*(t+1)/2-1, t=floor((-1+sqrt(8*n-7))/2); n>0. The sequence a(n) is the reluctant sequence of sequence b*R(n) - a(n) is triangle array read by rows: row number k coincides with first k elements of the sequence b*R(n). Similarly for b=0, we get T(n,k)=a*L(k).
%F For this sequence L(m)=m and R(m)=m^2, a=2, b=1. As table read by antidiagonals T(n,k) = Sum_{m1=1..n} 2^(n-m1)*m1^2*C(n+k-m1-1,n-m1) + Sum_{m2=1..k} 2^n*m2*C(n+k-m2-1,k-m2); n,k >=0.
%F As linear sequence a(n) = Sum_{m1=1..i} 2^(i-m1)*m1^2*C(i+j-m1-1, i-m1) + Sum_{m2=1..j} 2^i*m2*C(i+j-m2-1,j-m2), where i=n-t*(t+1)/2-1, j=(t*t+3*t+4)/2-n-1, t=floor((-1+sqrt(8*n-7))/2); n>0.
%e The start of the sequence as triangle array read by rows:
%e 0;
%e 1, 1;
%e 2, 3, 4;
%e 3, 7, 10, 9;
%e 4, 13, 24, 29, 16;
%e 5, 21, 50, 77, 74, 25;
%e ...
%p T := proc(n, k) option remember;
%p if k = 0 then RETURN(n) fi;
%p if k = n then RETURN(n^2) fi;
%p 2*T(n-1, k-1) + T(n-1, k) end:
%p seq(seq(T(n,k),k=0..n),n=0..9); # _Peter Luschny_, Aug 26 2013
%t T[n_, 0]:= n; T[n_, n_]:= n^2; T[n_, k_]:= T[n, k] = 2*T[n-1, k-1]+T[n-1, k]; Table[T[n, k], {n, 0, 10}, {k, 0, n}] // Flatten (* _Jean-François Alcover_, Feb 25 2014 *)
%o (PARI) T(n,k) = if(k==0, n, if(k==n, n^2, 2*T(n-1, k-1) + T(n-1, k) )); \\ _G. C. Greubel_, Nov 13 2019
%o (Magma)
%o function T(n,k)
%o if k eq 0 then return n;
%o elif k eq n then return n^2;
%o else return 2*T(n-1,k-1) + T(n-1,k);
%o end if;
%o return T;
%o end function;
%o [T(n,k): k in [0..n], n in [0..12]]; // _G. C. Greubel_, Nov 13 2019
%o (Sage)
%o @CachedFunction
%o def T(n, k):
%o if (k==0): return n
%o elif (k==n): return n^2
%o else: return 2*T(n-1,k-1) + T(n-1, k)
%o [[T(n, k) for k in (0..n)] for n in (0..12)] # _G. C. Greubel_, Nov 13 2019
%o (GAP)
%o T:= function(n,k)
%o if k=0 then return n;
%o elif k=n then return n^2;
%o else return 2*T(n-1,k-1) + T(n-1,k);
%o fi;
%o end;
%o Flat(List([0..12], n-> List([0..n], k-> T(n,k) ))); # _G. C. Greubel_, Nov 13 2019
%Y Cf. We denote generalized Pascal's like triangle with coefficients a, b and with L(n) on the left border and R(n) on the right border by (a,b,L(n),R(n)). The list of sequences for (1,1,L(n),R(n)) see A228196;
%Y A038207 (1,2,2^n,1), A105728 (1, 2, 1, n+1), A112468 (1,-1,1,1), A112626 (1,2,3^n,1), A119258 (2,1,1,1), A119673 (3,1,1,1), A119725 (3,2,1,1), A119726 (4,2,1,1), A119727 (5,2,1,1), A209705 (2,1,n+1,0);
%Y A002061 (column 2), A000244 (sums of rows r of triangle array - (r-2)(r+1)/2).
%K nonn,tabl
%O 1,4
%A _Boris Putievskiy_, Aug 26 2013