# Preventing Mathematica from considering small values to be equal to zero [duplicate]

In my calculations I have a variable (say z) which can be an argument of Log, say, z Log[z].

Under some conditions, z = x-y, where:

x = a + c;
y = b + c;
a = 4.24835*10^-18;
b = -4.24835*10^-18;
c = 1.3956*10^18;


By default Mathematica considers both

4.24835*10^-18 == -4.24835*10^-18 == 0


and this leads to x = y = 1.3956*10^18 and, hence, z = 0 and z Log[z] = Indeterminate.

How can I prevent this and make sure it does not happen elsewhere?

• show your code please – Alrubaie Oct 5 '19 at 15:45
• Use extended precision numbers instead of machine numbers. – Carl Woll Oct 5 '19 at 16:01
• please see the edit – Ragab Zidan Oct 5 '19 at 16:21

Use extended precision numbers instead of machine numbers. Machine numbers have a precision of about 16, so subtracting a number 36 orders of magnitude smaller will not cause a change. For example:

b = 4.2483510*^-18 - 1.395650*^18;
c = -4.2483510*^-18 - 1.395650*^18;

b-c


8.496700000*10^-18

The back ticks  are used to specify the precision to use. Also, it's simpler to use *^-18 instead of * 10^-18`, as this creates the desired number directly without having to multiply the mantissa by a power of 10.

• please see the edit – Ragab Zidan Oct 5 '19 at 16:21