Chop
Examples
open all close allBasic Examples (1)
Scope (2)
Applications (2)
Test if two numbers are the same to a certain tolerance:
x = N[Pi];
r = Rationalize[x, 10 ^ -12]They are the same to the default tolerance of
:
Chop[x - r] === 0They are not the same to the tolerance of
:
Chop[x - r, 10 ^ -14] === 0Eliminate very small terms before comparing with Equal:
list = {0, 0, 1, 0, 0};
identity = FourierDCT[FourierDCT[{0, 0, 1, 0, 0}, 2], 3]They are not equal because a small number is not equal to zero:
list == identityOnce the small terms are eliminated, equality holds:
list == Chop[identity]Properties & Relations (1)
A functional implementation of Chop:
chop[xa_, dxa_ : 10 ^ -10] := Module[{ch},
ch[x_Real, dx_] := If[Abs[x] < dx, 0, x];
ch[Complex[r_, i_], dx_] := ch[r, dx] + I ch[i];
ch[x_ ? AtomQ, dx_] := x;
ch[x_, dx_] := Map[ch[#, dx]&, x];
ch[xa, dxa]
]e = f[$MachineEpsilon, 1. + 2. x + 3. 10 ^ -12 x ^ 2]chop[e]Chop[e]Chop is much faster for large expressions:
x = ConstantArray[0., 10 ^ 6];
x[[1]] = 1.;y = Fourier[InverseFourier[x]];Timing[Chop[y] == x]Timing[chop[y] == x]Possible Issues (1)
Machine complex numbers have machine reals for both real and imaginary parts:
2. IConsequently, Chop does not make the real part of machine complex numbers an exact zero:
Chop[10. ^ -12 + 2. I]Small imaginary parts from machine complex numbers are eliminated to make a machine real:
Chop[2. + 10. ^ -12 I]See Also
Threshold Rationalize Round Clip Accuracy Floor IntegerPart N Precision SetPrecision
Function Repository: IntegerChop
Tech Notes
Related Guides
History
Introduced in 1988 (1.0)
Text
Wolfram Research (1988), Chop, Wolfram Language function, https://reference.wolfram.com/language/ref/Chop.html.
CMS
Wolfram Language. 1988. "Chop." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Chop.html.
APA
Wolfram Language. (1988). Chop. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Chop.html
BibTeX
@misc{reference.wolfram_2026_chop, author="Wolfram Research", title="{Chop}", year="1988", howpublished="\url{https://reference.wolfram.com/language/ref/Chop.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_chop, organization={Wolfram Research}, title={Chop}, year={1988}, url={https://reference.wolfram.com/language/ref/Chop.html}, note=[Accessed: 12-June-2026]}