2
$\begingroup$

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.

$\endgroup$
4
  • 1
    $\begingroup$ If expr is not polynomial in x, either Collect[ expr, x, f] or Collect[expr, x] often simply returns expr. I don't have a reference for this, but I realized it while looking into this question (see comments). $\endgroup$
    – jjc385
    Sep 22, 2017 at 22:23
  • 1
    $\begingroup$ Perhaps you might be able to separate your input into pieces that are polynomial in (x+_)^_, and then do Collect[polnomialPart, (x+_)^_, whatever] on those. But note e.g. the behavior of Collect[a Sqrt[x + y] + b Sqrt[x + y] + d (x + y)^(-1/2), (x+_)^_], which has head Times. $\endgroup$
    – jjc385
    Sep 22, 2017 at 22:29
  • $\begingroup$ Finally, you might want to do Together on your expression and do Collect on the Numerator only. $\endgroup$
    – jjc385
    Sep 22, 2017 at 22:29
  • $\begingroup$ @jjc385 Thank you for the pattern suggestion (x+_)^_ with caution. I'll play around with it. I will check on the possible inherent limitation of Collectnot working for non-polynomials, and maybe I'll modify the post accordingly (remove the Simplify issue). As for Together, please see my added clarification in the paragraph starting with the words "my ultimate goal". Anyway your comments are appreciated! $\endgroup$ Sep 22, 2017 at 23:25

1 Answer 1

2
$\begingroup$

This is just addressing your ultimate goal. You can do

List @@ ExpandAll @ myFun;
Cases[%, #] & /@ {c0_ /; FreeQ[c0, x], x * c1_ /; FreeQ[c1, x]};
split = Plus@@@Append[%, Complement[%%, Flatten@%]];

It might be more readable to do

{constant, linear, perturbation} = split

Check that the split pieces sum to the original expression:

Plus @@ split == ExpandAll @ myFun
True
$\endgroup$
3
  • $\begingroup$ Wow this is great! I can understand codes like this when I read it, but I'm not at that level yet to write it myself. This is definitely a big step going in the right direction. It certain helps me a lot to dissect what I'm dealing with. I'll need to do some numerical work to see if this solves all my problems. $\endgroup$ Sep 23, 2017 at 0:12
  • $\begingroup$ Thanks for the accept. Were there other parts of your question that I failed to address? $\endgroup$
    – jjc385
    Sep 28, 2017 at 20:43
  • 1
    $\begingroup$ No, there weren't. You covered pretty much all aspects of the task in the earlier comments and in this "List then Pattern" approach. Thanks. You help edme realize that I need to have a customized procedure for my specific function and parameter range. $\endgroup$ Sep 28, 2017 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.