Machine epsilon of the HP Prime

09172022, 04:28 PM
Post: #1




Machine epsilon of the HP Prime
// program mach_eps HP Prime
// September 17, 2022 // machine epsilon of the HP Prime // From Wikipedia; // "Machine epsilon or machine precision is an upper bound // on the relative approximation error due to rounding in // floating point arithmetic. This value characterizes // computer arithmetic in the field of numerical analysis, // and by extension in the subject of computational science." ///////////////////////////////////////////////////////////// export mach_eps() begin local epsmach; local one := 1.0; local two := 2.0; local u := 1.0; repeat u := u / two; until ((one + u) = one); epsmach := u; print(); print("machine epsilon of the HP Prime"); print("\neps = " + epsmach); print("\n1.0 + eps = " + (1.0 + epsmach)); end; 

09172022, 05:28 PM
Post: #2




RE: Machine epsilon of the HP Prime
I suspect Home mode and CAS mode have different epsilons...
Bob Prosperi 

09182022, 08:11 AM
Post: #3




RE: Machine epsilon of the HP Prime
I fear there might be a couple of problems with this approach...
I should say that I'm taking machine epsilon to be the same as a unit in the last place (an ULP). If that's wrong, please tell me! First, I would have thought the correct value of epsilon is not the final u, but the one before that. Second, on a binary machine with correct rounding, we can add half an ULP and find that it makes a difference, because half an ULP may round upwards. So, in the case of BBC Basic with a 32 bit mantissa, the program as written returns 2^33 as the epsilon, whereas I think the right answer is 2^31. (Actually, I'm thinking now that even a decimal machine with correct rounding should round up when half an ULP is added... but then again, in this sense I think I'd have to say the majority of HP machines don't tend to round this way. With a decimal machine, halving the candidate epsilon each time might be asking for trouble: at the very least, the final epsilon found will be close to a power of two, but it ought to be an exact power of ten.) 

09182022, 12:20 PM
(This post was last modified: 09182022 02:41 PM by Albert Chan.)
Post: #4




RE: Machine epsilon of the HP Prime
(09182022 08:11 AM)EdS2 Wrote: BBC Basic with a 32 bit mantissa, the program as written returns 2^33 as the epsilon, Your "right" answer was the variant definition, machine epsilon = ULP of 1. 1. = 2^31 ULP → ε = ULP = 2^31 OP use formal definition, u = ε/2 = 2^32 Roundtonearest, halfwaytoeven, 1. + u == 1., for any even base >>> from gmpy2 import * >>> get_context().precision = 32 # binary32 >>> one = mpfr(1) >>> one + 2**31 # 1 + ε mpfr('1.0000000005',32) >>> one + 2**32 # 1 + u mpfr('1.0',32) 10digits decimal, correct rounding: C:\> rpn =10 1e9 1+ 1.000000001 C:\> rpn =10 1e9 2/ 1+ 1 

09192022, 06:31 AM
Post: #5




RE: Machine epsilon of the HP Prime
Ah, thanks, so I may not be fully compliant, but I am a recognised variant!
Quote:This alternative definition is much more widespread outside academia: machine epsilon is the difference between 1 and the next larger floating point number. This, also from the Wikipedia page, seems to me to cast doubt on this approach: Quote:The following simple algorithm can be used to approximate the machine epsilon, to within a factor of two (one order of magnitude) of its true value, using a linear search.(Emphasis added) 

09192022, 01:05 PM
Post: #6




RE: Machine epsilon of the HP Prime
(09172022 05:28 PM)rprosperi Wrote: I suspect Home mode and CAS mode have different epsilons... Indeed, I think they should! See for example Joe Horn's explanation: (10232015 05:41 AM)Joe Horn Wrote:(10232015 02:35 AM)luc4as Wrote: When I try to calculate 3.6^24*3.24 in CAS mode, the calculator doesn't return 0, which is the correct answer. Home mode calculates it just fine. 

09202022, 11:24 AM
Post: #7




RE: Machine epsilon of the HP Prime
For HP Prime, formal definition (maximum relative error) and variant definition (ulp of 1.) are the same.
CAS round number to 53 bits double (roundtonearest), then chop to 48 bits, u = maximum relative error = (1 ULP) / (2^47 ULP) = 2^47 1 = 2^47 ULP, unaffected by roundingmode. This probably made variant defintion, ε = ulp of 1., more popular. 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)