# MATLAB Machine Epsilon

This tutorial demonstrates the machine epsilon in MATLAB.

## MATLAB Machine Epsilon

Machine Precision, also known as the Machine Epsilon, is the characteristic of double precision arithmetic numbers. These double precision numbers are standard IEEE 754 used by MATLAB to store floating point numbers which are the approximates for the real numbers.

The definition for the Machine Epsilon is the maximal possible relative error of the floating point representation depending on the numbers of the bits of mantissa. Mathematically, for t-bits of mantissa rounded according to the following equation: The Machine Epsilon for this equation is: The Machine Epsilon always depends on the implementation. The calculation precision is always limited on the hardware side by the size of the registers used for calculation.

The calculation precision is limited by the data types used to represent the floating point numbers on the software side. A double precision number is coded as 64 bits according to IEEE 754 standards, so the lower the Machine Epsilon is, the greater the relative precision calculation.

Mostly, the Machine Epsilon is used to study the effect of rounding error. MATLAB has its own `eps` method to calculate the machine epsilon; we tried an example where both MATLAB and a user-defined epsilon are compared:

``````macheps = double(1.0);
previous_macheps = macheps;

while(1 < (1 + macheps))
previous_macheps = macheps;
macheps = macheps / 2;
end

disp('Our macheps function: ');
disp(previous_macheps);

disp('Built-in MATLAB macheps function: ');
disp(eps);
``````

The code above calculates the Machine Epsilon using a user-defined method and built-in MATLAB function `eps`. See output:

``````Our macheps function:
2.2204e-16

Built-in MATLAB macheps function:
2.2204e-16

``````