Question: how to find constants _Cn in an expression?

Given an expression, how to best find the constants _C1, _C2, etc.... in this expression?  Currently I do the following, but I think there should be a better way.

restart;
sol:=dsolve(diff(y(x),x$2)+y(x)=1);
indets(sol);
select(x->`if`(type(x,symbol) and convert(x,string)[1..2]="_C",true,false),indets(sol))

The above works, at least on the few examples I tried it on, but is there a better way to do it?  All constants will have the form _Cn where n is integer. 

 

 

Please Wait...