Skip to main content
Tweeted twitter.com/StackMma/status/774498720851296256
edited tags
Link
Alexey Popkov
  • 62.3k
  • 7
  • 154
  • 375
added 112 characters in body
Source Link
GambitSquared
  • 2.3k
  • 1
  • 16
  • 23
$MachineEpsilon
x = 0.0000000000000001
% + 1
% - 1

As expected the final result equals zero, since x < MachineEpsilon ($2.22045\times10^{-16}$).

However, if I double x (to 0.0000000000000002), then the final result should in my understanding still be zero, since x is still smaller than the MachineEpsilon, but... to my surprise the final result isn't zero! Question: why is this?

Note 1: If I triple x (to 0.0000000000000003), then x is larger than the MachineEpsilon and indeed the final result is bigger than zero.

Note 2: On my computer the value for MachineEpsilon is $2.22045\times10^{-16}$ Is this the same as on any computer using Mathematica by the way?


EDIT: I noticed that in binary form:

  1. The MachineEpsilon is $1.\times2^{-52}$
  2. And 0.0000000000000002 is $1.1100110100101011001\times2^{-53}$

Code:

BaseForm[$MachineEpsilon, 2]
x = BaseForm[0.0000000000000002, 2]
% + 1
BaseForm[% - 1, 2]

Therefore, could it be that $1.1100110100101011001\times2^{-53}$ is rounded up to $1.\times2^{-52}$ if $1$ is added? Which is precisely equal to the MachineEpsilon and that therefore the final result above with 0.0000000000000002 isn't zero but... the MachineEpsilon!?

$MachineEpsilon
x = 0.0000000000000001
% + 1
% - 1

As expected the final result equals zero, since x < MachineEpsilon ($2.22045\times10^{-16}$).

However, if I double x (to 0.0000000000000002), then the final result should in my understanding still be zero, since x is still smaller than the MachineEpsilon, but... to my surprise the final result isn't zero! Question: why is this?

Note 1: If I triple x (to 0.0000000000000003), then x is larger than the MachineEpsilon and indeed the final result is bigger than zero.

Note 2: On my computer the value for MachineEpsilon is $2.22045\times10^{-16}$ Is this the same as on any computer using Mathematica by the way?


EDIT: I noticed that in binary form:

  1. The MachineEpsilon is $1.\times2^{-52}$
  2. And 0.0000000000000002 is $1.1100110100101011001\times2^{-53}$

Therefore, could it be that $1.1100110100101011001\times2^{-53}$ is rounded up to $1.\times2^{-52}$ if $1$ is added? Which is precisely equal to the MachineEpsilon and that therefore the final result above with 0.0000000000000002 isn't zero but... the MachineEpsilon!?

$MachineEpsilon
x = 0.0000000000000001
% + 1
% - 1

As expected the final result equals zero, since x < MachineEpsilon ($2.22045\times10^{-16}$).

However, if I double x (to 0.0000000000000002), then the final result should in my understanding still be zero, since x is still smaller than the MachineEpsilon, but... to my surprise the final result isn't zero! Question: why is this?

Note 1: If I triple x (to 0.0000000000000003), then x is larger than the MachineEpsilon and indeed the final result is bigger than zero.

Note 2: On my computer the value for MachineEpsilon is $2.22045\times10^{-16}$ Is this the same as on any computer using Mathematica by the way?


EDIT: I noticed that in binary form:

  1. The MachineEpsilon is $1.\times2^{-52}$
  2. And 0.0000000000000002 is $1.1100110100101011001\times2^{-53}$

Code:

BaseForm[$MachineEpsilon, 2]
x = BaseForm[0.0000000000000002, 2]
% + 1
BaseForm[% - 1, 2]

Therefore, could it be that $1.1100110100101011001\times2^{-53}$ is rounded up to $1.\times2^{-52}$ if $1$ is added? Which is precisely equal to the MachineEpsilon and that therefore the final result above with 0.0000000000000002 isn't zero but... the MachineEpsilon!?

added 394 characters in body
Source Link
GambitSquared
  • 2.3k
  • 1
  • 16
  • 23
$MachineEpsilon
x = 0.0000000000000001
% + 1
% - 1

As expected the final result equals zero, since x < MachineEpsilon ($2.22045\times10^{-16}$).

However, if I double x (to 0.0000000000000002), then the final result should in my understanding still be zero, since x is still smaller than the MachineEpsilon, but... to my surprise the final result isn't zero! Question: why is this?

Note 1: If I triple x (to 0.0000000000000003), then x is larger than the MachineEpsilon and indeed the final result is bigger than zero.

Note 2: On my computer the value for MachineEpsilon is $2.22045\times10^{-16}$ Is this the same as on any computer using Mathematica by the way?


EDIT: I noticed that in binary form:

  1. The MachineEpsilon is $1.\times2^{-52}$
  2. And 0.0000000000000002 is $1.1100110100101011001\times2^{-53}$

Therefore, could it be that $1.1100110100101011001\times2^{-53}$ is rounded up to $1.\times2^{-52}$ if $1$ is added? Which is precisely equal to the MachineEpsilon and that therefore the final result above with 0.0000000000000002 isn't zero but... the MachineEpsilon!?

$MachineEpsilon
x = 0.0000000000000001
% + 1
% - 1

As expected the final result equals zero, since x < MachineEpsilon.

However, if I double x, then the final result should in my understanding still be zero, since x is still smaller than the MachineEpsilon, but... to my surprise the final result isn't zero! Question: why is this?

Note 1: If I triple x, then x is larger than the MachineEpsilon and indeed the final result is bigger than zero.

Note 2: On my computer the value for MachineEpsilon is $2.22045\times10^{-16}$ Is this the same as on any computer using Mathematica by the way?

$MachineEpsilon
x = 0.0000000000000001
% + 1
% - 1

As expected the final result equals zero, since x < MachineEpsilon ($2.22045\times10^{-16}$).

However, if I double x (to 0.0000000000000002), then the final result should in my understanding still be zero, since x is still smaller than the MachineEpsilon, but... to my surprise the final result isn't zero! Question: why is this?

Note 1: If I triple x (to 0.0000000000000003), then x is larger than the MachineEpsilon and indeed the final result is bigger than zero.

Note 2: On my computer the value for MachineEpsilon is $2.22045\times10^{-16}$ Is this the same as on any computer using Mathematica by the way?


EDIT: I noticed that in binary form:

  1. The MachineEpsilon is $1.\times2^{-52}$
  2. And 0.0000000000000002 is $1.1100110100101011001\times2^{-53}$

Therefore, could it be that $1.1100110100101011001\times2^{-53}$ is rounded up to $1.\times2^{-52}$ if $1$ is added? Which is precisely equal to the MachineEpsilon and that therefore the final result above with 0.0000000000000002 isn't zero but... the MachineEpsilon!?

added 3 characters in body; edited body; added 19 characters in body; added 10 characters in body
Source Link
GambitSquared
  • 2.3k
  • 1
  • 16
  • 23
Loading
Source Link
GambitSquared
  • 2.3k
  • 1
  • 16
  • 23
Loading