Question: indets to find all _C^n in expression, including default n=1

What is the correct way to find all terms of the form  _Cn^m where n is non negative integer and m is exponent which can be 1?

The problem is finding _Cn with no exponent. Maple's   _Cn^anything does not match _Cn but only when there is an actual exponent present.

It is easy to find _Cn^m with m present and easy to find _Cn with no exponent, but how to combine the two is the problem. Here is an example.

Given e:=_C1^2+_C1+_C2^3+a+b; I want to obtain the set {_C1^2,_C1,_C2^3}  but I get instead {_C1, _C2, _C1^2, _C2^3} using ther following code

e:=_C1^2+_C1+_C2^3+a+b;
indets(e,   Or(  And(symbol, suffixed(_C, nonnegint)),
                 And(symbol, suffixed(_C, nonnegint))^anything  ));

If instead I do this

e:=_C1^2+_C1+_C2^3+a+b;
indets(e, And(symbol, suffixed(_C, nonnegint))^anything);

This gives {_C1^2, _C2^3} , so it did not pick the _C1 term since exponent is missing. If I do this instead

e:=_C1^2+_C1+_C2^3+a+b;
indets(e, And(symbol, suffixed(_C, nonnegint)));

This it gives {_C1, _C2} and if I do 

e:=_C1^2+_C1+_C2^3+a+b;
indets(e,   And(symbol, suffixed(_C, nonnegint))^Or(anything,identical(1)))

it gives {_C1^2, _C2^3}

What to do to obtain {_C1^2,_C1,_C2^3} 

I am trying to find all _Cn^m in an expression where m can be anything including not being there (or 1 basically) but in Maple, exponent 1 is not counted as exponent.

Update

Another input example is e:=_C1^2+_C1+ _C1*_C2^3+a+b;  This should be produce the set {_C1^2,_C1,_C2^3} 

Any trick to use for this?

Maple 2024.1

 

Please Wait...