Post Reply 
HP 12C Permutation and Combination
08-24-2017, 10:29 AM (This post was last modified: 08-24-2017 10:33 AM by Dieter.)
Post: #26
RE: HP 12C Permutation and Combination
(08-24-2017 08:11 AM)Gamo Wrote:  deluxe version fix the problem

The compact version does so either.

Re. your suggestion of setting the display to FIX 0, i.e. rounding the result to the nearest integer: as already mentioned, this does not guarantee a correct result as the error may be as large as one unit in the 9th digit. But if factorials are used the domain for n and r is limited to 0...69 so there there is only a limited number of possible combinations. A test with n=1...69 and r=1...n showed that the worst case is P(64, 5) which is returned as 914941440,4 when calculated with factorials. So rounding to the nearest integer may actually work ...for results < 1E+9.

However, there may be errors in the last digit where rounding to the nearest integer does not work as the result already is a 10-digit integer. Take the example P(25, 7). It is returned as 25!/18! = 2422727999. The same is true for P(29, 7), for P(41, 6) etc. etc. Rounding to the nearest integer will not change anything as the result already is an integer. #-)

If you do the rounding by means of the usual procedure "0,5 + INTG" this will increase a 10-digit integer by 1 (thus returning a correct result for P(25, 7)), but already accurate 10-digit results will be increased as well, which again leads to an error. Results which are 1 unit high will even increase their error. For instance P(42, 6) yields 42!/36! = 3776965921 instead of ...920. Numerical rounding would change this to ...922. Or P(45, 6) is calculated as 45!/39! = 5864443202 which is even 2 ULP high. So rounding, either by setting FIX 0 or numerically, does not fix the problem.

Use one of the recent two programs and at least up to 1E+10 the results should be fine. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP 12C Permutation and Combination - Gamo - 08-15-2017, 04:54 AM
RE: HP 12C Permutation and Combination - Dieter - 08-24-2017 10:29 AM



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