Imagine we have an expression that contains both integer ($y$, $y^3$, $y^8$ etc.) and non-integer powers ($y^{1+\alpha}$, $y^{2\,\alpha}$, $y^{2+3\,\alpha}$) of the variable $y$, where $\alpha\in\mathbb{R}$, $\alpha>0$.
Simple example
expr = (-1 + (-1 + x) y) (2 + x y + y^α); I want to rewrite this as
-2 + (-2 + x) y + (-1 + x) x y^2 - y^α + (-1 + x) y^(1 + α) A more complicated expression, closer to what I have in reality:
expr=(-1 + (-1 + x) y + (-1 + x - x^2) y^2) ((1 + x)^4 (1 + y^2 a2[x] + y^α sna[x])^2 ((1 + (-1 + x) y) (1 + 1/2 (-1 + x) x (-1 + (-1 + x) x (6 + x (-8 + 3 x))) y + y^α sna[x]) (1 + 1/2 (-1 + x) x (1 + (-1 + x) x (-14 + x (-8 + 21 x))) y + y^α sna[x]) + (1 +1/2 x (-1 + x (35 + x (-76 + x (23 + (46 - 27 x) x)))) y + y^α sna[x]) (3 + 1/2 (-4 + 5 x - 3 x^2 - 20 x^3 + 73 x^4 - 78 x^5 + 27 x^6) y + y^α (3 + 2 (-1 + x) y) sna[x]))); where sna[x] is some real function of another variable x that we do not care about.
As in the simple example - I want to Collect all powers of y - both integer and non-integer, so the final expression will be something like
$\sum_{n=0}^{N}\,a_n(x)\,y^{n}+\sum_{k=0}^{K}b_k(x)\,y^{k+\alpha}+\sum_{j=0}^{J}c_j(x)\,y^{j+2\,\alpha}+...$ and so on depending on what is the highest multiple of $\alpha$ in an exponent, for some integers $N$, $K$, $J$.
I tried
Block[{$Assumptions = α > 0 && α ∈ Reals}, Collect[expr, y, Simplify]] and
Block[{$Assumptions = α > 0 && α ∈ Reals}, Collect[expr, {y, y^α}, Simplify]] but they don't work.
UPDATE: Possible solution. Taking the more complicated example, then we do
Block[{$Assumptions = α > 0 && α ∈ Reals}, kek = Collect[expr, {y, y^α}, Simplify]]; kekList = List @@ kek; Block[{$Assumptions = α > 0 && α ∈ Reals}, kek2 = If[StringContainsQ[ToString[Exponent[#, y]], "Max"], List @@ Collect[ExpandAll[#], y^α, Simplify], Collect[ExpandAll[#], y^α, Simplify]] & /@ kekList]; kek3 = SortBy[Flatten[kek2], Exponent[#, y] &]; and kek3 is what I want. A quick check on the exponents
Exponent[kek3, y] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, α, 2 α, 3 α, 4 α, 1 + α, 2 + α, 3 + α, 4 + α, 5 + α, 6 + α, 7 + α, 8 + α, 1 + 2 α, 2 + 2 α, 3 + 2 α, 4 + 2 α, 5 + 2 α, 6 + 2 α, 7 + 2 α, 1 + 3 α, 2 + 3 α, 3 + 3 α, 4 + 3 α, 5 + 3 α, 1 + 4 α, 2 + 4 α, 3 + 4 α} I am not going to post what kek3 is itself, as it is very long. The above also works with the simple example.
Now, this is the brute force way that is not efficient. What is the Mathematica way to do it, as my real expressions are way longer and this will take centuries to evaluate.
In[42]:= expr = (-1 + (-1 + x) y) (2 + x y + y^a); Collect[expr, {y^a, y}, Factor] Out[43]= -2 + (-2 + x) y + (-1 + x) x y^2 + y^a (-1 + (-1 + x) y)$\endgroup$someExpr/.{x^(1+k_):>x^k}for example. $\endgroup$