You are here

Sage for Undergraduates

Gregory V. Bard
Publisher: 
American Mathematical Society
Publication Date: 
2015
Number of Pages: 
352
Format: 
Paperback
Price: 
29.00
ISBN: 
9781470411114
Category: 
Textbook
[Reviewed by
Fernando Q. Gouvêa
, on
04/30/2016
]

The advent of Sage changes things. We now have a free computer system for doing mathematics that can do at least as much as the “big four”: Magma, Maple, Mathematica, and Matlab. Its main problem so far has been a lack of accessible documentation. This book is a successful attempt to remedy that for beginning undergraduates.

Let’s start with Sage itself. The initial idea was simple: since there are many open-source mathematics programs available, let’s create a single interface through which we can access all of them. Thus, Sage incorporates “NumPy, SciPy, matplotlib, Sympy, Maxima, GAP, FLINT, R, and many more,” as we can read on the Sage home page. In fact, the list includes at least 90 different packages. Some of those, like R, are big standalone systems in themselves; others are libraries that one would use in one’s own programs. Sage allows one to access all of them through a single interface that uses the same syntax as the Python computer language. The program can be (and usually is) used through a web-based interface: either the SageMathCell, which is basically one window into which one types code, or SageMathCloud, which provides a “notebook” or “worksheet” interface.

Sage can do pretty much any kind of mathematics that is doable by computer, from single commands such as factor(1538541535345), which yields 5 * 137 * 263 * 8540099, to something like this:

datapoints = [(0,7.1),(1,5.3),(2,3.0), (3,1.09), (4,-0.66)]
var("x a b")
model(x)=a*x + b
ab=find_fit(datapoints,model)
scatter_plot(datapoints)+plot(ab[0].rhs()*x+ab[1].rhs(),0,4)

which yields

Sage plot

(See, I learned something!)

Most of my students seem to find Sage more approachable than other free tools such as R or GP simply because it uses a web interface instead of a terminal-style interface. In addition, many of my students already know Python, which makes it very easy to understand how to write Sage commands. And, to belabor a point, it is free. You don’t even need to download anything to your computer, just use it online!

This book aims to introduce Sage to undergraduates. In fact, I should be more precise: what Gregory Bard is really doing here is introducing Sage to first-year undergraduates. He assumes very little mathematical knowledge beyond Calculus and maybe Linear Algebra, and even some very basic ideas (e.g., solving linear systems in the singular case) are explained as mathematics before Bard goes on to talk about how to use Sage to do those computations.

The book introduces Sage and the most basic commands in chapter one, which is followed by a chapter with “fun projects using Sage.” I must confess that I didn’t find these all that much fun, mostly because they are too elementary. Chapters three teaches more advanced plotting commands (something that both students and their teachers will find useful). Chapter four deals with “advanced features,” which means things like series, matrices, vector calculus, and differential equations. The last two chapters deal with programming (for loops, flow control, lists and arrays…) and with how to produce an interactive web page that uses Sage “under the hood” to demonstrate some mathematical idea. I think it makes a lot of sense to organize the material this way, particularly for this group of students. Anyone who works on the problems prior to chapter five will have gotten utterly tired of typing in certain things repeatedly and will welcome learning about “for” and “if”! Students are less likely to need the ideas in chapter six, I suspect. The projects in chapters four and five are much more interesting than those in chapter two, and would make nice assignments in a course on mathematical computing.

Of course, this only scratches the surface of Sage capabilities. There is nothing here about abstract algebra and number theory, no Fourier series, very little in terms of numerical methods, and no statistics at all, but of course Sage can do all that. For the intended audience, that is probably the right choice, but advanced students will want more than they will find here, so there is space for other books like this one.

One of the ways Bard tries to keep his book accessible is by using an unusual style. He addresses the reader as “you” throughout: “you should be careful to…”, “as you can see…”, and so on. (Occasionally the mask slips and the book talks about students learning or doing things.) I found this a little off-putting at first, and I’m still not quite convinced it is the right choice, but it does allow for a very informal tone. There is a lot of handholding. Some of it, particularly about dealing with long scary error messages, is probably needed, but other bits, like reminding students not to insert commas when writing a large number such as 245,543, really did not need to be repeated that often.

By special agreement with AMS, the book is available online in pdf form: go to Gregory Bard’s home page — click on “Sage Stuff”. (Some of the typos in the printed book have been corrected in the online version.) Also on that page one can find the source for some of the longer examples in the book and other Sage resources. Alas, what one cannot find (at this writing) is the online electronic appendix that will cover plotting in color, animations, and 3D graphics, which is promised in the book. As Bard notes, such things would be hard to visualize if they appeared in a book printed in grayscale; but all one can find on the page, over a year after the book was published, is the promise that this is “Coming Soon”.

I suspect that we will be seeing more advanced mathematics books built around Sage; there are already quite a few. This book, however, is the only one aimed at beginning undergraduates. So the book is an implicit argument for the thesis that we can and should be introducing our students to mathematical computing early in their careers, and that Sage is the right tool to use.

That may well be right. Computation plays such a crucial role in pure and applied mathematics that we really should be introducing our mathematics students to the basic tools and ideas. One can do this by requiring (or strongly urging) them to take a first course in programming, or one could use a book like this one to expose them more specifically to mathematical computing. One might even want to do both. Maybe we’ll soon have “how to compute” courses alongside the “how to write proofs” courses that we now use to transition students to more advanced work.

Buy Now


Fernando Q. Gouvêa is Carter Professor of Mathematics at Colby College and the editor of MAA Reviews.