# Is there a way to globally set when to treat a very small number as zero?

I understand that I can use Chop to force a very small number to be treated as 0 and can use PossibleZeroQ to as a way to test whether such a number might effectively be 0, but applying Chop every time a small number is close to zero in order to "make it be" zero is tedious and error prone; while PossibleZeroQ seems to have its own ideas about what constitutes 0.

Are there global settings that will let me

• treat every number smaller than some specified value as 0, effectively applying Chop automatically to all results; and
• specify how large a number PossibleZeroQ should recognize as 0?
• There is a system option controlling the maximum difference when treating close inexact numbers as equal. But I can't find it now ... should be somewhere in SystemOptions Commented Nov 13, 2012 at 18:59
• @Szabolcs and raxa: you're probably looking for Internal$EqualTolerance. – rm -rf Commented Nov 13, 2012 at 19:11 • @rm-rf: That looks interesting. There's no help on it though, and its value (2.10721) is cryptic. Commented Nov 13, 2012 at 19:16 • Regarding the first point: What about $Post=Chop? Commented Nov 13, 2012 at 19:30
• And note that Chop can tale a second argument specifying the tolerance. So you might want to use something like $Post = Chop[#, 10^-13]&. Commented Nov 13, 2012 at 22:04 ## 1 Answer As was pointed out in the comments, $Post is a way to go here. Take as an example:

FourierDCT[FourierDCT[{0, 0, 1, 0, 0}, 2], 3]

(*{0., -5.55112*10^-17, 1., 1.38778*10^-17, 1.38778*10^-17}*)


Now lets set $Post to Chop with tolerance 10^-13. $Post = Chop[#, 10^-13] &;


This will apply the Chop function to every output thereafter.

FourierDCT[FourierDCT[{0, 0, 1, 0, 0}, 2], 3]

(*{0, 0, 1., 0, 0}*)


If you want to make this behavior semi-permanent, you can set $Post in any one of your init.m files. A good choice might be the one located at $InstallationDirectory <> "\\SystemFiles\\Kernel\\Packages\\init.m"


If you do this and want to not Chop for a particular output you can always clear $Post or remove this from init.m` and restart the kernel. • Andy Ross ,Does$Post = Chop[#, 10^-13] &; really take away the digits smaller than 10^-13? I find that those digits still exist by Print[MatrixForm[FourierDCT[FourierDCT[{0, 0, 1, 0, 0}, 2], 3]]]; Commented May 7, 2013 at 5:33
• @novice this is a very good question that I don't immediately know the answer to. I suggest posting it as a question. Commented May 7, 2013 at 14:00