Quick and Dirty Numerics

Hendrik Weimer


Normal version

For many scientists and engineers, writing code for numerical calculations covers most of their daily work. This resulted in many algorithms having been researched and understood in great detail and there are many excellent textbooks like the famous "Numerical Recipes". However, the code examples in such books are typically non-free. As the benefits of sharing the code and not having to implement everything by oneself are obvious, this has led to the creation of various free software packages for numerical computing. Special-purpose libraries like LAPACK cover only a limited are of numerical computing and interactive suites like Octave do not scale too well, so the GNU Scientific Library (GSL) aims to fill the gap between them.

GSL covers large areas of numerical calculation, like linear algebra, numerical integration, solving sets of nonlinear equations. For many problems, there is not only a single algorithm to choose from. This enables the user to choose the best algorithm available depending on the details of the problem at hand.

For a numerical library the documentation is one of the parts that matters most. Unfortunately, this is an area where GSL displays severe shortcomings. Some important functions are not even fully documented, so the user has to guess what its parameters precisely mean. Furthermore, it is often difficult to find the place in which a function is explained as the documentation is not very well-structured.

On the other hand, if the function you would like to use is properly documented, GSL is fairly easy to use. You do not have to worry about every tiny aspect like checking the convergence of a solution as GSL takes care of such things. Even complex problems can be tackled in relatively few lines of code.

Error handling is another problematic area. By default, GSL aborts the execution of your program once it encounters trouble, but it often does not print a helpful error message. You can define your own error handler to decide what to do in more detail, but the default behavior is somewhat inconvenient.

While these issues make it hard to recommend the every-day use of GSL in its current state, there are some areas where it can prove useful. Getting a quick shot on a problem or using some unusual algorithms comes to mind here. In all other cases, use a special-purpose library or grab your copy of "Numerical Recipes" and implement the algorithm by yourself.

Distributions: [?]■ Debian stable■ Debian unstable
■ Fedora■ Mandriva
■ Suse■ Ubuntu


  • Easy to learn and use
  • Different algorithms
  • Incomplete documentation
  • Error handling

Copyright 2006–2008 OS Reviews. This document is available under the terms of the GNU Free Documentation License. See the licensing terms for further details.