When your input is
1 + x^2 + x^3 /. x^2 -> 0, you get
1 + x^3. What should you type in to get
PolynomialMod[ a + b x + c y + d z + e x^2 + f x^2 y + g z^2 + h x^3 z + k x y z + l x^2 y^2 z^2, x^2] (* a + b x + c y + d z + k x y z + g z^2 *)
One could use a replacement rule, too:
a + b x + c y + d z + e x^2 + f x^2 y + g z^2 + h x^3 z + k x y z + l x^2 y^2 z^2 /. x^p_Integer /; p > 1 -> 0 (* a + b x + c y + d z + k x y z + g z^2 *)
As for most of what's posted right now, I think everyone but Bob is pulling your leg a little:
1 + x^2 + x^3 /. x -> 0– Bob Hanlon 40 mins ago
But this will set all the terms with a factor of
x to the first power to zero, too, which fits with the original question but not the comment.
The thing to keep in mind about replacement rules is that whatever subexpression matches the pattern on the left-hand is replaced by the corresponding expression on the left-hand side. As expression-tree transformations, they sometimes do not behave quite like the algebra transformations one might be used to. For instance, you cannot replace the factor of
x^3, because as an expression,
x^3 does not contain
Power[x, 3]. There's no
2 and certainly not
Power[x, 2]. What's more troublesome is that
x^2 * x automatically becomes
x^3 inside Mathematica, unless you do some fancy things to interfere with the normal evaluation of expressions.
The point is that sometimes there are functions like
PolynomialMod that are more appropriate for doing algebra than replacement rules.
I think that what you are looking for is first order series expansion wrt
1 + x^2 + x^3; % + O[x]^2 (*1 + O[x]^2*) a + b x + c y + d z + e x^2 + f x^2 y + g z^2 + h x^3 z + k x y z + l x^2^2 z^2; % + O[x]^2 (*(a + c y + d z + g z^2) + (b + k y z) x + O[x]^2 *)
O[x]^2 (conversion from
SeriesData) can be eliminated by applying