Torture tests: what do they mean?
|
05-15-2014, 11:01 PM
Post: #27
|
|||
|
|||
RE: Torture tests: what do they mean?
(05-15-2014 06:01 PM)jebem Wrote: Test 1: No, not at all. Sure, the mathematically correct result is zero, but a perfectly working calculator may return this result or not. The reason simply is the fact that sqrt(6) is an irrational number so that no calculator in the world will safely return this value with a limited number of digits. All you get are the first n digits, where n=10, 12, 16 or even 34 (DP mode on a 34s). Consider this: sqrt(6) = 2,449 4897 4278 3178 0981 9728 4074... The correct 12-digit value as returned by the 50G or Prime is 2,449 4897 4278, which is more than 0,3 ULP below the true result. So if this is squared, the result is not exactly 6 but 5,999 9999 9998 443... which is rounded to ...998 and thus 2 E–11 low. If the root would have been calculated as 2,449 4897 4279 (next adjacent value), its square would be 6,000 0000 0003 34... which is even 3 E–11 high. There simply is no 12-digit value for sqrt(6) which, if squared, would return exactly 6 (not even when rounded to 12 digits). Now take another look at the sqrt(6) value. You will notice that it rounds very nicely to 16 digits, since the following 17th digit is a zero. This is the reason why the 34s even in SP mode (i.e. 16 digit working precision) happens to return sqrt(6)^2 as 6. It's not some "super precision" algorithm, it's simply the fact that the 17th digit happens to be a zero. You could do the same on any correctly working low-precision 6-digit machine: 2,44949² = 6,00000. There's no magic at work. Or try the same calculation with sqrt(5) on a 50G or Prime – you'll get a plain zero, simply because sqrt(5) happens to round very well to 12 digits. Let's take an even closer look at this with some basic calculus. The first derivative of x² is 2x, so if the correctly rounded root can be off by 5 E–12, the square may be off by 2 · sqrt(6) · 5 E–12 = 2,45 E–11 or more than 2 ULP. Which is exactly what you see in the above results. Quote:Test 2: This is what you will get on any calculator using 17 or more digits. So the usual 12-digit calculators won't return this result, nor does the 34s in SP mode (returns 700). In DP mode with 34 digits you'll get the 720. As you will on any other correctly working machine with at least 17 significant digits. Again: there's no magic at work. Replace the 10^15 with 10^40 and even the 34s in DP mode won't cut it. Replace it with 10^10 and any 12-digit machine will get a 720 as well. In general, if the power is 10^n, any machine with n+2 digits working precision will do the trick. Quote:Do we have here at least two different schools of algorithms, or is it just a matter of limited number of internal digits on HP machines? You should be able to answer this question now. ;-) Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)