3.38 How to find if an ode is missing the dependent variable?

Sometimes it is useful to know if ode is missing \(y(x)\) as this allows one to do the substitution \(y'=u\) and reduce the order of the ode.

This is a function which takes in an ode and returns true if it is missing \(y(x)\) or false otherwise.

#added 2/18/2024. checks if an ode is missing y 
export is_ode_missing_y:=proc(ode_in::`=`,y::symbol,x::symbol)::truefalse; 
local ode:=ode_in; 
local ode_order::posint := PDEtools:-difforder(ode_in); 
local N::posint; 
 
    ode:=lhs(ode)-rhs(ode); 
    ode:=convert(ode,D); 
    for N from 1 to ode_order do 
        ode:=eval(ode,[(D@@N)(y)(x)=Y||N]); 
    od; 
 
    RETURN(not has(ode,y(x))); 
 
end proc;
 

To use do

restart; 
ode:=diff(y(x),x$2)+diff(y(x),x$4)+x=0; 
is_ode_missing_y(ode,y,x); 
 
       #true 
 
ode:=diff(y(x),x$2)+diff(y(x),x$4)+x=sin(x)+y(x); 
is_ode_missing_y(ode,y,x); 
 
      #false