Help:=proc(): print(` GuessAlg(L,P,x,MaxDegP) `): print( ` GuessAlg1(L,P,x,DegP) , GuessAlg11(L,P,x,DegP,Degx) `): end: #C10.txt: starting the Alg. Formal Power Series #1+1!*x+2!*x^2+3!*x^3+ ...... #GuessAlg(L,P,x,MaxDegP): Inputs a sequence of numbers L #and tries to guess an alg. eq. of the from #F(P,x)=0. where P is the symbol for the generating #function of L, P(x)=add(L[i+1]*x^i,i=0..infinity) #of max. degree MaxDegP GuessAlg:=proc(L,P,x, MaxDegP) local g,DegP: for DegP from 1 to MaxDegP do g:=GuessAlg1(L,P,x,DegP): if g<>FAIL then RETURN(g): fi: od: FAIL: end: #GuessAlg1(L,P,x,DegP): Inputs a sequence of numbers L #and tries to guess an alg. eq. of the from #F(P,x)=0. where P is the symbol for the generating #function of L, P(x)=add(L[i+1]*x^i,i=0..infinity) #of degree DegP in P GuessAlg1:=proc(L,P,x, DegP) local g,Degx: for Degx from 0 while (1+Degx)*(1+DegP)FAIL then RETURN(g): fi: od: FAIL: end: #GuessAlg11(L,P,x,DegP, Degx): Inputs a sequence of numbers L #and tries to guess an alg. eq. of the from #F(P,x)=0. where P is the symbol for the generating #function of L, P(x)=add(L[i+1]*x^i,i=0..infinity) #of degree DegP in P and Degx in x GuessAlg11:=proc(L,P,x, DegP, Degx) local g, F,a, i,j, var,P1,F1,eq, var1,v: F:=add(add(a[i,j]*x^i*P^j,i=0..Degx),j=0..DegP): var:={seq(seq(a[i,j],i=0..Degx),j=0..DegP)}: P1:=add(L[i]*x^(i-1),i=1..nops(L)): F1:=expand(subs(P=P1,F)): eq:={seq( coeff(F1,x,i)=0, i=0..nops(L)-1)}: var1:=solve(eq,var): F:=subs(var1,F): if F=0 then RETURN(FAIL): else F:=subs({seq(v=1, v in var)},F): F:=add(factor(coeff(F,P,i))*P^i,i=0..degree(F,P)): RETURN(F): fi: end: