How to Calculate Epsilon

By Thomas Bourdin

Epsilon, or machine epsilon, is an important number in computing. Machine epsilon gives the distance between 1 and the next largest floating point number on your computer. This is important to calculate, as the size of the floating point number may lead to round-off errors for certain calculations. Calculating machine epsilon can be done a number of ways, and many programming languages have built-in functions that can determine this value. However, it also can be determined algorithmically with a fairly simple routine.

Things You'll Need

  • Computer with programming language of your choice

Step 1

Choose a programming language to program the algorithm in. Make sure you understand the language's syntax well enough to make a simple program within the language.

Step 2

Initialize a variable to be equal to 1. In pseudocode, this will look likex -> 1.

Step 3

Divide the initialized value by 2, and add that to 1. In pseudocode, this looks likey -> x/2 + 1.

Step 4

Add a conditional statement, such that if y is less than 2, set x -> x/2, and repeat the stepy -> x/2 + 1.Once the condition that y is greater than 2 is met, the resulting number is machine epsilon.