1.1 Detect reduced Riccati ode \(y'=a x^n + b y^2\)

This detects Reduced Riccati ode \(y'=a x^n + b y^2\) where \(a,n,b\) are scalars and \(y(x)\) is the dependent function. The input to the proc is the ode and the dependent function \(y(x)\). The parsing function will return \(a,b,n\) if successful match is found, or FAIL if ode does not match the expected pattern.

reduced_riccati_parse:=proc(ode::`=`,func::function(name),$) 
local RHS; 
local y:=op(0,func); 
local x:=op(1,func); 
local la,a,b,n; 
 
   try 
      RHS:=timelimit(30,[solve(ode,diff(y(x),x))]); 
      if nops(RHS)<>1 then RETURN(FAIL); fi; 
      RHS:=expand(RHS[1]); 
   catch: 
      RETURN(FAIL); 
   end try; 
 
   if patmatch(RHS,a::anything*x^(n::anything)+b::anything*y(x)^2,'la') then 
      assign(la); 
      if has(a,x) or has(a,y(x)) then RETURN(FAIL); fi; 
      if has(n,x) or has(n,y(x)) then RETURN(FAIL); fi; 
      if has(b,x) or has(b,y(x)) then RETURN(FAIL); fi; 
      RETURN(a,b,n); 
   else 
      RETURN(FAIL); 
   fi; 
 
end proc:
 

Example usage

ode:=diff(y(x),x)=x-1+y(x)^2: 
reduced_riccati_parse(ode,y(x)); 
DEtools:-odeadvisor(ode); 
                              FAIL 
                           [_Riccati] 
 
ode:=diff(y(x),x)=x-1+y(x)^2: 
reduced_riccati_parse(ode,y(x)); 
DEtools:-odeadvisor(ode); 
                              FAIL 
                           [_Riccati] 
 
ode:=diff(y(x),x)=-3*x^2+y(x)^2: 
reduced_riccati_parse(ode,y(x)); 
DEtools:-odeadvisor(ode); 
 
                            -3, 1, 2 
                     [[_Riccati, _special]] 
 
ode:=diff(y(x),x)=x^(-4)+y(x)^2: 
reduced_riccati_parse(ode,y(x)); 
DEtools:-odeadvisor(ode); 
 
                            1, 1, -4 
               [_rational, [_Riccati, _special]] 
 
ode:=diff(y(x),x)=sin(x)*x^(-4)+y(x)^2: 
reduced_riccati_parse(ode,y(x)); 
DEtools:-odeadvisor(ode); 
 
                              FAIL 
                           [_Riccati] 
 
ode:=diff(y(x),x$2)=x^(-4)+y(x)^2: 
reduced_riccati_parse(ode,y(x)); 
DEtools:-odeadvisor(ode); 
 
                              FAIL 
            [[_2nd_order, _with_linear_symmetries]] 
 
ode:=diff(y(x),x)-x^(-4)-9*y(x)^2=0: 
reduced_riccati_parse(ode,y(x)); 
DEtools:-odeadvisor(ode); 
 
                            1, 9, -4 
               [_rational, [_Riccati, _special]] 
 
ode:=diff(y(x),x)=1/x+x*y(x)^2: 
reduced_riccati_parse(ode,y(x)); 
DEtools:-odeadvisor(ode); 
 
                              FAIL 
                     [_rational, _Riccati] 
 
ode:=diff(y(x),x)=a*1/x+b*y(x)^2: 
reduced_riccati_parse(ode,y(x)); 
DEtools:-odeadvisor(ode); 
 
                            a, b, -1 
               [_rational, [_Riccati, _special]] 
 
ode:=diff(y(x),x)=a*x^n+b*y(x)^2: 
reduced_riccati_parse(ode,y(x)); 
DEtools:-odeadvisor(ode); 
                            a, b, n 
                     [[_Riccati, _special]] 
 
ode:=diff(y(x),x)=a*x^n+y(x)+b*y(x)^2: 
reduced_riccati_parse(ode,y(x)); 
DEtools:-odeadvisor(ode); 
                              FAIL 
                           [_Riccati] 
 
ode:=diff(y(x),x)=y(x)*x^n+b*y(x)^2: 
reduced_riccati_parse(ode,y(x)); 
DEtools:-odeadvisor(ode); 
                              FAIL 
                          [_Bernoulli]