############################################################## # Judge the relation of total degree with the degree wrt y[1] of F(y). # Input: F -differential polynomial # tdeg -the total degree of F # Output:'easy' -if F=y_1 or F=y_1+a # 'yes' -F=0 maybe have a polynomial general solution # 'no' -F=0 has no polynomial general solutiion ############################################################## Judgedegree:=proc(F,tdeg) local dy0,dy1,c,i,minu; dy0:=degree(F,y[0]); dy1:=degree(F,y[1]); if dy1=tdeg and dy0=dy1-1 then if dy1=1 then return(easy) else minu:=F-coeff(F,y[1],dy1)*y[1]^dy1; # judge whether the total degrees of monomials in F except y_1^tdeg # are not greateer than tdeg-1 for i from 0 to tdeg-1 do c:=coeff(minu,y[0],i); if degree(c,y[1])>tdeg-1-i then return(no) fi; od; return(yes); fi; fi; return(no) end: ################################################################## # Judge whether ybar is a polynomial solution of F=0 # Input: F -differential polynomial # tdeg -total degree of F # ybar -a polynomial wrt x # Output:'yes' -ybar is a polynomial solution of F=0 # 'no' -ybar is not polynomial solution of F=0 ################################################################## JudgeSols:=proc(F,tdeg,ybar) local num,i,py0,py1,ybar1; ybar1:=diff(ybar,x); # Substitute x by intergers 0...tdeg*(tdeg-1)/2 in F(ybar) to decite whether # F(ybar)=0 for i from 0 to tdeg*(tdeg-1)/2 do py0:=subs(x=i,ybar); py1:=subs(x=i,ybar1); num:=subs(y[0]=py0,y[1]=py1,F); if num<>0 then return(no) fi; od; # Substitute x by intergers -1...-tdeg*(tdeg-1)/2 in F(ybar) to decite whether # F(ybar)=0 for i from -1 by -1 to -tdeg*(tdeg-1)/2 do py0:=subs(x=i,ybar); py1:=subs(x=i,ybar1); num:=subs(y[0]=py0,y[1]=py1,F); if num<>0 then return(no) fi; od; return(yes); end: ###################################################################### # Compute the coefficient of x^deg in F(ybar) which maybe a solution # of F=0 # Input: F -differential polynomial # tdeg -total degree of F # ybar -a polynomial wrt x # deg -non negative integer # pc -the coefficients of monomials with total # degree tdeg-1 in F(y) # Output: result -the coefficient of x^deg ########################################################################## Computecoeff:=proc(F,tdeg,ybar,deg,pc) local py0,py1,i,j,yb0,num,result; num:=(tdeg-1)^2+deg-1; py0[0]:=1; py1[0]:=1; py0[1]:=ybar; py1[1]:=diff(ybar,x); if num=0 then result:=subs(y[0]=subs(x=0,py0[1]),y[1]=subs(x=0,py1[1]),F); return(result); fi; # Compute ybar^i for i=1...tdeg-1 for i from 2 to tdeg-1 do py0[i]:=expand(py0[i-1]*py0[1]) od; # Compute (ybar')^i for i=1..tdeg (ybar' ===deravite of yabr wrt x) for i from 2 to tdeg do py1[i]:=expand(py1[i-1]*py1[1]) od; for i from 0 to tdeg-1 do py1[i]:=pc[i]*py1[i]; od; result:=0; # Compute the coefficient of x^deg in ybar^(tdeg-2) if deg=0 then yb0:=coeff(F,y[0],tdeg-2); result:=result+coeff(yb0,y[1],0)*coeff(py0[tdeg-2],x,num); fi; # Compute the coefficient of x^deg in (ybar')^tdeg result:=result+coeff(F,y[1],tdeg)*coeff(py1[tdeg],x,num); # Compute the coefficient of x^deg in ybar^(tdeg-1-i)*(ybar')^i if deg=0 then for i from 0 to tdeg-1 do for j from num-(tdeg-1)*i to num do result:=result+coeff(py0[tdeg-1-i],x,j)*coeff(py1[i],x,num-j); od; od; else for i from 0 to tdeg-deg do for j from num-(tdeg-1)*i to num do result:=result+coeff(py0[tdeg-1-i],x,j)*coeff(py1[i],x,num-j); od; od; fi; return(result); end: ################################################################# # Compute a polynomial wrt x which maybe a solution of F=0 # Input: F -differential polynomial # tdeg -total degree of F # Output:yb -a polynomial wrt x ################################################################# ComputeSols:=proc(F,tdeg) local coef,n,yb,i,fy,coefx,cy0,yb0,pc,deno; n:=tdeg; cy0:=coeff(F,y[0]^(n-1)); coef[n]:=-cy0/(n^n*coeff(F,y[1]^n)); coef[n-1]:=0; deno:=cy0*coef[n]^(n-2); yb:=coef[n]*x^n; # Compute the coefficients of monomials with total degree tdeg-1 for i from 0 to n-1 do yb0:=coeff(F,y[1],i); pc[i]:=coeff(yb0,y[0],n-1-i); od; for i from 2 to n do coefx:=Computecoeff(F,tdeg,yb,n-i,pc); coef[n-i]:=-coefx/(deno*(i-1)); yb:=yb+coef[n-i]*x^(n-i); od; return(expand(yb)) end: ############################################################# # Main Program # Input: F -first order differential polynomial with constant # coefficient # Output: A polynomail general solution of F=0 if it exists or # Error information ############################################################# PolyGS:=proc(F) local n,sols,Gsols,a; n:=degree(F,{y[1],y[0]}); # the case F is not a differential polynomial wrt y if n=0 then print("The Input is WRONG!");return(); fi; # the case F=y_1 or y_1+a if n>0 and Judgedegree(F,n)='easy' then a:=subs(y[1]=0,F); print("The Polynomial General Solutions is"); if a=0 then print(c); else print(-a*(x+c)); fi; print("The run time is"); return(); fi; # other cases if n>0 and Judgedegree(F,n)='yes' then sols:=ComputeSols(F,n); if JudgeSols(F,n,sols)='yes' then Gsols:=subs(x=x+c,sols); print("The Polynomial General Solutions is"); print(Gsols); print("The run time is"); else print("No Polynomial General Solutions"); print("The run time is"); fi else print("No Polynomial General Solutions"); print("The run time is"); fi; end: ###################################################################### # Give the run time # ###################################################################### PolyGSols:=proc(F) time(PolyGS(F)) end: printf("The program is to find a Polynomial General Solutions of F(y)=0\n"); printf("where F(y) must be an IRREDUCIBLE FIRST ORDER¡¡differential polynomial.\n"); printf("We denote differential indeterminant by y[0], and the first derivative\n"); printf("of y[0] wrt x by y[1].\n"); printf("That is said, F(y) must be an irreducible algebraic polynomial in y[0],y[1].\n"); printf("For example, F(y)=y[1]^3+y[0]^2 is a right form,\n"); printf("but F(y)=(y')^3+y^2 or F(y)=y+1 are not \n"); printf("The main procedure is as the following\n"); printf("[ PolyGSols(F) ]\n");