I have been failing to apply Collect[#, x]&
to render a like-power series of $x^k$. Here $k = \frac52, \frac32, \frac12,\frac{-1}2$, etc.
The major issue is:
terms like $\sqrt{x}$ and $\sqrt{x+y}$ are not grouped together even though I thought in Collect[#, x]&
things like $y$ would be treated as constants. (this can't be fixed by With
, right?)
For my purpose, $\sqrt{x^5 +y^5}$ is considered the same power as $x^{\frac52}$, and I believe there are no terms like $\frac{\sqrt{x+y}}{\sqrt{x+2y}}$ or $\sqrt{a x^2 + bx}$.
Question:
How do I arrange the expression (named
myFun
in the code block) into a series of like-powers of $x$? I'd like to group all terms of the form $\sqrt{x+y}$ together, including $y = 1$ and $y=0$.(I also would like to see
myFun
in series of like-powers of $L$, where $L$ is another variable shown in the codes. Attempting at $L$-series poses basically the issues.)
My ultimate goal is to identify the expression as "linear $x$ plus perturbation" for asymptotic $L$ (actually at just $L \gtrapprox 3$ or 4). Therefore, it is essential that I'll be able to demonstrate the final result as something like "$c_0 + c_1 x +{}$other powers (positive or negative)". Consequently, Together
or Collect[#, {Sqrt[x], Sqrt[1+x-y]} }]&
based methods might need to recruit additional tricks to achieve this.
(Substantial Edit: Originally the post contained paragraphs about failure of Simplify
inside Collect
, which was distracting.)
Mathematically, $x$ and $L$ are the only two variables, and they are independent. All others are considered parameters with ranges specified in the block.
(* WARNING !!! HUGE OUTPUT !!! *)
ClearAll[myFun, tmp, ps (* power sum *), L, x, y, Y, tmp];
ps[j_, M_] := 2/5 ((j + M)^(5/2) - (1 + j)^(5/2)) + ((j + M)^(3/2) + (1 + j)^(3/2))/2 + 1/8 (Sqrt[j + M] - Sqrt[1 + j]) + 1/1920 (1/(j + M)^(3/2) - 1/ ((1 + j)^(3/2)));
tmp = (y (Y + L) - x Y)/(y + Y);
tmp = ps[x, tmp] Sqrt[1/(L + x + Y)] - ps[x - y, tmp] Sqrt[1/(L + x - y)];
myFun = Normal@Series[tmp, {L, \[Infinity], 4}]
(* Collect[ExpandAll@myFun,x,
Simplify[#,
0<x<1 && 0<y<1 && y+Y >0 && L >= 3
]& ] gives many terms that obviously can be combined *)
I'm also open to any methods other than Collect
that produce results similar to what I described above. (This might be a mathematically ill-posed question ... but there seems to be some wiggle room)
My failed attempts thus far include:
(a) Using Pattern
to try to capture "any sqrt-like function involving $x$", with BlankNullSequence
which I don't really know how ... Collect[ myFun, Power[ {___, x, ___ }, _ ] ]
is obviously wrong.
(b) Doing the arrangement on SeriesData
, that is, without Normal@
. This gave strange results that I'm not sure how to make use of.
There are some posts about Collect
but I didn't see any addressing non-integer powers. Others I don't think apply to my situation, like this (esp. the FAQ therein) or that.
Any input would be appreciated. Thanks.
P.S.
If the expression seems too large to read, feel free to reduce the order of Series
from 4 to 3. One can also remove the terms in ps[j_, M_]
starting at the $+\frac18$ and onward.
expr
is not polynomial inx
, eitherCollect[ expr, x, f]
orCollect[expr, x]
often simply returnsexpr
. I don't have a reference for this, but I realized it while looking into this question (see comments). $\endgroup$(x+_)^_
, and then doCollect[polnomialPart, (x+_)^_, whatever]
on those. But note e.g. the behavior ofCollect[a Sqrt[x + y] + b Sqrt[x + y] + d (x + y)^(-1/2), (x+_)^_]
, which has headTimes
. $\endgroup$Together
on your expression and doCollect
on theNumerator
only. $\endgroup$(x+_)^_
with caution. I'll play around with it. I will check on the possible inherent limitation ofCollect
not working for non-polynomials, and maybe I'll modify the post accordingly (remove theSimplify
issue). As forTogether
, please see my added clarification in the paragraph starting with the words "my ultimate goal". Anyway your comments are appreciated! $\endgroup$