#Homework 12 by Ben Miles for Experimental math OK to post #Number 3 GuessDE:=proc(L,x,Di,Max) local M,a: for M from 1 to Max do a:=GuessDE1(L,x,Di,M): if a<>FAIL then RETURN(a): fi: od: FAIL: end: Di:=proc(j,P,x): if j=0 then P: else diff(P,x\$j): fi: end: GuessDE1:=proc(L,x,Di,M) local i,j,k,P,Q,R,a,vars,vars1,eq: Q:=add(L[i+1]*x^i,i=0..nops(L)-1): vars:={seq(seq(a[i,j], i=0..M-j),j=0..M)}: P:=add(add(a[i,j]*x^i*Di(j,Q,x), i=0..M-j),j=0..M): R:=add(add(a[i,j]*x^i*Di^j, i=0..M-j),j=0..M): eq:={seq(subs(x=k,P)=0,k=0..M*(M+1)/2+2)}: vars1:=solve(eq,vars): print(vars); #factor(subs(vars,P)): #P:=add(L[i+1]*x^i,i=0..nops(L)-1): #Q:=add((i+1)*L[i+2]*x^(i),i=0..nops(L)-2): #R:=add(L[i+1]*x^i-(i+1)*L[i+2]*x^(i),i=0..nops(L)-2): #P,Q,R: R:=subs(vars1,R): if R=0 then RETURN(FAIL): else R:#=subs({seq(v=1, v in vars)},R): fi: end: #I keep getting an extra term. I have a I'm not sure what I'm doing wrong #Number 4 AlgToDe:=proc(F,P,x,Di,K)local L: L:=AlgToSeq(F,P,x,K,1): GuessDE(L,x,Di,K-1): end: AlgToSeq:=proc(F,P,x,K,f0) local H,F1,i,f,L,m: H:=coeff(F,P,1): if subs(x=0,H)=0 then RETURN(FAIL): fi: #a0(x)+H(x)*P(x)+a2(x)*P(x)^2+...=0 #P(x)=-(a0(x)+a2(x)*P(x)^2+....)/H(x) F1:=(P*H-F)/H: #start at f(x)=1 and iterate f(x)->F1(f(x)) f:=f0: L:=[f0]: for i from 1 to K do f:=subs(P=f,F1): f:=taylor(f,x=0,i+1): L:=[op(L),coeff(f,x,i)]: f:=add(coeff(f,x,m)*x^m,m=0..i): od: L: end: