How to Calculate Epsilon

Techwalla may earn compensation through affiliate links in this story. Learn more about our affiliate and product review process here.
Machine epsilon provides information about the computations that computers can make.

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.

Advertisement

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.

Video of the Day

Step 2

Initialize a variable to be equal to 1. In pseudocode, this will look like

Advertisement

x -> 1.

Step 3

Divide the initialized value by 2, and add that to 1. In pseudocode, this looks like

y -> x/2 + 1.

Advertisement

Step 4

Add a conditional statement, such that if y is less than 2, set

Advertisement

x -> x/2,

and repeat the step

Advertisement

y -> x/2 + 1.

Once the condition that y is greater than 2 is met, the resulting number is machine epsilon.

Video of the Day

Advertisement

Advertisement

references