<<

Sage Introduction Student Seminar in Combinatorics: Mathematical Software

CHRISTIAN SCHNEEBELI ETH Zürich, D-MATH December 8, 2014

Abstract This report will outline the idea of the sage project and show the extensive possibilities by referencing to the included packages and by giving various examples for group theory.

The Sage project

William A. Stein is the initiator of the Sage project and he started it because he had following problems with the commercial solutions like Matlab, Magma, Mathematica and such: Firstly, he was a professor and liked to use Magma in his analysis lectures to be able to give the students an image of the content matter. The idea was, that they can reuse and play with his examples. But for most students Magma was just to expensive. So he was looking for a free solution. Secondly he thought that its highly contra-productive from a scientific point of view that the source-code of the complex and fast algorithms imple- mented in these commercial solution aren’t publicly accessible. Therefore the intellectual community can’t learn from and improve these algorithms. Thats why he started the Sage project with this idea: "Creating a viable open-source alternative to Magma, , Mathematica, and Matlab" 1 While this "viable" means, that Sage should have all the functionalities of the commercial solutions in comparable speed. And in fact some of them are even faster.2 1http://www.sagemath.org/help-video.html 2http://www.sagemath.org/tour-benchmarks.html

1 Power of Sage

By now this idea is nearly realized. The possibilities are almost as widespread as those of i.e. Matlab. On www.sagemath.org/tour.html a brief description is given by this sentence: "Sage can be used to study elementary and advanced, pure and . This includes a huge range of mathematics, including basic algebra, calculus, elementary to very advanced number theory, cryptogra- phy, numerical computation, commutative algebra, group theory, combinatorics, graph theory, exact linear algebra and much more." So basically one can use Sage in almost every branch of mathematics and its for students as well as for researchers. It’s very useful for com- putable experimentations and in fact SAGE originally stood for Software for Arithemic Geometry Experimentation.3 due to the fact that the project shortly integrated much more then arithmetic geometry the acronym SAGE simply was changed to the name Sage. But now the question arises: How that Sage could realize all the function- alities? And that by distributing the application for free and open-source. Of course they couldn’t develop everything on their own. They noticed, that there are many open-source packages out there for different kind of problems, so they needn’t to reinvent the wheel but rather to connect all those packages. And that’s exactly the idea of sage: to create an interface for this large amount of already implemented packages and libraries that fits them together clean and easy to use. This is the huge power of Sage and how the developers describe Sage on the front-page of sagemath.org: "Sage is a free open-source mathematics software system licensed under the GPL. It builds on top of many ex- isting open-source packages: NumPy, SciPy, matplotlib, Sympy, , GAP, FLINT, R and many more. Access their combined power through a common, Python-based language or directly via interfaces or wrappers." This also highlights another strength: one simply codes with Python, which is a common programming language. You don’t need to learn a new metalanguage as in most of the included packages and as in Matlab. Additionally to the included code, the Sage community also wrote about half a million new lines of code and thereby integrated many functionalities that aren’t in any other library.

3http://www.sagemath.org/help-video.html

2 As Sage is developed and enhanced by many different programmers and in principal every free developer can contribute to the project, there must be a clear documentation and help system, otherwise one couldn’t see the wood for the trees. Therefore the community is willing to keep the code neat by commenting every function, describing its usage and giving some examples. Furthermore there are tutorials and documentations for the bigger packages. And finally lets talk about the usability. Sage can be run in a command window or in any browser. Both are the UI (User Interface) as well as the IDE (integrated development environment), so you don’t need to install a separate IDE. This may sounds like a useless development environment but actually it’s very user-friendly:

1. If you don’t know a functions name you can type the first two letters and press to get a list of all functionalities with this prefix. 2. If you have the function-name but you aren’t sure how to call it, just press and you see the functions description. 3. If you created an object and you wonder what you can achieve with it, just type objectname. to see a list of all methods you can use with this object. 4. If you think: "that’s a nice function", write functionname?? to see the fully commented source-code.

As you will see in the last part of this report, once you defined an object and run the code you can access it in every code you write in the same worksheet. So you can easily create an variable, call a function to change it and print it to see if it looks as expected, in three different coding parts. And if you are solving a problem and do not erasing any code, then you have a nice history of the way you solved it. This is the advantage of having the UI and IDE, respectively execution and coding in the same frame.

3 Packages

Here is a list of some of the packages/libraries in Sage.4

Subject Package Algebra GAP, Maxima, Singular Algebraic geometry Singular Arbitrary precision arithmetic MPIR, MPFR, MPFI, NTL, mp- math Arithmetic geometry PARI/GP, NTL, mwrank, ecm Calculus Maxima, SymPy, GiNaC Combinatorics Symmetrica, Sage-Combinat Linear algebra ATLAS, BLAS, LAPACK, NumPy, LinBox, IML, GSL Graph theory NetworkX Group theory GAP Numerical computation GSL, SciPy, NumPy, ATLAS Number theory PARI/GP, FLINT, NTL Statistical R, SciPy As one can see there are many famous libraries. For example: GAP, Singular, Maxima, PARI and R.

4For a full list go to: http://www.sagemath.org/download-packages.html This list is from en.wikipedia.org/wiki/Sage_(mathematics_software)

4 Examples Group Theory (GAP)

To get started we need a group and as for many subjects there is a tutorial for group theory5, which shows that many common permutation groups are implemented. So lets create a alternatingroup and see what we can do with this new object by pressing :

Figure 1: List of all the methods for the object A.

With type(A) one can see the type of an object which is sage.groups.perm_gps.permgroup_named.AlternatingGroup_with_category for this object A. On the next page are some examples of functions from the list:

5http://www.sagemath.org/doc/thematic_tutorials/group_theory.html

5 Figure 2: Examples of some properties of a group object

6 So we learned that the quotient of the dihedral group of order 8 with the subgroup generated by (1,3,5,7)(2,4,6,8) is isomorphic to the Kleinfour- group. The Kleinfour-group is not the only small group that is implemented. In fact all groups up to order 16 are integrated.6 An impressive function is cayley_graph combined with the show3d method, which loads an interactive graphic of the operation of the generators on each element of the group (there are three generators for S4 illustrated by the three colors red,blue,green). This graphic can be rotated and zoomed which gives a very neat idea of the cayley-graph:

Figure 3: Examples of well-colored cayley-graph of S4

6http://www.sagemath.org/doc/thematic_tutorials/group_theory.html (at the bottom)

7 Most of the functions used in the examples are not genuinely from the GAP-package but call a GAP-function at some point in the code. To work directly with the GAP objects and methods you need to transform the group to a GAP-group. With this new object one have an almost never-ending list of possibilities:

Figure 4: Examples of some properties of a group object

8 To conclude: Sage is a powerful, user-friendly, open-source application to calculate and illustrate many mathematical problems. And it is still growing rapidly every year.

References

All the information is from the original Sage web-page www.sagemath.org The examples are self-created on basis of the tutorials.

9