Help:=proc(): print(`GuessPol(L,n), GuessRat(L,n)`):end: #============================================================ #GuessPol1(L,d,n): guesses a polynomial of degree d in n for # the list L, such that L[i]=P[i] for i>=s0 for example, try: #GuessPol1([(seq(i,i=1..10),1,n,1); GuessPol1:=proc(L,d,n) local P,i,a,eq,var: if d>=nops(L)-3 then ERROR(`the list is too small`): fi: P:=add(a[i]*n^i,i=0..d): var:={seq(a[i],i=0..d)}: eq:={seq(subs(n=i,P)-L[i],i=1..d+4)}: var:=solve(eq,var): if var=NULL then RETURN(FAIL): fi: subs(var,P): end: #============================================================ #GuessPol(L,n): guesses a polynomial of degree d in n for # the list L, such that L[i]=P[i] for i>=1 for example, try: #GuessPol([(seq(i,i=1..10),n); GuessPol:=proc(L,n) local d,gu: for d from 0 to nops(L)-4 do gu:=GuessPol1(L,d,n): if gu<>FAIL then RETURN(gu): fi: od: FAIL: end: ################# GuessRat := proc(L,x) local d,PoQ; for d from 1 to (nops(L)-5)/2 do PoQ := GuessRat1(L,x,d); if not PoQ = FAIL then RETURN(PoQ); fi; od; RETURN(FAIL); end: #============================================================ #Recall that a rational function f(x) is a quotient of #polynomials f(x)=P(x)/Q(x). Write a program GuessRat1(L,x,d) #that inputs a list L, a variable x, and a non.neg. #integer d such that 2*d+5 <= nops(L), and outputs a #rational function P(x)/Q(x) with degree(P,x), #degree(Q,x) <= d, such that P(i)/Q(i)=L[i] for all #i from 1 to nops(L), if one exist, and FAIL otherwise. GuessRat1 := proc(L,x,d) local P,Q,var,eq,i,Ans,a,b,j; if 2*d+5>nops(L) then print(`List not big enough`); RETURN(FAIL); fi; P := add(a[i]*x^i, i=0..d); Q := add(b[i]*x^i, i=0..d); var := {seq(a[i], i=0..d),seq(b[j], j=0..d)}; eq := {}; for i from 1 to nops(L) do if not subs(x=i,Q)=0 then eq := eq union {subs(x=i,P/Q)-L[i]}; else print(`denominator equals 0 for i=`,i); RETURN(FAIL); fi; od; Ans := solve(eq,var); if Ans=NULL then RETURN(FAIL); fi; RETURN(factor(subs(Ans,P/Q))); end: