Thou Shalt Compute, in One Click: Using (Embedded) Sage Cells Online

What is this talk about?

Sometimes, we want to use easy access to technology outside of lab-based courses or specific modules from (say) a publisher.

What is the Sage cell?

The Sage cell is a way to do one-off computations in the Sage mathematics software, without loading up the program. The idea is to make it as easy as possible to access computation in the cloud.

We'll talk about several ways to use this in the classroom, from easiest to hardest to use in the classroom: unsurprisingly, these turn out to have the reverse ordering when it comes to ease of use for students, though all are pretty straightforward.

Go to Sage Cell

First, you can just send students to
and have them compute. (Let's do a demo.)

Create a shared link

Okay, that is probably too complicated for other commands. But you can also share a link with them. I do this a lot in many classes.

Here is a direct link from my linear algebra class - an exercise from Lay's text preparing them to see Markov chains weeks later.

Once you've created a computation, you just click on "Share" and choose either a short, possibly temporary, URL to link to, or use a full URL which just encodes the actual code in your demonstration into the URL itself!

But from then on, they just click and go. I was really pleased with how many students followed through; it made things easy for them, no login required.

Embed in a webpage

Still, this is somewhat unsatisfying, because you have to have the homework or book or course notes or whatever separated from the computation.

So... what if you just put the Sage cell inside a webpage? As long as you have access to the raw HTML of your page, this is pretty straightforward, and very nice-looking.

For instance, here is an example I used in that same class, embedded in this talk's webpage.

Chapter 2 - Matrices

Chapter 2.1

Several of you asked whether Smiley Guy could be transformed by one thing, and then another.  Let's see!

Technical details

Of course, this doesn't do things magically. You have to put some effort in.

  1. For sending students to the Sage cell, you have to do very little. Of course, if they don't know Sage syntax or haven't seen examples, they probably will do very little too. Depends on your context.
  2. For sending them to pre-made cells, you'll have to come up with something for them to do. Makes sense. It can be a very simple thing like
    or a fairly involved interactive thing with sliders and other widgets. But that will require searching through interact collections or creating your own - a small price to pay for students who actually think about the math, but still a bit more.
  3. To embed those same things in your page, you will need to add some boilerplate (cut and paste!) Javascript headers to your page and do just a tiny bit of formatting. The source to this page shows some, and shows the many, many options, including linking two cells so you don't have to redefine things:
    (Imagine other text you need to explain some important point.)
    For some fairly ridiculously complicated examples of this, my number theory course notes are replete with Sage cells interspersed with crazy Mathjax-powered formulas.

Thanks for coming! Questions?

This talk is at