msg258218 - (view) |
Author: Brett Cannon (brett.cannon) *  |
Date: 2016-01-14 20:35 |
If you look Modules/mathmodule.c you will notice there is a comment that goes with erf() and erfc() stating that the algorithms were taken from a book entitled 'Numerical Recipes'. Unfortunately that book has a license dictating that any information from the book is only allowed for non-commercial use; commercial use requires negotiating a license (http://numerical.recipes/aboutNR3license.html). That's bad for anyone who has a commercial distribution of Python as that's a special requirement they have to follow. It would be best to do a clean room implementation of both math.erf() and math.erfc() that does not use information from 'Numerical Recipes' in order to not be violating that license. That way Python can be sold commercially without having to negotiate a separate license just for those two functions. Unfortunately this code exists since at least Python 2.7, so I have flagged all Python releases as needing the eventual clean room implementation applied to it (although Python 3.2 goes out of security maintenance next month so I don't know how critical it is to fix that far back). |
|
|
msg258279 - (view) |
Author: Mark Dickinson (mark.dickinson) *  |
Date: 2016-01-15 08:47 |
The comment is unfortunate. The code in Modules/mathmodule.c *was* written from scratch (by me). All I took from Numerical Recipes was the idea of using continued fractions from one part of the domain and a power-series expansion for another part. If you compare the code with the NR code, there's really no similarity beyond that part. Perhaps just deleting the NR reference is the way to go. |
|
|
msg258280 - (view) |
Author: Mark Dickinson (mark.dickinson) *  |
Date: 2016-01-15 09:05 |
... and the way I read it, the NR licence applies specifically to their code, not to the basic numerical ideas set out in the text (which is all we're using). We're not using the actual code from NR at all. IOW, IANAL but I really don't think there's an issue here. |
|
|
msg258281 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-01-15 09:06 |
erf() is a part of C99. May be move hand-writen implementation to Modules/_math.c and use libc erf() if available? |
|
|
msg258283 - (view) |
Author: Marc-Andre Lemburg (lemburg) *  |
Date: 2016-01-15 09:20 |
On 15.01.2016 10:05, Mark Dickinson wrote: > > Mark Dickinson added the comment: > > ... and the way I read it, the NR licence applies specifically to their code, not to the basic numerical ideas set out in the text (which is all we're using). We're not using the actual code from NR at all. > > IOW, IANAL but I really don't think there's an issue here. The license is a copyright license, so it only applies to the actual code from the book. The ideas would have to be patented to be protected. Copyright in some code or text is not enough to (potentially) prevent someone else from reusing the ideas. If someone is aware of a patent on the algorithm, we may have an issue. Otherwise, there's no issue if we're using Mark's implementation. |
|
|
msg258284 - (view) |
Author: Mark Dickinson (mark.dickinson) *  |
Date: 2016-01-15 09:20 |
@Serhiy: Sure, that would work (the same way that we do for log1p). I *think* I tried this at the time, but it turns out that some libm implementations of erf and erfc are pretty bad, so our tests failed. (But I may be misremembering.) In any case, the proposal to use the libm erf/erfc should be a separate issue, I think. |
|
|
msg258305 - (view) |
Author: Brett Cannon (brett.cannon) *  |
Date: 2016-01-15 16:28 |
Thanks for the historical information, Mark! I'll either update the comment or flat-out delete it so it doesn't trip anyone else up. I'll also scale back the scope of the update since it's just a cleanup and not an IP issue. |
|
|
msg258311 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-01-15 17:39 |
New changeset 76eb752e5447 by Brett Cannon in branch '3.5': Issue #26114: Remove a reference to 'Numerical Recipes'. https://hg.python.org/cpython/rev/76eb752e5447 New changeset 8ad701463cd7 by Brett Cannon in branch 'default': Merge for issue #26114 https://hg.python.org/cpython/rev/8ad701463cd7 |
|
|
msg258312 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-01-15 17:41 |
New changeset faac8f09020d by Brett Cannon in branch '2.7': Issue #26114: Remove mention of 'Numerical Recipes'. https://hg.python.org/cpython/rev/faac8f09020d |
|
|
msg258384 - (view) |
Author: Terry J. Reedy (terry.reedy) *  |
Date: 2016-01-16 11:46 |
Some additional history: the original 1986 book has separate copyright notices for text (Cambridge U Press), and computer programs (Numerical Recipes Software). It also has an offer to sell diskettes (Fortran or Pascal), 15 pounds each. There is no additional license statements that I can see, even for the disks. I vaguely remember that there was some upset or controversy when a 'license' was added to the 2nd edition. The copyrighted but license-free erf and erfc functions on p. 164) use the incomplete gamma functions, which use continued fractions and series for different subdomains. Applied Statistics algorithm AS 66 (about 1973), for normal integrals, appears to directly use series and continued fractions for different subdomains. It is based on a similar algorithm from 1969. Both series and continued fraction expansions for erf/normal-integral were known well before that. |
|
|