Mathematics Science and Engineering

Matlab Alternatives on Linux

The well-known standard for mathematical research on computers is Matlab but except for being costly, it is not always the best alternative. To solve mathematical problems and vizualise different mathematical concepts you can use many other alternatives. The ones listed below are common in both academia and industry for a wide variety of reasons. This article compares the different packages and shows how easy it is to use for projects with the GUI and with other methods.

SCILAB

Scilab has a long history, with many name changes. It started in the French Institute for Research in Computer Science and Control. The Scilab name was first used in the ‘90s. Through a few twists and turns, the Scilab foundation was setup to maintain and develop the software.  Scilab has a nice, Graphical interface, similar to Matlab and can also convert Matlab scripts. There is a special tool for the purpose.

To install Scilab you can use the built-in package manager of your distribution. The package is also available as a tar file from the Scilab web page.  The interface is very similar to Matlab and the other programs in this post. There is one console window, variable viewer and command history by default. The windows can be undocked so they act separately. The editor is a separate application which you open from a dropdown list. Each time you plot a function, a new window appears.
To learn the capabilities there are tutorials and a large library of demonstrations. You can reach the  demosntrations from the help menu. After having loaded and tested them you have a link to open the code that was used for the demonstration.

Packages are called modules until they are added, when they are called Toolboxes. Modules comes in different shapes, some are many script files using the scilab script language.

To use Scilab inside a Python program, use sciscipy, the best known module for scilab code.

OCTAVE

This is the official GNU solution for mathematics scripting and visualization. Many of the scripts are Matlab compatible, if you make Matlab-using colleagues aware you can use Octave with a minimum of adaptation work. Users can run scripts interactively, with or without GUI and can also call it in a shell script.

To install Octave the wisest is to use your standard package manager, apt, yum or similar. If you are compiling you can still use the package manager to install build depndencies. Once you have Octave installed there are many packages available, this is one of the best features of Octave. The packages are available on its own page, when you have picked your own and downloaded you need to unpack the files. Since most packages are script files (with .m extension), you can unpack them anywhere though the manual recommends the working directory of Octave.

The programming language is so similar to Matlab that there will be few lines to adapt even after having made thousands of lines of code.  To use Octave in other programming languages there are a number of options;  For Python, use oct2py(pypi.org/projects/oct2py) module. In Ipython, it supports inline plotting in notebooks. For javascript you should use the cgi module of Octave. If you are programming in C or C++, you can call the liboctave.so functions.

SAGEMATH

Use your built-in package manager to install. Having said that, there are several options should you run into trouble. There is a downloadable tar file and also a bootable disk image. All avaialble at: http://www.sagemath.org/download.html . The disk image contains an entire Linux distribution but can also be remastered for distribution of the disc further.

Sagemath is built as an educational tool and has no ambition to be like Matlab, just implement the functions. The explicit goal is to find a viable alternative to Maxima, Matlab and others.
Using Sagemath is not necessarily running a shell or a GUI for that matter. There is an interactive shell you can run which has command completion and inline help but the intention is to give the user flexibility in this regard. The interface is actually using Ipython. This means that using Sagemath will not be good if you want to learn a specific task and get a visualization of it. To try it out though, look at the web based notebook. The true strength is how you can integrate it into existing projects, especially in Python.

The programming language is different from Matlab. To start, you can still type in regular calculations and expressions but functions look different. The original idea of Sagemath is to use as much as possible of exisiting software. The packages it uses are Maxima, SymPy, R and others.

FREEMAT

FreeMat is a GUI application that looks similar to Scilab. When you open the application you get a console with a variable watch, debug and history window. The commands operate just like they do in most others in this list.  The program comes as an RPM file or your package manager. From the Sourceforge webpage there seems to be no development since 2013 but the package still works well.

There is no Matlab import or possibility, guaranteed anyway, of running Matlab code.

The programming language is similar to the other mentioned here but more limited. This package is  not the best here but it is small and you can be certain you do not need to battle any dependancies.

MAXIMA

Maxima is written in Lisp and has been developed since 1982, it is still available and actively maintained. This software has inspired many others and is used by many, including the Sagemath package.

Maxima is usually available with your package manager so installing is simple.

This program starts in the terminal with a new prompt. If you need help, type the descibe command or a question mark for exact search and double question mark for inexact search. You will not get far with this package without following a few tutorials first. Reaching the inline help requires that you first have a clue about the functions, after you have that the documentation is comprehensive.

All development of Maxima has been focused on making better functions and increasing support for  more fields of mathematics. This means there is no modules system for packages, instead use one of the other packages that use the Maxima package if you want specialized pakcages.

CONCLUSION

These packages all have some advantages, so before you choose consider what you need to achieve in your project.

About the author

Mats Tage Axelsson

Mats Tage Axelsson

I am a freelance writer for Linux magazines. I enjoy finding out what is possible under Linux and how we can all chip in to improve it. I also cover renewable energy and the new way the grid operates. You can find more of my writing on my blog.