4 ms·
I remember there was quite some critique of the algorithms used in NR and why you should not use them [1]. Not sure if they fixed the issues in the third editio
by splittingTimes 10y ago
I remember there was quite some critique of the algorithms used in NR and why you should not use them [1]. Not sure if they fixed the issues in the third edition though. Some alternatives can be found here [2].
"It is naïve to hope that every computational problem can be solved by a
simple procedure that can be described in a few pages of chatty prose, and
using a page or two of Fortran or C code. Today's ambitions for
correctness, accuracy, precision, stability, "robustness", efficiency,
etc. demand sophisticated codes developed by experts with deep
understanding of their disciplines. We have long ago outgrown the
capabilities of the simplistic approaches of 30 years ago."
===
[1] http://www.uwyo.edu/buerkle/misc/wnotnr.html http://www.uwyo.edu/buerkle/misc/wnotnr.html
[2] https://web.archive.org/web/20021015200910/http://math.jpl.nasa.gov/nr/nr-alt.html https://web.archive.org/web/20021015200910/http://math.jpl.n...
- sidlls 10y agoYeah, even when I was in grad school some 15-20 years ago these recipes were at best "okay" for very basic work. Then again my work required use of non-trivial linear algebra, which (at least at the time) NR's chapters on that topic said "better to use something pre-built".
- GFK_of_xmaspast 10y agoEven in 1970 Forman Acton was saying 'use someone else's numerical linear algebra'.
- olympus 10y agoThis is really just an example of geeks overcomplicating everything. The majority of applications don't require the bleeding edge speed or accuracy, they can get by just fine with this book. One example that comes to my mind is the Lanczos approximation given by NR to estimate the Gamma function. With the coefficients given in NR you can be accurate to seven significant digits or so. While there are better approximations available, seven sig figs is plenty good enough for me. NASA allegedly uses 15 sig figs, so I guess if you are literally a rocket scientist then NR isn't for you. The benefit of NR is that it has a lot of workable solutions in a single volume. I save time by having a single source solution that makes it easy to look stuff up. TL;DR: Perfect is the enemy of the good. Unless your project actually demands the best possible algorithm, get your answer faster from NR and be on your way.
- GFK_of_xmaspast 10y agoSeven digit accuracy is only single precision, and if speed-of-implementation is your concern (and you're not in a situation where you have a c99+ libc available), there's a perfectly good license-unemcumbered version in cephes.
- eigenman 10y agoI think that criticism of Numerical Recipes is still fair. Most of the topics in this book are the subject of decades of research hundreds of papers. Expecting all this to be condensed down to a few pages with the 'good enough' answer is unreasonable. Before the internet and the wide availability of good software packages (say in the 1980s), I could see the appeal to the practicing scientist or engineer. My boss wants the inverse of a 3x3 matrix -- I'll use Numerical Recipes. Today, anyone wanting to implement any of their algorithms is wasting their time -- excellent tested code already exists and may already have bindings to their language (e.g., numpy/scipy). The real problem with this book is it is sometimes the first and only introduction to applied mathematics. I first saw it in 2005 as an undergraduate physics major. Later, when I mentioned to my applied math PhD advisor, he was appalled. I was at first surprised by his response, but after finishing my PhD program and spending a few years in the field, I agree with him. Unfortunately, applied mathematics has not produced a competing generalist manual to the breadth of our field. In part, this is because the field is large and complex; to even understand the basics of modern algorithms requires a level of mathematical sophistication not taught in undergraduate math (see, e.g., GMRES). There are good books that cover specific topics in Numerical Recipes, e.g., Trefethen's Spectral Methods in Matlab and Trefethen and Bau's Numerical Linear Algebra, but they (rightfully) don't provide a pithy answers as to which algorithm to use. These books showcase different algorithms and illustrate the situations where they are or are not appropriate. This latter part requires significant significant sophistication to understand. Implementing an algorithm, easy. Choosing the right algorithm; aye, there's the rub. And that is where Numerical Recipes fails.
- kem 10y agoI always liked the Boost model (if I'm thinking of the right library), where things aren't just open source, but where there's some expectation of active peer review. I'm not sure how to incentivize peer review, but that seems like the right solution: to not only put out code that's openly reviewable, but where you create some incentive for people to review it. Maybe that's the point of paid third-party audits, or rewards for identifying bugs, but maybe there's some other options that could be encouraged more?