############From GuessRat #GenPol(Resh,a,deg): Given a list of variables Resh, a symbol a, #and a non-negative integer deg, outputs a generic polynomial #of total degree deg,in the variables Resh, indexed by the letter a of #followed by the set of coeffs. For example, try: #GenPol([x,y],a,1); GenPol:=proc(Resh,a,deg) local var,POL1,i,x,Resh1,POL: if not type(Resh,list) or nops(Resh)=0 then ERROR(`Bad Input`): fi: x:=Resh[1]: if nops(Resh)=1 then RETURN(convert([seq(a[i]*x^i,i=0..deg)],`+`),{seq(a[i],i=0..deg)}): fi: Resh1:=[op(2..nops(Resh),Resh)]: var:={}: POL:=0: for i from 0 to deg do POL1:=GenPol(Resh1,a[i],deg-i): var:=var union POL1[2]: POL:=expand(POL+POL1[1]*x^i): od: POL,var: end: #GenRat(Resh,a,b,degT,degB): The generic form of a rational function #in the list of variables Resh indexed by a on top and b at bottom #of total degree degT on top and degB at bottom #for example, try: GenRat([x,y],a,b,1,2) GenRat:=proc(Resh,a,b,degT,degB) local TOP,BOT: TOP:=GenPol(Resh,a,degT): BOT:=GenPol(Resh,b,degB): TOP[1]/BOT[1],TOP[2] union BOT[2]: end: #GuessRat1(F,Resh,degT,degB): Given a set of pairs [vect,value] #and a symbolic lis Resh, nops(Resh) arguments (that are integers), guesses a rational function #with total degree degT and degB for numerator and denominator respectively #that seems fits it GuessRat1:=proc(F,Resh,degT,degB) local eq,var,Rat,a,b,i1,j1,k: k:=nops(Resh): Rat:=GenRat(Resh,a,b,degT,degB): var:=Rat[2]: Rat:=Rat[1]: eq:= {seq( numer(normal(F[i1][2]-subs({seq(Resh[j1]=F[i1][1][j1],j1=1..k)},Rat))), i1=1..nops(F))}: eq:=eq minus {0}: if nops(eq)FAIL then RETURN(factor(lu)): fi: od: FAIL: end: