Finding Epsilon & Smallest Floating Point - Python

In summary, programmers have written routines to test for the machine epsilon using various programming languages.
  • #1
BubblesAreUs
43
1
I'm finding it difficult to find the exact value of epsilon on python? Moreover, I am also supposed to find the smallest floating point number as well.

Wikipedia tells me that the machine epsilon is 2−52 ≈ 2.22e-16 for 64-bit
IEEE 754 - 2008? Is this the exact value on Python?

Outside of that, I'm not sure where to start.
 
Technology news on Phys.org
  • #2
BubblesAreUs said:
I'm finding it difficult to find the exact value of epsilon on python? Moreover, I am also supposed to find the smallest floating point number as well.

Wikipedia tells me that the machine epsilon is 2−52 ≈ 2.22e-16 for 64-bit
IEEE 754 - 2008? Is this the exact value on Python?

Outside of that, I'm not sure where to start.
Programmers have written routines to test for the machine epsilon using various programming languages. You could probably do a Google search and find either a routine or a description of one to use in Python.
 
  • #3
BubblesAreUs said:
I'm finding it difficult to find the exact value of epsilon on python? Moreover, I am also supposed to find the smallest floating point number as well.

Wikipedia tells me that the machine epsilon is 2−52 ≈ 2.22e-16 for 64-bit
IEEE 754 - 2008? Is this the exact value on Python?

Outside of that, I'm not sure where to start.
In Python v3.4.2, epsilon is 2.220446049250313e-16. The float_info member of the sys module contains this information.
 
  • #4
Mark44 said:
In Python v3.4.2, epsilon is 2.220446049250313e-16. The float_info member of the sys module contains this information.
I just tried out sys. and got the following:

>>> sys.float_info.epsilon
2.220446049250313e-16
>>> sys.float_info.min
2.2250738585072014e-308

I am looking for the smallest floating point number. Oddly, I was expecting the smallest floating point number to be greater than machin epsilon.

PS: Will try that out as well SteamKing.
 
  • #5
BubblesAreUs said:
I am looking for the smallest floating point number. Oddly, I was expecting the smallest floating point number to be greater than machin epsilon.
Machine epsilon and the smallest floating point number are different things.
From the Python docs:
epsilon - difference between 1 and the least value greater than 1 that is representable as a float
min - minimum positive normalized float
 
  • #6
Mark44 said:
Machine epsilon and the smallest floating point number are different things.
From the Python docs:
epsilon - difference between 1 and the least value greater than 1 that is representable as a float
min - minimum positive normalized float
Oh that makes sense. Now what I even more puzzling is that I'm supposed to find a min floating point such that, it plus 1 should not return 1. Interestingly, the output I am getting when adding min float and 1 is 1.
 
  • #7
BubblesAreUs said:
Oh that makes sense. Now what I even more puzzling is that I'm supposed to find a min floating point such that, it plus 1 should not return 1. Interestingly, the output I am getting when adding min float and 1 is 1.
That's really not that surprising. The smallest positive number that you can add to 1, and still get 1, is machine epsilon, which is many orders of magnitude larger than min.
 
  • #8
BubblesAreUs said:
... I'm supposed to find a min floating point...
Why are we dealing with homework in this forum?
 
  • Like
Likes jim mcnamara
  • #9
MrAnchovy said:
Why are we dealing with homework in this forum?
Good point.
@BubblesAreUs, this should have been posted in the Homework & Coursework section, under Engineering & Computer Science. For future posts of this nature, please put them in that forum section.
 

1. What is the concept of finding epsilon in Python?

Finding epsilon in Python involves determining the smallest possible number that can be represented as a floating point value. This value is used to determine the precision of floating point calculations in Python.

2. How is epsilon calculated in Python?

Epsilon is typically calculated by dividing 1 by the smallest possible floating point number that can be represented in Python. This value can vary depending on the computer's architecture and the specific version of Python being used.

3. Why is finding epsilon important in scientific calculations?

Finding epsilon is important because it allows for more accurate and precise calculations in scientific applications. It helps to minimize rounding errors and ensure that calculations are as close to the true value as possible.

4. How can I use the sys.float_info module to find epsilon in Python?

The sys.float_info module can be used to access the smallest possible floating point number (sys.float_info.epsilon) and the number of digits of precision (sys.float_info.dig) for a specific Python environment.

5. Are there any limitations to using epsilon in Python?

While finding epsilon can improve the accuracy of floating point calculations, it is not a perfect solution. There may still be some rounding errors and limitations in representing certain numbers, particularly very large or very small ones. It is important to be aware of these limitations when using epsilon in scientific calculations.

Similar threads

  • Programming and Computer Science
Replies
32
Views
1K
  • Computing and Technology
Replies
4
Views
764
Replies
4
Views
927
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
6
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
3K
  • Programming and Computer Science
Replies
1
Views
953
  • Programming and Computer Science
Replies
2
Views
8K
  • Programming and Computer Science
Replies
2
Views
3K
Back
Top