4.37 find if some type inside some expression and its location

Use membertype

restart; 
expr:=cos(x)+x+9+sin(x)*(x^2+4); 
membertype( polynom(anything,x), expr,'loc' ); 
       true 
loc; 
       2
 

The above says there is a polynomial in \(x\) inside the expression at op(2,expr) notice that \(x^2+4\) is not a polynomial since the expression will expand and \(\sin x\) will be multiplied by it causing it not to become polynomial. So only \(9+x\) is the polynomial. The location is where the member starts at. Notice that Maple sorts polynomial from lower to higher powers.

restart; 
expr:=cos(x)+x+9+sin(x)*(x^2+4); 
membertype( integer, expr,'loc' ); 
       true 
loc; 
       3
 

The above says that there is an integer (which is \(9\) in this example) inside the expression at op(3,expr)