#Yusra Naqvi: HW #12 #OK to post ################################################################################ ################################################################################ #3 #GuessDE(L,x,Di,Max): inputs a list of L, representing the first nops(L) terms #of a formal power series: #P(x)=L[1]+L[2]*x+ ...+L[nops(L)]*x^(L-1)+ ... #and outputs a differential operator with polynomial coefficients: #OPER(x,Di) #(where Di is differentiation with respect to x), such that the ORDER ("degree" #in Di) and DEGREE (degree in x) satisfy DEGREE+ORDER<=Max, but with #DEGREE+ORDER as small as possible, such that when you apply OPER(x,Di) to P(x), #it is (conjenturally) 0 GuessDE:=proc(L,x,Di,Max) local M,oper: for M from 1 to Max do oper:=GuessDE1(L,x,Di,M): if oper<>FAIL then return(oper): fi: od: FAIL: end: ################################################################################ #GuessDE1(L,x,Di,M): this is the same as above, but with DEGREE+ORDER=M GuessDE1:=proc(L,x,Di,M) local order,oper: for order from 1 to M do oper:=GuessDE11(L,x,Di,M,order): if oper<>FAIL then return(oper): fi: od: FAIL: end: ################################################################################ #GuessDE11(L,x,Di,M,order): this is the same as above, but with ORDER=order GuessDE11:=proc(L,x,Di,M,order) local P,n,oper,var,eq,i,j,k,var1: P:=add(L[n]*x^(n-1),n=1..nops(L)): oper:=add(add(a[i,j]*x^i*Di^j,j=0..order),i=0..M-order): var:={seq(seq(a[i,j],j=0..order),i=0..M-order)}: eq:={seq(coeff(add(a[i,0]*x^i*P+add(a[i,j]*x^i*diff(P,x$j),j=1..order), i=0..M-order),x,k),k=0..nops(L)-1-order)}: var1:=solve(eq,var): oper:=subs(var1,oper): if oper=0 then return(FAIL): else oper:=subs({seq(v=1, v in var)},oper): fi: end: ################################################################################ ################################################################################ #4 #AlgToDE(F,P,x,Di,K): inputs a polynomial F(P,x) and the variables P and x, #representing an algebraic equation F(P(x),x)=0 satisfied by a #formal power series P(x), and a positive integer K, and conjectures #a differential operator "annihilating" P(x), by using the first K+1 #coefficients of the Maclaurin expansion of P(x). #For example: #AlgToDE(P*(1-x)-1,P,x,30); #should return: #1-Di+x*Di AlgToDE:=proc(F,P,x,Di,K) local L: L:=AlgToSeq(F,P,x,K+1): GuessDE(L,x,Di,K): end: ################################################################################ #AlgToSeq(F,P,x,K): #inputs #(i) a polynomial F in the symbols P and x denoting an algebraic relation #satsfied by a formal power series P(x) such that #F(P(x),x)=0 #(ii),(iii) variables P and x as above #(iv) a positive integer K, #outputs: #a sequence of length K+1 denoting the coefficients of x^0 through x^k #of the Maclaurin expansion of the power series of P(x). #For example: #AlgToSeq(P*(1-x)-1,P,x,4); #should output #[1,1,1,1,1] #AlgToSeq(P-1-x*P^2,P,x,4); #should output #[1,1,2,5,14] AlgToSeq:=proc(F,P,x,K) local H,F1,i,f,L,m,f0: H:=coeff(F,P,1): if subs(x=0,H)=0 then return(FAIL): fi: F1:=(H*P-F)/H: f:=1: L:=[1]: for i from 1 to K do f:=expand(subs(P=f,F1)): f:=taylor(f,x,i+1): L:=[op(L),coeff(f,x,i)]: f:=add(coeff(f,x,m)*x^m,m=0..i): od: L: end: ################################################################################