This article describes the installation and simple usage of the Sage mathematical software system. Sage is free, open-source math software that supports research and teaching in algebra, geometry, number theory, cryptography, numerical computation, and related areas.

We start by installing Sage on Ubuntu:

sudo apt-get install sagemath

Let’s take a look at what the Sage commandprompt can give us:


This will present you with a prompt that says “sage:”. You can type things here that Sage will try to understand and solve. For example, if we type “2+3”, Sage will respond with “5”:

sage: 2+3

Now let’s try to solve something a bit more difficult:

sage: a, b = var('a, b')
sage: solve([a + b == 12, a - b == 6], [a, b])
[[a == 9, b == 3]]

There are numerous functions you can use. We will show some of them here:

sage: factor(60)
2^2 * 3 * 5

sage: is_prime(1234567891)

sage: gcd(100, 24)

Using some Python magic, we can do things like:

sage: [factor(n) for n in range(2, 10)]
[2, 3, 2^2, 5, 2 * 3, 7, 2^3, 3^2]
Using the sage mathematical software system
Tagged on:

One thought on “Using the sage mathematical software system

  • 2010-01-05 at 16:16

    Hi, the debian package for Sage is terribly outdated 🙁

    Please don’t use it, seriously!!!

    I strongly recommend to get the prebuilt binary for ubuntu from one of our mirrors, extract it via
    tar –lzma -xf sage-x.y.z-..ubuntu….tar.lzma (or right-click extract in nautilus, read the README, or the download guide) and start the “sage” file directly. Best way to download it is to install “aria2” and pick a metalink – or the “downemall” firefox extension.

    Keep in touch with the project via the rss feed, twitter @sagemath or facebook page since we release new versions about every month.


Leave a Reply

Your email address will not be published. Required fields are marked *