Question: how to make type selection orderless?

I am learning how to use select with my own types defined, to find parts of expression. This is instead of using patmach.

For example, given   3+x^2*sin(x) and then I want to find any POLYNIMAL*sin function, if present. So I did the following

restart;
expr_1:=3+x^2*sin(x):
mytype_1 := `&*`( polynom(And(algebraic, satisfies(u -> not has(u, I))),x),specfunc('sin')):
select( z->type(z,mytype_1),expr_1);

Which works. Maple returned 

The problem is that if I change the order of multiplication, and also at same time change the polynomial by adding one more term, it no longer works!

I have no idea why. It seems Maple rememebrs something.  Here is a screen shot, followed by plain text code.

 

code

restart;
expr_1:=3+(1+x)*sin(x):
mytype_1 := `&*`( polynom(And(algebraic, satisfies(u -> not has(u, I))),x),specfunc('sin')):
select( z->type(z,mytype_1),expr_1);
expr_1:=3+sin(x)*(1+x):
select( z->type(z,mytype_1),expr_1);

#change polynomial but keep same order, it works
expr_2:=3+(1+x+x^2)*sin(x):
select( z->type(z,mytype_1),expr_2);

#change order BUT keep same polynomial, it works
expr_3:=3+sin(x)*(1+x+x^2):
select(z->type(z, mytype_1),expr_3);

#keep same order as above, but change polynomial, now it does not works
expr_4:=3+sin(x)*(1+x+x^2+x^4):
select(z->type(z, mytype_1),expr_4);

#keep same order as first one  but change polynomial, it does not work
expr_5:=3+(1+x+x^2+x^4)*sin(x):
select(z->type(z, mytype_1),expr_5);

#keep same order as first one but change polynomial back to what it was, now it works
expr_6:=3+(1+x)*sin(x):
select(z->type(z, mytype_1),expr_6);

What Am I doing wrong?

 

Maple 2021.1

 

Please Wait...