HelpL:=proc() print(`PolF1(Li,a,d,x)`): print(`PolF2(Li,a,d1,d2,x)`): print(`PolF(Li,a,x)`): print(`PolF3(Li,a,x)`): print(`GuessHG(R,j)`): end: #PolF1(Li,a,d,x): tries to fit a polynomial f(x) #of degree d in x, such that f(a)=Li[1], #f(a+1)=Li[2],...f(a+nops(Li)-1)=Li[nops(Li)] #and FAIL otherwise PolF1:=proc(Li,a,d,x) local f,c,i,var,eq, sol: f:=add(c[i]*x^i,i=0..d): var:={seq(c[i],i=0..d)}: eq:={seq(subs(x=a+i-1,f)=Li[i],i=1..nops(Li))}: sol:=solve(eq,var): if sol=NULL then print(`Sorry, there is no polynomial of degree`, d): RETURN(FAIL): fi: subs(sol,f): end: #PolF2(Li,a,d1,d2,x): tries to fit a rational function #f(x) = P(x)/Q(x) with deg P(x) = d1, deg Q(x)= d2, #in x, such that f(a)=Li[1], #f(a+1)=Li[2],...f(a+nops(Li)-1)=Li[nops(Li)] #and FAIL otherwise PolF2:=proc(Li,a,d1,d2,x) local f,g,c1,c2,i,var,eq, sol: f:=add(c1[i]*x^i,i=0..d1): g:=add(c2[i]*x^i,i=0..d2): var:={seq(c1[i],i=0..d1),seq(c2[i],i=0..d2)}: eq:={seq(subs(x=a+i-1,f)/subs(x=a+i-1,g)=Li[i],i=1..nops(Li))}: sol:=solve(eq,var): if sol=NULL then #print(`Sorry, there is no rational function f=P(x)/Q(x) with deg P =`, d1, `deg Q =`, d2): RETURN(FAIL): fi: normal(subs(sol,f)/subs(sol,g)): end: #determines the lowest degree polynomial that PolF1 doesn't return FAIL #and returns the desired polynomial PolF:=proc(Li,a,x) local d,f: for d from 0 to nops(Li)-4 do f:=PolF1(Li,a,d,x): if f<>FAIL then RETURN(f): fi: od: FAIL: end: #determines the lowest degree polynomial that PolF2 doesn't return FAIL #and returns the desired rational function Rat:=proc(Li,a,x) local d1,d2,f: for d1 from 0 to nops(Li)-3 do for d2 from 1 to nops(Li)-3-d1 do f:=PolF2(Li,a,d1,d2,x): if f<>FAIL then RETURN(f): fi: od: od: FAIL: end: #GuessHG: inputs a rational function R, and outputs the #hypergeometric expression such that a(0)=1 GuessHG:=proc(R,j) local a: rsolve( { a(j)=R*a(j-1), a(0)=1}, a(j)): end: