Re: A=B example
- To: mathgroup at smc.vnet.net
- Subject: [mg32131] Re: [mg32120] A=B example
- From: BobHanlon at aol.com
- Date: Sat, 29 Dec 2001 00:46:51 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 12/28/01 3:51:58 AM, erich.neuwirth at univie.ac.at writes: >this has probably been asked before. >being new to the list i would be happy with a pointer to previous >answers. > > >in A=B by Wilf and Zeilberger, >on page 61 there is the following program for deriving recursions >explicitly >(i had to change FactorialSimplify to FullSimplify >because the original version was for mathematica 2.2): > > >findrecur[f_, ii_, jj_] := > Module[{yy, zz, ll, tt, uu, r, s, i, j}, > yy = Sum[ > Sum[a[i, j] *FullSimplify[f[n - j, k - i]/f[n, k]], {i, 0, ii}], >{j, > 0, jj}]; > zz = Collect[Numerator[Together[yy]], k]; > ll = CoefficientList[zz, k]; > tt = Flatten[Table[a[i, j], {i, 0, ii}, {j, 0, jj}]]; > uu = Flatten[Simplify[Solve[ll == 0, tt]]]; > For[r = 0, r <= ii, r++, > For[s = 0, s <= jj, s++, > a[r, s] = Replace[a[r, s], uu]]]; > Sum[Sum[a[i, j] F[n - j, k - i], {i, 0, ii}], {j, 0, jj}] == 0] > >defining >f[n_, k_] := n!/(n - k)! > >and executing >findrecur[f,1,1] >works, >but trying to run exactly the same statement a second time >produces a lot of errors and effectively hangs mathematica. > >is there a solution? Inside the definition of findrecur you use a[]. a is defined globally and retains its values from the first call. Try findrecur[f_,ii_,jj_, a_Symbol:a]:= Module[{yy,zz,ll,tt,uu,r,s,i,j}, Clear[a]; yy= ... ]; Bob Hanlon Chantilly, VA USA