HP 12C Permutation and Combination
|
08-17-2017, 06:12 PM
Post: #10
|
|||
|
|||
RE: HP 12C Permutation and Combination
(08-17-2017 10:01 AM)Gamo Wrote: I try the same 25P7 on the HP 15C build-in functions and the result is Here is what I wrote: Quote:That's why most HPs, including the 12C, internally use 3 more digits for their calculations Both the 12C and the 15C internally (!) use 13 digits so that the final 10-digit result that is presented to the user is correct (ok, mostly). So the 15C's internal nCr and nPr functions are performed with 13 digits. This usually (but not always) gives results with at least 10 exact digits – which is what you see in the display. On the other hand user programs like the ones we're discussing here always work with only 10 digits. This can cause roundoff errors. For instance, calculating 1/3 * 3 with the usual 10 digits yields 0,99999 99999 while with 13 digits you get 0,99999 99999 999 which, after rounding to 10 display digits, shows up as "1". Internally the 15C probably calculates permutations and combinations by repeated multiplication, similar to the method in the thread I linked to. We can safely assume that it does not call the factorial routine. This means that C(25, 7) is almost certainly not calculated by first evaluating 1 · 2 · 3 · ... · 25, then 1 · 2 · 3 · ... · 18 and finally 1 · 2 · 3 · ... · 7 and then determining the permutations from these three. Take a look at the linked thread and you get an impression of how it can (and should) be done: 25 / 1 · 24 / 2 · 23 / 3 · 22 / 4 · 21 / 5 · 20 / 6 · 19 / 7 = 480700. With this method all intermediate results are integers so that roundoff errors are minimized. Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)