How can I chop this expression?

After some long calculations, Mathematica gives me this output:

−0.11728G121−0.0692416G1G2−0.000011728G222-0.11728 \, G_1^{\phantom{1}2} – 0.0692416\, G_1\, G_2 – 0.000011728 G_2^{\phantom{2}2}

where G1 and G2 are two coefficients whose value I don’t know, but I know that it must be integers and in the range (0; 10) (extremes excluded).

The last term is much smaller than the other two: how can I get rid of it? Chop doesn’t work here since it only deals with numerical expressions.




Try Chop[expr, 1.*^-4].
– J. M.♦
Oct 10 at 13:34



Note that the last term can be the major term in the range given, e.g., if G1 = 0.001, G2 = 9.
– Michael E2
Oct 10 at 15:19



Sorry, you are right, but I forgot to write that the coefficients must be integers.
– mattiav27
Oct 10 at 15:29



No. As I have written, extremes are excluded.
– mattiav27
Oct 11 at 7:32



Oh gosh. Somehow I read it several times as “included.” Not sure how that happened. Sorry for that. (You should use @Michael E2 to make sure I’m notified.)
– Michael E2
Oct 11 at 22:42


2 Answers


If you want to apply Chop to just the numerical expressions you can use a Rule with a Condition that the subject is a number:

delta = 0.01;
rule = x_ :> Chop[x, delta] /; NumericQ[x]

exp = -1.2 G1^2 – 0.02 G1 G2 – 0.000011 G2^2;

exp /. rule

-1.2 G1^2 – 0.02 G1 G2

Chop accepts a second argument and appears to work only on numerical parts of an expression:

expr = -0.11728 G1^2 – 0.0692416 G1 G2 – 0.000011728 G2^2;

Chop[expr, 10^-3]

-0.11728 G1^2 – 0.0692416 G1 G2



+1. You could even quote the docs to support your edit: “Chop[expr] replaces approximate real numbers in expr that are close to zero by the exact integer 0.”
– Michael E2
Oct 11 at 23:03