Question: How to automatically group all functions in expression?

I have expression which can have many different functions  in it. Assume the expression is `+` type.

I do not know before what these function names are. 

Is there a way to make Maple collect on these functions automatically? Simplify does not do it. So if there is something like b*g(x)+g(x) in the expression, to simplify this to (1+b)*g(x) automatically?

I noticed if expression is   just b*g(x)+g(x) then simplify does give (1+b)*g(x) but once I add a new term, like 3+b*g(x)+g(x) then it no longer does it! which for me is very strange. I was expecting to get 3+(1+b)*g(x) 

Here is an example

restart;

T:=g(x)+b*g(x);
simplify(T);

g(x)+b*g(x)

g(x)*(b+1)

T:=3+g(x)+b*g(x);
simplify(T);

3+g(x)+b*g(x)

3+g(x)+b*g(x)

T:=3+g(x)+b*g(x)+f(x);
simplify(T);

3+g(x)+b*g(x)+f(x)

3+g(x)+b*g(x)+f(x)

 

 

Download simplification_oct_9_2024.mw

What do I need to do to get this output using another software

Ofcourse, I could go and add code to find the names of each function and then use collect. But it seems to me simplify should have done this automatically as the above shows. So I am wondering if there is an option I've overlooked which will do this more easily.

Maple 2024.1

Please Wait...