#C11.txt: Feb. 28, 2019, Math640(RU), Dr. Z. Help:=proc(): print(` GuessAlg(L,F,x) , Iter(INI,Q,x,F,f,N), AlgToSeq(INI,Q,x,F,N), Trunc(f,x,N) `): print(`MakeNice(P,x,F) `): end: ###From C10.txt #GuessAlg1(L,F,x,d): inputs a list of numbers L (starting at n=0) #symbols F and x and a pos. number d, outputs a polynomial P, in F and x #of degree d such that P(x,Sum(L[i+1]*x^i,i=0..nops(L)-1) had degree nops(L) #improved after class to get rid of annoying factors GuessAlg1:=proc(L,F,x,d) local P,i,j,a,eq,var,f,tem,c: P:=add(add(a[i,j]*x^i*F^j, j=0..d-i), i=0..d): f:=add(L[i+1]*x^i,i=0..nops(L)-1): var:={seq(seq(a[i,j],j=0..d-i),i=0..d)}: #nops(var)=(d+1)*(d+2)/2 if nops(L)<=(d+1)*(d+2)/2+3 then print(`Make the list bigger`): RETURN(FAIL): fi: tem:=subs(F=f,P): eq:={seq(coeff(tem,x,i)=0,i=0..nops(L)-1)}: var:=solve(eq,var): P:=subs(var,P): if P=0 then RETURN(FAIL): else P:=normal(P): c:=lcoeff(lcoeff(P,F),x): P:=normal(P/c): fi: end: #GuessAlg(L,F,x): inputs a list of numbers L (starting at n=0) #symbols F and x and a pos. number d, outputs a polynomial P, in F and x #of degree d such that P(x,Sum(L[i+1]*x^i,i=0..nops(L)-1) had degree nops(L) GuessAlg:=proc(L,F,x) local P,d: for d from 1 while nops(L)>=(d+1)*(d+2)/2+3 do P:=GuessAlg1(L,F,x,d): if P<>FAIL then RETURN(P): fi: od: FAIL: end: #####end from C10.txt #Trunc(f,x,N): inputs a polynomial f in x and a pos. integer N, outputs the truncation up to x^N Trunc:=proc(f,x,N) local i: add( coeff(f,x,i)*x^i,i=0..N): end: #Iter(INI,Q,x,F,f,N): Inputs a poly INI in x alone and a poly Q(F,x) of F and x #and a pos. integer N, and a current candidate for the solution of #f(x)=INI(x)+Q(f(x),x) and truncates it up x^N #outputs one step of f(x)->INI(x)+Q(f(x),x) Iter:=proc(INI,Q,x,F,f,N) local tem: if (coeff(INI,x,0)<>0 and subs(x=0,Q)<>0 and degree(Q,F)<=degree(INI,x) ) then print(`bad input`): RETURN(FAIL): fi: Trunc(INI+subs(F=f,Q),x,N): end: #AlgToSeq(INI,Q,x,F,N): #Inputs a poly INI in x alone and a poly Q(F,x) of F and x #and a pos. integer N, output the N+1 coefficients of the unique f.p.s. solution of #f(x)=INI(x)+Q(f(x),x) F-INI(x)-Q(F,x)=0 AlgToSeq:=proc(INI,Q,x,F,N) local f,f1,i,f2: if (coeff(INI,x,0)<>0 and subs(x=0,Q)<>0 and degree(Q,F)<=degree(INI,x) ) then print(`bad input`): RETURN(FAIL): fi: f:=0: while f<>Iter(INI,Q,x,F,f,N) do f:=Iter(INI,Q,x,F,f,N): od: [seq(coeff(f,x,i),i=0..N)]; end: #MakeNice(P,x,F): converts the equation P(x,F)=0 to the equivalent form #F-INI(x)-Q(F,x)=P(F,x). Returns [INI,Q] #corrected after class MakeNice:=proc(P,x,F) local P1,INI,c,Q: c:=coeff(coeff(P,x,0),F,1): if c=0 then RETURN(FAIL): fi: P1:=P/c: P1:=P1-F: INI:=-coeff(P1,F,0): Q:=-INI-P1: [INI,Q]: end: