Linux Goodies

In Pursuit Of The Perfect O/S



A Review of the Euler Mathematics Toolbox

Amazon Computers

The Euler Math Toolbox

Below is an illustration of a Euler 3-D plot created with the Linux GTK Euler Math Toolbox. This review will concentrate on the Linux version that is part of the Debian distribution, as well as available from sourceforge.

Euler mesh plot

Where Can You Get it?

Yet another freely available matrix math language is the Euler Toolbox. Euler provides a very capable environment for exploring complex mathematical functions and examining data. It is available for both Windows and Linux, and provides a minimal GUI environment in both. The Windows version is more complete, including an integrated Maxima package allowing algebraic expressions to be evaluated. You can get the Windows version here.

The most commonly available version is the Windows version, and it can run in Linux with most of its capabilities in Wine. It can also run via Windows in a virtual machine. But a bit older version of Euler Toolbox is still available for Linux. You can get it at the GTK Euler Toolbox site, or from the Debian archives, which is where I obtained my copy.

From Debian and it's derivative operating systems, the installation of Euler is easy. It can be installed in any Linux distro derived from Debian with the Debian apt-get utility as follows:

As root:
apt-get install euler
apt-get install euler-doc

If you are a Puppy Linux user as I am, you can download the Euler Toolbox deb file from the Debian site, and simply run Rox on it, which will install it. You may need to hunt down a lib or two also from Debian to get it to run. I've not had to do that in the Slacko Puppy Linux version. It has installed and worked well.

How Do You Use Euler Toolbox?

To run Euler, simply type in euler in a terminal window. That will bring up the GUI work environment for Euler. From the environment, one can interactively graph functions, load programs, load data, and manipulate matrix data with the many tools. To test out Euler, I converted a program to Euler that I'd written in PDL and also converted to Yorick, Octave, R, and Scilab.

The program exercised many but certainly not all of Euler's extensive capabilities. Particularly the program exercised a number of matrix routines, the Fourier transform routines, and both line plotting and 3D plotting routines. While not the fastest of the languages in which I ran the program, I'd estimate Euler to be between Yorick and Octave in speed, which is quite respectable.

Euler always presents a GUI window for interacting with the program, and a graphic window that displays all graphics. The GUI window is interesting in that it allows the user to use the up/down keys to move back and forth through a history of commands during a session. It jumps over function outputs to land on the commands or function calls. One can skip back to a previous command, modify it, and execute it again.

Euler Toolbox allows the user to save all the commands and outputs of the GUI window as a notebook file. Notebook files can also (via the menu) have comments put in them before saving. Saved notebook files can be re-loaded, giving the user all the commands ran before, easily modified and ran again just by scrolling through the GUI display. In conjunction with Euler scripts (programs and libraries) that you can save to files, the notebook file creates a very handy and productive programming experience.

In matrix syntax, Euler is somewhat similar to MATLAB and Octave. Enough so that MATLAB or Octave users could easily adapt. Sequences of numbers are generated in the same way, and indexing matrices is the same. In fact, Euler allows matrix indices to be expressed within parentheses or brackets to provide more compatibility with other languages, though the author suggests brackets. I found it best to use brackets for matrix indexing, because Euler sometimes confuses parenthetical indexing with function calls. A number of matrix operations are different, and somewhat unique to the Euler language. For example:

To combine matrices X and Y by columns:
A = X | Y;
To combine matrices X and Y by rows:
A = X _ Y;
To perform a matrix multiply:
A = X . Y;

As you can see with these examples, Euler isn't intended to be a highly compatible MATLAB clone, just a language that is similar in capability and appearance. Functions are declared in a way unique to Euler. Similar to other languages, but not exactly like any of those I've used before. To declare a function that accepts 3 arguments and returns 3 results:

function test(x, y, z)
return {a, b, c};

One nice thing about functions in Euler is that they can return multiple arguments. It seems that the GTK version can return up to 7 arguments. Note the curly bracket nomenclature for returning multiple arguments. Again similar looking to MATLAB and Octave users, but not exactly the same as those languages. The same curly bracket nomenclature is used to receive multiple arguments:

{u, v, w} = test(x, y, z);

I was unable to find any form of data structuring in Euler beyond the matrix. That is, to my knowledge there is no way to hold a stack of images for example rather than as individual matrices, or to combine different data structures into some kind of single, large matrix . However, Euler does have an impressive collection of problem solving, linear algebra, and statistics functions.

The FFT routine works on vectors or matrices. Matrices have to have rows and columns of 2**n values. It does work exceedingly fast however, and has a corresponding inverse transform function. The classical way to deal with the power of 2 limitation is to pad a matrix with zeros to extend the rows and/or columns to a power of 2. The power of two restriction doesn't seem to apply for FFT's of vectors.

For help, one can click on the help menu at the top of the GUI and Euler will bring up a browser to display the HTML help documentation. The user can set which browser to use in the .euler/euler.cfg file.

Typing list tells Euler Toolbox to list all currently defined functions, including the built in ones. Typing help followed by an Euler function name will bring up help on that particular function directly to the GUI window. Lines starting with ## (if at first character) will be ignored during function execution, but will be listed by the help command. Such comments that do not start at the first character of a line are just ignored, not listed by help. For example, the function below:

function sqr(x)
## y = x^2 -- Comment line also listed by help sqr command
  ## This is just another comment, not listed by help
return x^2;

If help is used on this function (help sqr), then the function definition line and following ## comment line(s) starting in column 1 will be listed to the screen. It's a handy way to document your functions. Incidentally, though ## lines are comment lines, they are only allowed when occurring within function definitions.

Also in the .euler/euler.cfg file is a list of the libraries automatically loaded every time Euler is invoked. A user can create his or her own libraries and have them auto-loaded by adding them to the euler.cfg file. If some libraries are too specific to be always loaded, then the load command can be handily used as part of a saved notebook file, with comments about what the lib does.

Linux Euler Limited in File I/O Capabilities

File I/O operations are limited compared to many matrix languages. It's no problem if you work exclusively within the Euler system, but makes reading files made from other languages difficult. At least, it may require you write external programs in some other language, like maybe c or perl, to convert files between Euler and other languages. The main issue is the limited binary i/o available in Euler Toolbox. It handles text files just fine, and this can be the way to move information to/from other languages.

In the Linux version, one can simply write out a matrix with the writematrix command, and read a formally written matrix with the getmatrix command. However, the writematrix command doesn't output any information about the size of a matrix, just the matrix values. So reading in a matrix with the getmatrix requires parameters that specify the size of the matrix in the call function. Not so handy in that you must know the size of the matrix you want to load.

However, it was an easy task to package a couple of commands together in a new output routine (I call it eulerout) that writes first the matrix size, then the matrix. Then a similarly packaged input routine (eulerin, what else) reads in the size then uses that to read in the matrix. So with those two simple routines it's easy to save and load matrices just as with the Windows version.

The Linux version of Euler can read and write data ASCII files, but assumes that the files are purely numerical. There is little support for reading files that might have other kinds of information, such as data labels mixed with the data. There is a getchar command, and I was able to write an Euler function that could read past a label to a line feed, and then read in the data as a vector. Euler has only primitive binary file support, being able to read or write characters, and single or double word integers, and can only read and write vectors, not matrices.

euler mobius strip
Euler Mobius Strip Graphic

Euler Graphics

Euler has many familiar graphic routines that do what you might expect. The plot function will plot a vector or an x,y pair. Mesh will plot a matrix as a 3D filled wire model. Other routines can do contours, color contours, wire model and solid model 3D presentations with Euler's own unique arguments.

As shown in the Mobius Strip image above and the sinx/x image at the beginning of the page, Euler can plot in colors. It can use up to 16 colors, which can be selected from a palette of 255 colors. In both the Linux and Windows version, these colors can be selected via the application interface. The Linux version stores setup up parameters in the file ./euler/eulerrc. So you can set the colors numerically in this file rather than use the application interface. In the images shown here, you can see that I selected terrain type colors, as I most often do color graphics on terrain data.

Euler can even display shaded images, though one has to convert an image into one of the simple file forms that Euler can import, or create a function to read some type(s) of graphic files. I was able to construct an Euler Toolbox routine that can read pnm type graphics files, as that structure is about the very simplest to implement. Likewise I have a function for writing pnm files. This gives some capacity to even use the toolbox for some basic image work.

euler processed moon image
Lunar Apennine Mountains
Image Processed with Euler Toolbox

The above image of the moon is one taken with my ETX Telescope and the Celestron NexImage Astro-camera. The ETX site link takes you to a collection of processed images taken with the ETX telescope. Each image was created by aligning and averaging many frames from a web cam movie of each area of the moon. The web cam is one that's been modified for astronomical work.

I usually use a Yorick program for this work, but I created the same capability with the Euler Toolbox, and the above image was processed with the Euler program. The Euler version runs a bit slower than the Yorick version, but not objectionably so. The effort proved to me that my astronomy images can as easily be processed with the Euler Toolbox as with Yorick.

euler line plot

Above you see can example of a multiple-line plot created with Euler. Rather than provide extensive optional arguments to plot functions as do some languages, Euler plot functions accept only the data to be plotted. There are text functions that can be used to put plot titles and other textual information on a plot or graph.

Other function calls allow the user to select the plot color, plot scale, etc. Normally, each plot call clears the plot area to draw a graph. To plot multiple functions in different colors as was done on this plot, I used the Euler holding command, which allows additional data to be plotted on the same window.

Over the years I've worked a lot with time-series data, and usually that entailed data in 2 or 3 coordinates, like latitude, longitude, and altitude. So I often wanted 2 or 3 plots on a page, but each on its own axis. With some languages (Yorick comes to mind) it was a bit challenging to get a plot setup to do my preferred 3 plots. Yorick expects a template file to define a plot structure. Euler Toolbox makes this task easy. Here's an example of 2 plots each with its own axis, created in Euler Toolbox:

euler multi plot

This turned out to be very simple in the Euler Toolbox because of the figure command, which allows one to divide the plot window into any number of areas. In this case, the command used was figure([2,1]), which means 2 rows and 1 column. Declaring the desired figure before making the plot puts the plot in the desired sub-section of the window, like: figure(2) followed by the desired plot command.

euler line plot

In addition to line plots and 3D plots, Euler can do line contours and colored contours, as shown above. For the color filled contours, the user can select the hue color, using values from 0 to 15. A hue color with a zero argument produces multi-color plots.

The following sequence of plots show how the Euler Toolbox density, contour, and holding can be used for different effects. First shown is a color density plot of some terrain data. Following that is the same data presented with the contour command. Following that the contours are overlayed on the density plot, made by using the holding command to allow over plotting on the same graph.

euler density plot
Euler Density Plot

euler contour plot
Euler Contour Plot

euler density + contour
Euler Density + Contour Plot

For another terrain view, the solidhue command can be used to get a 3d, colorized image of terrain, as follows:

euler solidhue graph
Euler Solidhue Colorized Graph

Linux Version Limited in String Support

I have been able, with just a few user generated functions, to do about everything I've done with any other matrix language. The biggest limitation I encountered was the limited string support in Euler Toolbox. The Linux version allows only scalar variables to contain strings, no string arrays. Strings can be concatenated with the | character, and strings can be compared with the stringcompare function. One can convert a number to a string with the printf command. For example:

lab = The value of pi is | printf(%0.2f,pi)
Sets lab to be a string with value: The value of pi is 3.14

There are a couple of character operators, like ascii, which will return the ascii value of the first character in supplied string, and the char command, which will return the ascii character given the character numerical value. That's about all that's inherently available in the Linux version. The Windows version of Euler Toolbox has a much more extensive string library.

String Functions Can Be Easily Added

While the Linux version of Euler Toolbox is lacking in string utilities compared to the Windows version, it turned out to be pretty simple to add a number more. A string to character array function (I call mine s2c) can be formed by writing a string to a file and reading it back as characters. Packaged as a function, this quickly and easily converts a string to an array of characters. To convert characters back into a string, a character array function (I use c2s) can just loop through and concatenate the array characters back together.

These two basic functions make it easy to create all manner of string manipulation functions, as one has complete access to all characters in a character array. I've created a substr function to return a sub-section of a string, and a split function which combined with the built in nonzeros function returns portions of a string split on a given character.

With just these additional and easy to make functions, I feel pretty much caught up with the string abilities needed to replicate programs I've written in my other matrix languages. Since Euler can already directly and quickly read in numerical strings, I really only use string functions for handling a few labels and such, so processing time isn't an issue at all.

One additional string limitation is that while the Windows version can have arrays of strings (handy sometimes for labeling output or holding file names), the Linux version cannot store strings in arrays. In the Linux version of Euler Toolbox, arrays and matrices are only for numbers.

Aha, but converting a string to a character array creates an array of numbers, the numerical value of each character. So one can store rows (or columns) of string arrays into a matrix and in so doing store labels and things in arrays. In the following example, I use my s2c (string to character array) and c2s (character array to string) functions to easily create a usable array of strings, in a sense.

Example, to store strings array
names = [s2c("One"); s2c("two"); s2c("three")];

To see the character array contents:
79 110 101 0 0
84 119 111 0 0
84 104 114 101 101

To list out one of the labels:

Note the 0 values at the end of the first two rows of the matrix. Each row holds one of the strings, and Euler Toolbox, needing all rows to be the same length, automatically padded the shorter names with zeros. So my c2s routine takes that into account, either returning only a string up to the 0 values, or turning the zeros to some character, like blanks.


In summary, I find Euler to be very useful, with some solution methods not commonly found in math languages. It has a smaller resource requirement than many matrix languages, making it a snap to install. Some other languages are so dependent on many libraries that they don't easily install in a version of Linux just from source code, or packages from other Linux distros.

It took me awhile to become aware of the usefulness of the notebook style of the Euler Toolbox interface. None of the matrix languages I'd used up to then had such an interface. Now I've found that it is very useful. The experiments ran to develop new functions can be cleaned up and saved as notebook files, and be the mechanism used to run the functions later. In other languages I always had to create batch files or programs to package things together. The notebook files do that for me.

Euler Toolbox is easy to use, and easy to program. It isn't probably the best choice for large scale projects or data reduction if more flexible I/O support is needed, or some more complex data structures are needed. But looking back over the many years I did time-series data work, I believe I could have done all that work with Euler Toolbox.

What Euler is good for is listed at the Sourceforge Euler Site. Euler has many familiar graphic routines that do what you might expect. The plot function will plot a vector or an x,y pair. Mesh will plot a matrix as a 3D filled wire model. Other routines can do contours, color contours, and wire model 3D presentations with Euler's own unique arguments.

Clearly every language has some tailored language elements and solution methods most meaningful to the person or team who created them. And it's best to chose the language where those design intentions best match up with your needs. You'll generally find that you can get used to most any nomenclature if you use a language frequently. The oddities become second nature.

Since I'm more casual about my programming exploits these days, I've found that the simple syntax of Euler works very well for me. In some ways, the other languages with which I'm familiar can seem more arcane than the refreshingly intuitive Euler, even though they are perhaps more powerful in solving some problems. So I have more trouble doing my casual, web-oriented programming projects with the more cryptic languages because I'm not doing that kind of work on a daily basis. That's why the straight forward expressiveness of Euler has made it my go-to mathematics tool.

You may wonder why I use the native Linux version of Euler Toolbox, given that it's an older version and has less features, particularly in the string handling area and the symbolic math. I do it because the native Linux version is snappier in response and faster than if running the Windows version in a virtual environment of some kind. Plus, my work involves primarily the matrix and graphic features, which the Linux version contains. The additional features I've needed were all added fairly easily with some library scripts. If I were a student and some classes needed the symbolic math support, I'd switch to the Windows version in a virtual environment, at least when those requirements were useful.

The following pros and cons are my subjective views of Euler:

  • Freely available for both Windows and Linux. The Windows version includes more features, such as better string support and the integrated use of Maxima.

  • Loads quickly.

  • A GUI environment for controlling the Euler environment.

  • The ability to save/load notebook files of GUI command sequences

  • An easy to learn Basic style programming language.

  • Quite fast when solutions are optimized to use intrinsic matrix operators.

  • Easy to use 2D and 3D graphics utilities.

  • Cons:
  • The Linux version is only the matrix language portion, no Maxima interface.

  • File handling utilities are minimal, making it difficult to work with files made with other utilities without some external conversion routines.

  • String handling features are limited (but can be easily augmented).

  • Designed to be mostly used interactively -- but can run in batch mode.