An Introduction to Sage: Free and Open-Source Mathematics Software - Online!
Northeastern Section MAA, Fall 2009 Meeting, November 20th
Speaker: Karl-Dieter Crisman, Gordon College
Thanks to Karen and the organizing committee for inviting me! I hope this will be a real treat for all of you. Before we start, and while we're digesting lunch, think of a generic username and password for yourself, and send your web browser to http://demo2.sagenb.org.
|
|
Let's start. We usually expect our students to be able to do calculations like these. But what about calculations like these?
|
|
Unless we had a specific reason for them doing these by hand, most of us would be happy for our students to be able to use these things in some other problem. And doing computations like this (symbolic and numerical) is what comprehensive mathematics software does - often, very well indeed.
But there are two potential barriers to our using them.
This talk is about a solution which overcomes both of these barriers - the Sage mathematics software package. In fact, the entire talk is running in Sage!
In fact, if you followed the directions earlier, you discovered you currently have access to such a server at http://demo2.sagenb.org! Use that username and password I asked you for earlier; sign up for an account, and log in.
You may want to click on "New Worksheet", and try entering 2+2 in the cell. To see if it works, either click on the "Evaluate" button, or press Shift and Enter at the same time (Shift-Enter).
|
|
It's as easy as that; type in the command and Shift-Enter. This is very similar to other systems you may be familiar with, and makes it easy to experiment.
In fact, I strongly encourage you to play around and not pay any attention to me for the remainder of the talk; the "Help" button up top should give you links to some tutorials and references, for instance if you really want to get right into computing with modular forms. You should also be able to click "Published" at the top of the sheet to find the very same worksheet I am using right now, and to play around with it.
Getting back to the worksheet; please let me know if you did not get 4 as the answer in the previous cell. For instance, if you got
Of course, you might want to know how to get that to show up! Let's explore that. Move your mouse between two math cells (that's what we call these) until you see the little blue line. Press shift, and click on the line simultaneously; now you have a WYSIWYG text editor called TinyMCE available - and it understands TeX through the magic of jsmath!
So you can type "x" or "$x$", and the result should be different. Note that depending on the browser, you may have to install some extra fonts for full effect, but it should still look better than nothing. The above formula is "$$\zeta(s)=\sum_{n=1}^{\infty}\frac{1}{n^s}=\prod_p \left(\frac{1}{1-p^{-s}}\right)$$", by the way.
|
|
Back to mathematics. Here, our example is from linear algebra. Notice how making two lines is easy, so we can separate commands.
Above, in the first line we have assigned a specific matrix to the variable A, and the second line tells Sage to represent A for us - in this case, by nicely typesetting it, if I have clicked the "Typeset" button at the very tippy-top of the page. Notice the difference between the next two cells.
|
|
|
|
Flexibility like this is very nice to have when preparing class notes. Anyway, back to the matrices.
|
|
Note that it's important to assign most things to a name, in order to obviate the tedium of retyping everything. Just don't reassign things like \pi:
|
|
Sage has support for a wide variety of things, and often has a couple different ways to get the same result. Here, we are solving the linear system
|
|
It will also tell me if there isn't a solution, which of course can happen!
|
|
Okay, this is nice, but what about finding out what else Sage can do? Here, there is a very nice set of help features. What can we do with a matrix, for instance? Type the dot/period after your object's name, and then [tab] to see what options you have:
|
|
|
|
Naturally, the only options that come up are ones you can actually do to a matrix.
Also note the "()" syntax - it betrays Sage's foundation in the Python programming language. You don't need to know Python to use Sage, though it doesn't hurt to learn just a tad of it to be able to do cooler things.
Many things are also accessible via normal mathematical syntax, of course:
|
|
But not all. This is probably a good thing, though:
|
|
The other nice feature in Sage for help is access to the documentation of each function or object. This is done simply by appending "?" to your request.
|
|
Just a few final examples, to show a few more standard things you might expect Sage to have - which indeed it does:
|
One annoying, but crucial, point in the above is that you must use the syntax "var('y')" to define all variables other than "x". In the long run, this is good, because it helps avoid doing silly things like the reassignment of \pi I did above, but in the short run it is annoying, I apologize.
The only other such thing I can think of off the top of my head is that Sage doesn't like it if you pretend a symbolic expression is "callable" without explicitly saying so. In one variable this seems pointless:
|
|
|
|
But it makes lots of sense to require this in more than one variable!
|
|
|
|
Okay, now we can continue with the eye candy.
|
Click to the left again to hide and once more to show the dynamic interactive window |
|
|
Well, I could go on, but I really just wanted to give you a taste of how Sage is and isn't like similar systems; I assume you have your own experience and needs. And naturally, there are some things that are easier to do in one system than another, and some that aren't possible in any of them (solving the Riemann Hypothesis, for instance).
One thing I do want to point out is the variety of pedagogical techniques one can use with this (or any other) software - but from the convenience of students' own rooms. For instance:
Okay, now let's open up the floor! And don't forget to check out the website:
http://www.sagemath.org
|
|