octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #61199] Allow 'char' input sets to nchoosek fo


From: Rik
Subject: [Octave-bug-tracker] [bug #61199] Allow 'char' input sets to nchoosek for Matlab compatibility
Date: Fri, 24 Sep 2021 18:05:05 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36

Follow-up Comment #24, bug #61199 (project octave):

@Anonymous: Matlab gives no warnings for nchoosek (54,27) and nchoosek
(56,28).  The results are the same for Matlab and for unpatched Octave, so it
is not clear that the improved code with gcd() is necessary for these cases.

In Matlab, nchoosek (58,29) does produce a warning.  Specifically, "Warning:
Result may not be exact.  Coefficient is greater than 9.007199e15 and is only
accurate to 15 digits.

The result is the same in either Matlab or Octave


format long
z = nchoosek (58,29)
z = 3.006726649954106e+16
+verbatim-

With the patched code that uses gcd() the answer differs by 2 in the last
position


z = 3.006726649954104e+16


There are some differences.  For Matlab and Octave unpatched code,


nchoosek (56,26)
ans = 6.646448384109071e+15


BUT, for patched code


nchoosek (56,26)
ans = 6646448384109072


There is a difference of 1 in the final position.  This is correct as the
answer should be even.  But, is it worth it?  eps (6.646448384109071e+15) is 1
so essentially the current calculation is within the error bar for a numerical
approximation.  I don't have much of an opinion here.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61199>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]