Travis Scrimshaw (The University of Queensland)
Ewha Womans University
March 20, 2018
SageMath (http://www.sagemath.org/), or Sage for short, is an open-source mathematical software that is built upon numerous open-source packages and uses Python as a common language. It began in 2005 by William Stein (who now runs cocalc, https://wstein.org) as a way to build a better car rather than reinvent the wheel by building on these previously disjoint packages.
In this demo, we will explore some of its features ranging from being a simple calculator to how to use Sage in research.
To install an old version of Sage (7.4) on Windows, you can use the .exe from https://github.com/embray/sage-windows/releases/. You can also build it from source using Cygwin64.
Like every good Sage tutorial, we begin by verifying Sage can do basic arithmetic operations.
If this was plain Python, this would be considered int
(floor) division, and would return . However, these are a special Sage integer, so we get rational numbers and can do extra operations on integers.
In order to see what operations are available on integers (or really any object), all one needs to do is x.<tab>
, where <tab>
means hitting the tab character on your keyboard. This is called tab-completion (it can also fill out partially typed commands).
Don't forget the dot .
!
However, it is not always clear what some of these methods (functions acting on a particular type of object, yes you can think of .
that way) do. I do not even know all of them. However, Sage has a very useful way to find out: just add ?
to the end and it will display the documentation.
Tab-completion and ?
will get you very far in exploring what Sage can do and how to use Sage. If you take anything away from this introduction, remember these two things.
Unfortunatly, we cannot write every real number exactly using a computer as that will take an infinite amount of time and space. anyone? So we need to consider real numbers up to a fixed precision.
As we can see with the above example, this can cause a loss of precision (remember significant figures?). To get a better sense about the error that can be introduced, we can use interval arithematic.
We have the same thing for the complex numbers.
However, if we want to work with known constants, Sage has them.
Since simplifying expressions in general can require a lot of computations, Sage does not always simplify things. Instead, you must tell Sage to do so.
Subsets of the complex numbers are good, and we can do a lot by just applying basic functions. However, Sage allows you to construct much more complicated functions and do things like calculus.
For the following examples, we will turn Sage's output for CoCalc into latex by default.
While we are talking about functions and plotting, let's do some other types of plots.
One of the powerful features of using CoCalc (or the Sage notebook) is through interacts, where one can dynamically update inputs in the same cell. These are not just limited to plots, but the examples we give below are all for plots.
For more information and examples, see:
Linear algebra is one of the core components of any computer algebra system. Sage provides support for doing linear algebra over a variety of fields and some support over rings.
Working with symbolic variables (i.e., by using var()
) has a lot of flexibility, but because of that generality, they don't have a lot of structure and methods. The computations can also become very slow for more complicated expressions. Instead, if you want to work in a polynomial ring, then we should take advantage of that extra structure.
Notice above that we also have rational functions and have created one just like we did with the rational numbers. We can also do quotients with remainders.
To create a multivariate polynomial ring is no different than for univariate, but if we want an array of variables, here is an easier construction.
Sage can also perform more advanced computations, such as Gröbner bases and quotient rings.
There are a number of other basic algebraic objects in Sage. We give a few of them here:
=
QQbar
-adics
Zp(p)
(universal) cyclotomic fields
power series (either with finite precision or lazily computed)
Laurent polynomials
finite fields
You can always start typing something you want and hit <tab>
to see if it is in Sage. Note that capitalization matters!.
As previously mentioned, Sage is built upon Python, which means we can write our own functions and loops to test things and construct examples. Below, we compute the number of polynomials with increasing coefficients in degree 1 to 20 over that are divisible by .
We can then take this data and plug it into OEIS and find that it is http://oeis.org/A007997. If we do , then we get http://oeis.org/A008646. For , we obtain http://oeis.org/A032192. This then suggests we should try it for , and we get http://oeis.org/A008610.
Sage also has a lot of builtin features for many different fields in mathematics, including:
(algebraic) combinatroics (including matroid theory, graph theory)
number theory
(algebraic) geometry
group theory
Next, if we want to generalize this to (or any simple Lie algebra), we need to discuss root systems: a finite set of vectors closed under reflections in with no scalar multiples. The root systems for are , , , and .
You can find an extended tutorial for the visualization of root systems here: http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/root_system/plot.html
To every (crystallographic) root system, there is an associated Lie algebra. However, the example we did before was a bit complicated. So we can simplify things by using crystals, which are certain edge-colored directed graphs. For , they have an interpretation using partitions and semistandard tableaux with entries at most .
We first use Sage to list all such semistandard tableaux.
This is built up by using the tensor product rule from the vector representation of .
In fact, as the partition gets larger (by containment), we have an embedding of crystals. The direct limit is called and the crystal of every finite-dimensional representation is contained within .
If we consider the (stable) characters of , these are specific symmetric functions called Schur functions. More generally, Sage provides a very expansive implementation of symmetric functions, including all of the classical bases, the character bases of of recent work of Orellana-Zabrocki (i.e., structure coefficients are stable Kronecker coefficients), Hall-Littlewood polynomials, Jack polynomials, and Macdonald polynomials. It can also computer other products, such as the Kronecker product, plythesyms, Hopf algebra computations, and other related objects such as -Schur functions and Stanley symmetric functions.
For a more detailed tutorial, see this SageMath tutorial. We do some basic computations here to demonstrate how to work with symmetric functions.
Sage also has generalizations of the ring of symmetric functions, including quasisymmetric functions (QSym), non-commutative symmetric functions (NCSF, which is Hopf dual to QSym), and symmetric functions in non-commutative variables (NCSym) (and its Hopf dual). As they have multiple bases, like symmetric functions, we need to specify the bases we want to work with.
For more detailed information, see
http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/ncsf_qsym/tutorial.html
http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/ncsf_qsym/qsym.html
http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/ncsf_qsym/ncsf.html
http://doc.sagemath.org/html/en/reference/combinat/sage/combinat/ncsym/ncsym.html