Interacting with SAGE – Part 1

May 12th, 2008 | Categories: math software, sage interactions | Tags:

Regular readers of this blog will know that I have been keeping an eye on the open source mathematics package, SAGE, but have never really had time to take a closer look at it. A couple of things happened recently that made me find time to sit down and have a play with this extremely promising piece of software.

First of all I discovered that the developers of SAGE have been implementing a command called interact which is essentially a free version of the Mathematica command Manipulate. I love tinkering with Manipulate and so this open source alternative proved to be very tempting. Secondly, the developers of Sage recently released version 3.0 and, usually, a .0 release signifies a major milestone in development.

So first things first. What exactly is SAGE? In my opinion, the easiest way to sum up the answer to this question is to quote the projects mission statement which is

“Creating a viable free open source alternative to Magma, Maple, Mathematica, and Matlab.

No small task! I have access to three of the four CAS systems that SAGE has chosen to compare itself with and they are all extremely powerful (not to mention expensive) applications backed by large, well funded development teams. Not content with taking just on just one of them – SAGE has chosen to compete with all four at the same time!

Free maths packages are nothing new of course – there are several good quality, regularly updated open-source packages that one could choose from. For example we have

  • Octave – A numeric-centric application that aims to be source-compatible with the base version of Matlab
  • Maxima – A more symbolic-centric package than Octave that is an open source development of the old commercial Macsyma code.
  • Scilab – Another numeric-centric package that has similar functionality to Matlab but it does not aim to be source compatible in any way.

We also have YACAS, Mathomatic, PARI/GP, GAP, R, Singular and GINAC among others – some of which are very well known in various academic disciplines. So what makes SAGE different?

SAGE is a car

The first major thing I noticed when reading about SAGE is that its developers realised that there is a lot of good code in packages such as Maxima and it would take a long time to develop equivalent levels of functionality from scratch. So, to paraphrase their slogan, rather than re-inventing the wheel they built a car.

In other words they did not try to compete with Maxima by re-implementing its algorithms – they simply included the entire Maxima executable with the base install of SAGE and wrote a SAGE-Maxima interface. So that’s one of the wheels of the car for a start.

For the other wheels they included GAP, PARI and Singular with SAGE so you immediately have access to four different systems from one standard interface – that’s a lot of funtionality. Continuing with the car metaphor I guess we have Python as the engine along with the statistical package, R, as um..the doors? You also have GMP (multi-precision arithmetic), Matplotlib (2d plotting), Tachyon3d (3d plotting) and lots more!

You don’t have to stop with just these included systems if you don’t want to. For example, if you have a copy of Octave on your machine then you can also call that from inside SAGE. Apparently you can even use commercial packages such as Mathematica or Maple although I have yet to try this out myself.

Of course, SAGE is much more than just an interface to existing systems – the developers have also written 250,000 lines of new, SAGE specific code, that adds to this plethora of functionality.

This isn’t just any old car – this is a car with all the optional extras. That gets constantly upgraded. For free!

SAGE uses Python

The next thing about SAGE that stood out for me is the fact that you use the Python scripting language to interact with it. I already know some Python and so, without needing to learn a thing, I already know how to use large parts of SAGE.

SAGE’s use of Python doesn’t just provide a shallower learning curve for Pythonistas, there are a great many other benefits too. In particular, the use of Python gives SAGE access to all of the routines of the extensive numerical library numpy along with the plotting library, matplotlib. These two Python libraries alone provide a reasonable amount of matlab-like functionality before you start considering everything else in the SAGE system.

SAGE has a great user interface

Its been a while since I used any of the other open source maths packages in anger so what I am about to say might be a bit out of date but in general it seems that their user interfaces are a bit, well…primitive. Many of them look just like a terminal prompt with a graphics output window. This is all well and good but when you are used to the pretty, notebook-like interfaces in Mathematica or Maple they all look very last-century.

SAGE uses your web browser as its notebook-like interface and I think it looks great. Here is an example of it in use (shamelessly stolen from here)

Of course you can still use it in good, old fashioned terminal mode if you really want to :)

SAGE has the interact function

SAGE is first and foremost a tool written by researchers for research and so it contains a lot of very advanced mathematics. For example the lead developer, Willian Stein, is very pleased about the fact that SAGE includes code for computing with modular abelian varieties. Now I wouldn’t know what a modular abelian variety was if it hit me over the head (I would welcome an idiot’s guide by anyone willing to write one) but I am sure that this code is very important to those who work with them.

So, bearing in mind that the SAGE developers have worked very hard to include all of this cutting edge functionality, I would like to apologise to them in advance for the fact that the piece of SAGE that really got me interested was the interact command – something that many people may well find frivolous.

In a nutshell interact offers similar functionality to Mathematica’s Manipulate command which I am a HUGE fan of. If you are new here and have no idea why the Manipulate command is so wonderful – check out the Wolfram Demonstrations Project and note that without Manipulate, the project would not exist.

In the second part of this blog post (coming in a few days) I will give you an idea why I think the interact command is so wonderful, what you can do with it and how to use it along with some comparisons with the Manipulate command of SAGE’s competitor, Mathematica. If you can’t wait for me to write the next post and want to see some interact examples right now then check out the interact page on the SAGE wiki.

If you enjoyed this article, feel free to click here to subscribe to my RSS Feed.

  1. May 12th, 2008 at 23:28
    Reply | Quote | #1

    Thanks for this post. I’m looking for a program to have my high school students to use in their multivariable calc course (small class, as you can imagine), and I was considering SAGE. But with your post, I’m now getting more and more convinced that it’s just the thing for me. Especially with the MAPLE-like notebook interface. I just have to see how it graph 2-d and 3-d things.

  2. admin
    May 13th, 2008 at 15:57
    Reply | Quote | #2

    Hi Sam

    The graphing isn’t too bad at all. Do you have any particular examples you would like to plot?

  3. May 13th, 2008 at 22:37
    Reply | Quote | #3

    Not right now. I’m going to spend this summer trying to design this course. I’d think just some general 3-d shapes, but I recently saw the screenshots at the website and they are pretty darn impressive. Thanks!

  4. Jason Grout
    May 14th, 2008 at 20:41
    Reply | Quote | #4

    I just used Sage quite a bit in my college multivariable calc course and it worked fairly well. Feel free to subscribe to sage-edu ( or sage-support and ask any teaching/support questions about Sage.

    The new @interact functionality is pretty neat to use. We’re actively working on extending it and making it better too. The next release of Sage, 3.0.2, will have a matrix control, for example.

Comments are closed.