restart; my_type:=''`*`'( { Or('specfunc'(sin),'specfunc'(sin)^Or(integer,rational)), Or('specfunc'(cos),'specfunc'(cos)^Or(integer,rational))})'; type(sin(x)^2*cos(x)^3,my_type); type(sin(x)^2*cos(x),my_type); type(sin(x)*cos(x),my_type); type(cos(x)*sin(x)^(1/2),my_type); true true true true
I could not find a way to avoid writing Or('specfunc'(sin),'specfunc'(sin)^Or(integer,rational)
in order to match both \(\sin x\) and \(\sin ^2 x\). For these things, I find Mathematica patterns more flexible.
The above can be done as follows in Mathematica
ClearAll[x,n,m,any] patt=any_.*Sin[_]^n_. * Cos[_]^m_. MatchQ[Sin[x]^2*Cos[2*x]^3,patt] MatchQ[Sin[x]^2*Cos[x],patt] MatchQ[Sin[x]*Cos[x],patt] MatchQ[Cos[x]*Sin[x],patt] True True True True
In Mathematica n_. says basically to match \(\sin x\) or \(\sin ^2 x\) since the dot says to match zero or
more. So no need to duplicate things as I did above in Maple. There might be a way to do
the same in Maple using structured type, but I could not find it. In General, I
find patterns in Mathematica more flexible and easier to use for this sort of
thing. Maple has patmatch command, but not as easy to use as Patterns in
Mathematica.