An easy workaround approach is to multiply the polynomial by some x^m, then cut terms and then restore the original terms. But is there an easier way, ideally using ReplaceAll alone? Thanks.
Let’s say you have P=P_{\ge4}+P_{<4} and trouble computing P_{\ge4} directly.
Why not compute P_{<4} and then obtain P_{\ge4} by subtraction, P_{\ge4}=P-P_{<4}?
Whenever you know the maximum exponent in your power series, you have another option to use “Coefficient” and work in a vector space of the coefficients. The advantage here is that
Coefficient[ P, x, 0 ]
will return 2 in your case. Combining with Map, Part, Dot, Power, and Range I think you should be able to calculate P_{\ge4} without ever using any replacement rules.
Since my earlier method to strike that subpolynomial took too long, Tech Support used zero replacement to swiftly strike it. But then I noticed an occasional wrong result caused by a linear term c x that replacement didn’t touch. Unable to zero out the subpolynomial-with-linear-term, I turned to Wolfram Community to see if Replacement could be made to do so.
In the actual application, the full polynomial (in x) is the sum of many bilinear forms a.B.c where B is the power of another matrix whose entries are powers of x – B also depends upon the summation index (whose values are tuples). And so computing that subpolynomial isn’t so easy. Although it seems that Replacement can’t be made to behave as I had hoped, your idea to use Coefficient is a good one that I’ll remember.
Thanks Sander. This looks great for use with polynomials.
As it turns out, what I had called a “polynomial” is really a Laurent polynomial, and so the negative integer exponents cause trouble. I’ll still further investigate CoefficientRules.
Yours and Brad’s replies suggest that maybe Replacement can’t be coerced into zeroing-out a linear term in a Laurent polynomial. If so then this is important to know.
I didn’t suggest this earlier, because you wanted to keep the constant term while dropping non-constant terms below a threshold. Your last comment suggests that you do want to zero-out the linear term. So, if you wanted to drop all terms below a threshold, including the constant term, then you could use Series as follows:
Thanks Carl. Using Normal is what I first used but for my long Laurent polynomials, processing was slowing down. That’s when I asked Tech Support if there was a faster way and that’s when zeroing-out was suggested. Since Normal adapts to many things, more work is done to determining its appropriate use and this – among other things – contributes to the slowing down.
HOWEVER, your first example uses (x, Infinity, -3} – I’ve never considered using Infinity as the center point. So, you’ve just helped with other matters that will soon come back into my inbox. Thank you again for this.