# How to select p terms with powers larger than 1 in a given expression?

My expression is:

expr = (p^(1/3) q + 5)/(3q^2)+p^2+(p-1)^(1/3)

And I want to single out all terms with $$p^k, k > 1$$

How should I do that? (If there is any way other than applying Series[] would be the best, since I want it to be less time-consuming when dealing with large expr.)

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign Sep 12 '21 at 5:04
• Please give your expression in code. This will make it easier for others to help you out. Sep 12 '21 at 5:05

And I want to single out all terms with p^k,k>1

I use this nice function getPatterns thanks to Carl Woll that he gave me as an answer long time ago. It is a handy function to have in your toolbox.

ClearAll[p, q];
expr=(p^(1/3)*q+5)/(3*q^2)+p^2+(p-1)^(1/3)+p^5+(p^(9/2)-1)^(1/3)

getPatterns[expr_, pat_] := Last@Reap[expr /. a : pat :> Sow[a], _, Sequence @@ #2 &];

And now

getPatterns[expr, Power[p, x_] /; x > 1]

Edit

if there is a term 2 q p^(1/3), it only gives p^(1/3) while neglecting 2 q factor in front under current setting. And I want to have the final answers attached with 2 q factor

You can change the pattern to

expr = (2 *q*p^(1/3)*q + 5)/(3*q^2) + p^2 + (p - 1)^(1/3) +
p^5 + (888*p^(1/2) - 1)^(1/3)
getPatterns[expr, any_*Power[p, x_] /; x < 1]

• Thank you for your reply! But is there anyway to also single out the coefficients corresponding to the terms? Sep 12 '21 at 5:29
• @TianyiWang You mean the actual powers themselves? Sep 12 '21 at 5:30
• For example, if there is a term 2 q p^(1/3), it only gives p^(1/3) while neglecting 2 q factor in front under current setting. And I want to have the final answers attached with 2 q factor. Sep 12 '21 at 5:36
• @TianyiWang please see edit. Sep 12 '21 at 5:41
• It works!! Thanks a lot! Sep 12 '21 at 6:12