3.15 How to check if an ode has \(y'\) in it?

Suppose to want to check if an ode has \(y'(x)\) in it. We can not write has(ode, diff(y(x),x)) and see if this gives true or not, because this will also match \(y''\) and \(y'''\) and any higher order.

One way is to first convert the ode to D form and then use has on D(y)(x). This will not match \(y''\) anymore which is what we wanted, because \(y''\) becomes (D@@2)(y)(x) and so the check for first order diff will work as expected.

ode:=diff(y(x),x$2)+3*y(x)=0; 
ode:=convert(ode,D); 
has(ode,(D)(y)(x)) 
 
            #false
 

Another example

ode:=diff(y(x),x$2)+1/diff(y(x),x)=0; 
ode:=convert(ode,D); 
has(ode,(D)(y)(x)) 
 
            #true
 

The same thing if we wanted to check if the ode has \(y''\) or not.

ode:=diff(y(x),x$3)+diff(y(x),x)=0; 
ode:=convert(ode,D); 
has(ode,(D@@2)(y)(x)) 
 
       #false