Question: how to extract common term in this form

colect(expr,y)  and collect(expr,y,factor) do not work on these.  The expression can be anything. No necessarily a polynomial in y.

I have as input an expression, which has y  in it, and I want to find if I can write it  as   y*(....)  of y^2*(...) or y^3*(...), etc...

Basically, I want to see if can be taken out as common term. Just like we do by hand. 

So, given expression as  y^2+y^3*sin(x)+3*x*y^5 then I want to see if it can be written as y^2*(1+y*sin(x)+3*x*y^3)

In the above y^2 was extracted as common term. I found that simplify sometimes work, but I can't depend on simplify, since it is not guranteed to work all the time. Here is an example where it worked

expr:=y^2+y^3*sin(x);
simplify(expr)

but if expression is this, then it did not extract out y^2

expr:=y^2+y^3*sin(x)+3*x*y^5;
simplify(expr)

I am doing this  all in code, without looking at the expression and decide what to do. 

I just know  is the name of the variable, and the expression will be a function of  and I just want to know if I can extract a common y^n  term out, so the result is y^n*g(y)

For example, for expr:=y^2+y^3*sin(x)+3*x; it will fail, since  I can't extract from all terms. In this case the result will be  y^2*(1+y*sin(x))+3*x  and this is not type(`*`). So it is ok for the method to fail, if it can not do it. I can always check the result to see if it failed or not.

Does Maple have build in method to do this? Or one has to program this? I wanted to ask first before if there is some hidden Maple function that can do this I did not see.

Sometimes math is easier to do by hand than using the computer :)

Maple 2020.2

Thanks.

edit: I also tried factor, but it does not work on everything. An example where it did not work

expr:=y^2+y^3*sin(x)+3*x*y^(7/2);
factor(expr);

It did not factor out y^2 because of y^(7/2) is not "integer, rational. numeric, or algebraic coefficients"? according to help.

Edit:

Thanks to all the answers. I used a combination of all of them to check if it can be factored or not, and now it is working for every example I tried it on. So if one method failed, I try the next method shown in the answers. 

 


 

Please Wait...