4.26 How to find all derivatives \(y'(x)\) in an expression?

Given an expression such as

\[ \sin \left (x \right )+\left (\frac {d}{d x}y \left (x \right )\right )^{3}+\left (\frac {d}{d x}y \left (x \right )\right ) \ln \left (y \left (x \right ) \left (\frac {d}{d x}y \left (x \right )\right )^{2}\right )+\sqrt {\frac {d}{d x}y \left (x \right )}+\frac {x}{\left (\frac {d}{d x}y \left (x \right )\right )^{7}} \]

Find all \(y'(x)\) for any power that show up, so the result should be

\[ \left \{\frac {1}{\left (\frac {d}{d x}y \left (x \right )\right )^{7}}, \left (\frac {d}{d x}y \left (x \right )\right )^{2}, \left (\frac {d}{d x}y \left (x \right )\right )^{3}, \sqrt {\frac {d}{d x}y \left (x \right )}, \frac {d}{d x}y \left (x \right ) \right \} \]

Use indets with type identical(diff(y(x),x))^anything is used. But must use the flat option to work correctly.

restart; 
 
expr:= y(x)*diff(y(x),x)^(1/3)+sin(x)*diff(y(x),x)^3 + z*diff(y(x),x)*ln(y(x)*diff(y(x),x)^2) +diff(y(x),x)^(1/2) + x/diff(y(x),x)^7; 
t1:=identical(diff(y(x),x))^anything; 
t2:=identical(diff(y(x),x)); 
indets[flat](expr, 'Or'(  t1, t2 ));
 

gives

{diff(y(x), x)^(1/3), 1/diff(y(x), x)^7, diff(y(x), x)^2, diff(y(x), x)^3, diff(y(x), x), sqrt(diff(y(x), x))}
 

Without using flat it will given wrong result. For example

restart; 
 
expr:=diff(y(x),x)^2; 
t1:=identical(diff(y(x),x))^anything; 
t2:=identical(diff(y(x),x)); 
indets(expr, 'Or'(  t1, t2 ));
 

Gives

{diff(y(x), x)^2, diff(y(x), x)}
 

You see, it has extra diff(y(x), x) showing up. Adding flat it gives

restart; 
 
expr:=diff(y(x),x)^2; 
t1:=identical(diff(y(x),x))^anything; 
t2:=identical(diff(y(x),x)); 
indets[flat](expr, 'Or'(  t1, t2 ));
 

Now it gives

{diff(y(x), x)^2}
 

Which is the correct result.