11-03-2016, 10:53 PM

Here's a short program that calculates the machine epsilon of the HP Prime calculator. The square root of the machine epsilon is often used for the convergence criterion for iterative algorithms such as root finders, numerical integrators, etc.

EXPORT meps()

// machine epsilon of the HP Prime

// epsilon is that number when added to one

// is still one according to the calculator

///////////////////////////////////////////

BEGIN

LOCAL x;

x := 1.0;

WHILE ((1.0 + x) > 1.0) DO

x := x / 2.0;

END;

PRINT;

PRINT("machine epsilon = " + x);

print(" ");

print("1 + epsilon = " + (1.0 + x));

END;

Here are the results for the HP Prime. The second calculation verifies the computed value by adding it to the number one and printing the result.

machine epsilon = 3.63797880705ᴇ−12

1 + epsilon = 1

EXPORT meps()

// machine epsilon of the HP Prime

// epsilon is that number when added to one

// is still one according to the calculator

///////////////////////////////////////////

BEGIN

LOCAL x;

x := 1.0;

WHILE ((1.0 + x) > 1.0) DO

x := x / 2.0;

END;

PRINT;

PRINT("machine epsilon = " + x);

print(" ");

print("1 + epsilon = " + (1.0 + x));

END;

Here are the results for the HP Prime. The second calculation verifies the computed value by adding it to the number one and printing the result.

machine epsilon = 3.63797880705ᴇ−12

1 + epsilon = 1