#WZcoh.txt Help:=proc(): print(`findKernel(F,G,n,k), `): print(`findPolyWZPairP(K, n, k, Pdeg, Qdeg,a,b)`): end: # findKernel(F, G, n, k): Find a closed-form kernel for the WZ-pair (F, G) in n # and k. That is, find a closed form K such that F = K * P and G = K * Q for # polynomials P and Q. # Try: # findKernel(WZchu(n, k, 0, 0, 0, n), n, k); findKernel:=proc(F, G, n, k) local ratio, Q: ratio := simplify(F / G): if not type(ratio, ratpoly(anything, {n, k})) then return FAIL: fi: Q := denom(ratio): G / Q: end: # genPoly(n, k, a, deg): Return a generic polynomial in n and k of degree `deg` # using a[i, j] as symbolic coefficients. # Try: # genPoly(n, k, a, 5); genPoly:=proc(n, k, a, deg) add(add(a[i, j] * n^i * k^j, i=0..deg-j), j=0..deg), {seq(seq(a[i, j] , i=0..deg-j), j=0..deg)}: end: # findPolyWZPair(K, n, k, Pdeg, Qdeg): Given a closed form K in n and k, use # undetermined coefficients to find polynomials P and Q of degree <= Pdeg and # Qdeg, respectively, such that (K P, K Q) is a WZ-pair. # Try: # findPolyWZPair(n * k, n, k, 1, 1); # K := findKernel(WZchu(n, k, 0, 0, 0, n), n, k): # findPolyWZPair(K, n, k, 1, 1); # findPolyWZPair(K, n, k, 3, 3); findPolyWZPair:=proc(K, n, k, Pdeg, Qdeg) local nRat, kRat, P, Q, left, right, expr, eqns, soln, freeVars, freeAssign: nRat := simplify(subs(n = n + 1, K) / K): kRat := simplify(subs(k = k + 1, K) / K): P := genPoly(n, k, a, Pdeg): Q := genPoly(n, k, b, Qdeg): left := denom(kRat) * (numer(nRat) * subs(n = n + 1, P) - denom(nRat) * P): right := denom(nRat) * (numer(kRat) * subs(k = k + 1, Q) - denom(kRat) * Q): expr := expand(left - right): eqns := [seq(seq(coeff(coeff(expr, k, j), n, i), j=0..degree(expr, k)), i=0..degree(expr, n))]: soln := solve(eqns): freeVars := select(e -> lhs(e) = rhs(e), soln): freeAssign := map(e -> lhs(e) = 1, freeVars): soln := subs(freeAssign, soln) union freeAssign: subs(soln, [P, Q]): end: # checkWZPair(F, G, n, k): Check that (F, G) is a WZ-pair in n and k. checkWZPair:=proc(F, G, n, k) local d: d := subs(n = n + 1, F) - F - (subs(k = k + 1, G) - G): evalb(simplify(d) = 0): end: # findPolyWZPairP(K, n, k, Pdeg, Qdeg,a,b): Given a closed form K in n and k, use # undetermined coefficients to find polynomials P and Q of degree <= Pdeg and # Qdeg, respectively, such that (K P, K Q) is a WZ-pair. # Try: # findPolyWZPair(n * k, n, k, 1, 1); # K := findKernel(WZchu(n, k, 0, 0, 0, n), n, k): # findPolyWZPair(K, n, k, 1, 1); # findPolyWZPair(K, n, k, 3, 3); findPolyWZPairP:=proc(K, n, k, Pdeg, Qdeg,a,b) local nRat, kRat, P, Q, left, right, expr, eqns, soln, var,freeVars, freeAssign,var1,var11, soln1,MID,BAS: nRat := simplify(subs(n = n + 1, K) / K): kRat := simplify(subs(k = k + 1, K) / K): P := genPoly(n, k, a, Pdeg): Q := genPoly(n, k, b, Qdeg): var:=P[2] union Q[2]: P:=P[1]: Q:=Q[1]: left := denom(kRat) * (numer(nRat) * subs(n = n + 1, P) - denom(nRat) * P): right := denom(nRat) * (numer(kRat) * subs(k = k + 1, Q) - denom(kRat) * Q): expr := expand(left - right): eqns := [seq(seq(coeff(coeff(expr, k, j), n, i), j=0..degree(expr, k)), i=0..degree(expr, n))]: soln := solve(eqns): var1:={}: for soln1 in soln do if op(1,soln1)=op(2,soln1) then var1:=var1 union {op(1,soln1)}: fi: od: #freeVars := select(e -> lhs(e) = rhs(e), soln): #freeAssign := map(e -> lhs(e) = 1, freeVars): #soln := subs(freeAssign, soln) union freeAssign: MID:=subs(soln, [P, Q]): BAS:={}: for var11 in var1 do BAS:=BAS union {[coeff(MID[1],var11,1),coeff(MID[2],var11,1)]}: od: BAS: end: # checkWZPair(F, G, n, k): Check that (F, G) is a WZ-pair in n and k. checkWZPair:=proc(F, G, n, k) local d: d := subs(n = n + 1, F) - F - (subs(k = k + 1, G) - G): evalb(simplify(d) = 0): end: