Numerical Recipes - Is this stuff legal?

So here is a debate question for the legal and scientific minds out there.

One of the books that constantly gets referred to in applied numerical methods is Numerical Recipes. One of the main selling points of this book is that it comes with computer code (in the latest version C++) for nearly all of the algorithms discussed.

There are two problems though. One is that the code is absolutely awful. In every version it is basically a mindless translation of the original Fortran code for each of the algorithms, and as such the code has nearly all of the typical bad design that Fortran programers seem to love. For instance it wasn’t until the latest C++ version that the authors started to use arrays indexed from 0 (as in the C convention) instead of 1 (as in the Fortran convention), despite releasing two previous editions that were supposedly “in C”.

That’s not the worst problem. The bigger problem is that the authors insist that the code in the book comes under a separate license, and that if one wants to even just type the code into their computer they need a license to do so. Even code that is in some way based on the code in the book is considered by the authors a “derived work” and also subject to licensing.

The main problem though is that the book is merely a summary of the numerical methods literature, and as such contains no novel algorithms. Worse still is that several of the algorithms are either:

Any code that’s non-novel I suspect they’re talking out of their ass with. Here’s an exercise: take some arbitrary algorithm, Google it, if you can find code examples (psedocode or otherwise) within 30 minutes it’s probably not too bad to copy it (using general discretion). Now that’s not to say you don’t have to credit them, in the comments it’s ALWAYS good to say “Adapted from Algorithm as presented by <Source>” but I highly doubt most of that stuff is novel enough to be bad evil evil bad if you copy it.

Numerical Recipes - Is this stuff legal?
So here is a debate question for the legal and scientific minds out there.

One of the books that constantly gets referred to in applied numerical methods is Numerical Recipes. One of the main selling points of this book is that it comes with computer code (in the latest version C++) for nearly all of the algorithms discussed.

There are two problems though. One is that the code is absolutely awful. In every version it is basically a mindless translation of the original Fortran code for each of the algorithms, and as such the code has nearly all of the typical bad design that Fortran programers seem to love. For instance it wasn’t until the latest C++ version that the authors started to use arrays indexed from 0 (as in the C convention) instead of 1 (as in the Fortran convention), despite releasing two previous editions that were supposedly “in C”.

That’s not the worst problem. The bigger problem is that the authors insist that the code in the book comes under a separate license, and that if one wants to even just type the code into their computer they need a license to do so. Even code that is in some way based on the code in the book is considered by the authors a “derived work” and also subject to licensing.

The main problem though is that the book is merely a summary of the numerical methods literature, and as such contains no novel algorithms. Worse still is that several of the codes are either:

  1. Trivial implementations of formulas already in the literature
  2. Codes that are based on previous public domain codes.

Their implementation of the gamma function is an example of the first, where the code is really just calculating an approximate polynomial, and all the work is in finding the fitting parameters, which are in the literature.

Their implementation of matrix diagonalisation is an example of the second, where their implementation is, by their own admission, based on the public domain libraries Eispack and Lapack.

As far as I can tell none of the algorithms used in the book are patented. At the time of writing all of the algorithms would be considered “prior art”.

My main question is whether or not the licensing model used by “Numerical recipes” would stand up to legal challenges. I think that given the dependence of “Numerical Recipies” on the previous literature, then the authors really have no claim over the “ownership” of the code in the book, except in a very narrow sense. I would think that if someone copied and modified their code for their own use, then it would be difficult to sue them for breach of copyright.

I, however, am not a lawyer. So what does everyone else think?

Calculon.

I don’t think you can patent an algorithm. Just copywrite actual code.

Also, FWIW, from the 3rd edition:

So I don’t think its true you can’t copy the code into your computer for personnel use.

Also from the book

So making your own routines with the same algorithims is kosher, you just can’t copy the actual code.

It also sounds like they give permission to copy a few routines simply without special permission, but if you want to start distributing compiled applications with the code, you need to go to their website and buy a license.

Seems kinda silly to me, since for almost all the routines coming up with your own code is trivial once you have the algorithm, but I guess if they want to copywrite it, its their right.

My understanding was that due to some recent court decisions in the US, you could patent algorithms, at least in the US. That is really not the issue here anyway.

OK, so maybe that is a little over the top. But certainly there are many restrictions on using the code. The licence text from my version of the third edition reads

So you can only use 10 routines, and then only on one computer. So if you have more than one computer, you need a book for each computer that runs the code.
If you get the book from a library, then presumably you can’t use the code. There are a number of other restictive things on exactly who you can give the code to, even when you have a license.

Calculon.

My contention though is that much of the code is based on previous codes, either public domain or otherwise, and therefore the code is not really “theirs” to copyright. Unless you only mean the literal code, in which case you can copy the code and make a few modifications. And given the awful way it is written most of the code needs some cleaning up anyway to conform to normal programming standards.

Calculon.

It doesn’t matter if the code is awful. There are plenty of awful novels out there, but you can’t just copy them legally on the grounds that they’re awful.

They don’t have a patent or copyright on the algorithms in the book. You can’t patent or copyright an idea. They only have a copyright on what they actually wrote. If you copy it letter by letter, you violate the copyright. And yes, they only have a copyright on the literal code. If you want to write new code that implements the exact same algorithm, you can. If you “clean up” the code to make it conform to your standards, then you’ve written new code. And your new code is protected by copyright, just like theirs was.

I don’t dispute that authors of code have copyright rights over that code. What annoys me about Numerical Recipes is that it looks like they have copied code / algorithms from the literature, which they do not have copywrite over. They have then made some minimal changes, and as a result claim copyright over their resulting code and more importantly any modified versions or translations into new languages. So they appear to be quite inconsistent with their application of copyright. On the one hand they seem quite free to copy code from others, but at the same time use copyright to try and claim ownership of anthing resulting from thier code.

For instance if you look at their implementation of Brent’s algorithm, which is in chapter 10, they cite as a source Brent’s book which details the algorithm. In that book he gives Algol and Fortran code for the algorithm, which is nearly identical to the Numerical recipes code. It even uses the same variable names and peculiar control statement formulations. While there are one or two cosmetic changes, the code executes in the same way. I think it unbelieveable that they would naturally create the same code just reading the algorithm, especially since the algol and Fortran code is given in the same cited work as the algorithm. Given that, what rights do the Numerical Recipes authors have over their code? Should not the copyright of the code really rest with Richard Brent (the author of the original code and designer of the algorithm). If if Brent donates that source code to the public domain, can someone else copy it and claim copyright over it?

I guess the main point is at what point does/should modified code from one source become your own code? How much do you have to change to make it your code? Or is it the case that if you start with copied code, no matter how many changes you make the copyright still rests with the original author.

The poor qulity of the code in one sense does not matter. I agree that poor quality of code does not negate a copyright claim. However in this case much of the code they claim copyright over has existed previously in other forms. So what it does mean is that there are clearly many improvements to the code that they could make to further cement their claims of copyright and functional difference from other codes. However they have not done this, instead publishing code with minimal changes from other codes. This makes is harder to take their claims of copyright seriously when their code appears based on public domain or other previous sources. In re-publishing the code they have not really added anything of value to the original code. In the cases where they have not based their code on other sources, then the code could be as awful as you like and it would not matter from a copyright standpoint.

Calculon.

Why mess around with Numerical Recipes? There are a million numerical methods textbooks out there that at least give you pseudocode. You can code it up yourself using whatever trendy language you want.

Or, you could use the codes at netlib. They’re written by world-class researchers, thoroughly tested, and free for the taking.

The question is not “are there other alternatives”. Obviously there are, although with some options there are still issues of documentation and reliability/robustness. The question I am interested in is the question of how copyright of computer code is supposed to work. Computer code is not like natural language in the sense that for many “ideas” in programming, there really aren’t that many functionally different ways to express them. So how is copyright supposed to work when we talk about copyrighting source code? This is especially problematic in the case of Numerical recipes were they both:

  1. Openly publish their source code for people to read. Closed source programs are much easier to consider since the source code there is supposedly secret, and possibly contracts or other agreements are in place to protect access to the code. However if you publish your code openly, does that have an impact on how much people can be influenced by it in writing their own code

  2. Obviously based some of their source code on previous works over which they have no copyright claim. This is where I think their attitude becomes quite inconsistent. Either you need to make significant changes to the code to gain copyright, in which case I don’t think the Numerical Recipes people deserve to have copyright over several of their codes. Or only a few changes are needed, in which case just fixing the code up to improve the programming style will mean that you don’t need any sort of license from them to use the code.

The Numerical Recipes people seem to want to have different definitions of copyright depending on what suits them. Do you think their idea of copyright and licensing would actually stand up to a legal challenge?

Calculon.

I’m not an expert on this subject, but ISTM the question raised by the OP is a derivative work problem. Notice there are two issues. One is whether the derivative work infringes the copyright of the original work. The second, assuming no infringement, is whether the derivative work is sufficiently original to support a claim of copyright. I’m having a hard time seeing that here.

Step 1: Is there copyright?

If they wrote it themselves, almost certainly yes (skipping merrily over originality etc). For the rest of the steps, we assume copyright is vested in the authors.

Step 2: Is copying the algorithm infringement?

In the US, algorithms are patentable (Re Bilsky). The rest of the world thinks this is a bad idea. If patented, copying the algorithm (not the code) would be infringement of a patent.

Step 3: Is copying the code infringement?

If literally copied, almost certainly yes.

Step 3a: Is making an adaptation of the code infringement?

Depends. If you’ve changed it so much that you’ve made an original out of it, maybe not.
Step 4: If there’s only one way to express this idea, is it infringement?

Case law diverges. IIRC in the US, if there’s only one way to express an idea, then that expression is not protected, because ideas are not protected.

This advice is worth exactly as much as you paid for it. :wink: