Save Time With Software Libraries

Do you know a programming language? Do you think you will have to learn one for your research? As a former software developer, I have a few opinons on the subject. First, in line with my general teaching philosophy, I believe it’s boring to learn to program for programming’s sake. Same with learning a new language. When learning a language, you really should have a specific problem you’re attempting to solve (creating a video game, solving a particular equation, making a turtle move across the screen). Second, after you learn a language or two, becoming proficient in a new language is a matter of learning the specific idioms which allow you to accomplish the tasks you have in mind, as well as studying built-in and popular libraries for the new programming environment. This brings me to my main point, don’t reinvent the wheel. Read on if you want to learn about some wheels which have already been invented, that is, libraries and environments for mathematical computation.

Suppose you were at a point in your reseach which required results from a computer to continue. The computer program you need to write requires some basic data structure or mathematical object such as a tree or a matrix. It can be satisfying, almost addictive, to write all of the necessary tools from scratch. Be mindful of why exactly you’re writing each piece of code: for fun, to learn the details of a known algorithm or to directly further your research. A straightforward programming task can be fun like a mathematical puzzle, and writing these small programs may be a valuable source of stress relief. Similar to mathematics, if you haven’t seen an argument or trick before you should attempt to prove it for yourself. The programming analog would be building your own toy implmentation of a library function, as you sometimes won’t fully understand and appreciate the existence of a particular software tool until you’ve attempted writing it yourself. But if programming for fun or to learn distracts from progress, it might be time to pull the plug and use a library.

Why should you prefer libraries to hand-written code? Allow me to make one argument based on language. The mathematical language you would use to write a proof, like other natural languages, contain conventions which provide an informal way to handle various unimportant alternatives. Error handling in software is a giant pain. A second justification is efficiency; there’s a good chance your code will run an order of magnitude slower than a popular available library. Using pre-existing libraries may save time, especially when they provide a service you use frequently. Finally, after familiarizing yourself with an opensource tool you may stumble upon the opportunity to contribute back to the project with bug fixes or new features.

Since I love a good list, I’m going end this post with links to opensource mathematical software you may find handy. Feel free to add your picks, or corrections, in the comments!

  • Sage – a computing environment pieced together from numerous open source packages and glued via Python, plotting facilities, licensed under GPL. Every mathematics student should be aware of Sage.
  • Octave – numerical computation environment, similar to Matlab (in fact the languages are compatible to an extent), plotting facilities, GPL license.
  • The R Project – statistical computing environment, plotting facilities, available in SAGE, licensed under GPL.
  • GAP – computer algebra tool with focus on group theory, included in SAGE, licensed under GPL.
  • PARI/GP – another computer algebra tool, included in SAGE, licensed under GPL.
  • Maxima – one more computer algebra system, included in SAGE and licensed under the GPL. (Sorry, I don’t know much about computer algebra systems!)
  • Numpy – widely-used implementation of multi-dimensional array data types and linear algebra functions, uses FFTPACK, available through SAGE or directly in Python language, Numpy license.
  • SciPy – numerical computing environment using the Python language and Numpy library, plotting facilities, also available in SAGE, BSD license.
  • Apache Commons Math – useful mathematical tools for the Java language in the areas of statistics, linear algebra, numerical analysis, Apache license.
  • Boost Math Toolkit – collection of statistical distributions and special functions implemented in C++, Boost license. For the C++ nerds in the audience, note that many features are inducted into the standard library after implementations are stable in Boost for years.
  • Boost Graph Library – high quality graph data structures and algorithms, like most of Boost makes heavy use of templated/generic C++, Boost license.
  • GSL – collection of scientific routines for C and C++, licensed under GPL. Go here or Netlib before you implement something from Numerical Recipes.
  • Netlib – collection of numerical algorithms maintained by “AT&T Bell Laboratories, the University of Tennessee and Oak Ridge National Laboratory, and by colleagues world-wide,” libraries are mostly written in Fortran with some in C, various licenses.
  • LAPACK – famous linear algebra library written in Fortran and highly tuned, available through SAGE and other environments, BSD license.
  • FFTW – like the name says it’s the Fastest Fourier Transform in the West, written in C, available through Octave, licensed under GPL.
  • The Trilinos Project – collection of C++ libraries for linear algebra, nonlinear optimization, mesh generation, maintained by Sandia National Laboratories, BSD license.
  • The DAKOTA Project – another C++ collection from Sandia National Laboratories for optimization and uncertainty analysis, BSD license.
  • Cuba Library – multidimensional numerical integration with interfaces in C, C++ and Fortran, licensed under the LGPL.

About Derek Smith

Former weather dude and scientific software developer. In the upcoming 2015-16 year I will complete my PhD at UCSB in nonlinear dispersive equations. I enjoy spending time with my two young daughters and running.
This entry was posted in Advice, General, Technology & Math. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

HTML tags are not allowed.