What is Sagemath?¶

SageMath is a free open-source mathematics software system licensed under the GPL. It builds on top of many existing open-source packages: NumPy, SciPy, matplotlib, Sympy, Maxima, GAP, FLINT, R and many more.

Mission: Creating a viable free open source alternative to Magma, Maple, Mathematica and Matlab.

Free¶

  • Freedom to run the program as you wish, for any purpose.
  • The freedom to study how the program works, and change it so it does your computing as you wish.
  • The freedom to redistribute copies so you can help your neighbor.
  • The freedom to distribute copies of your modified versions to others. By doing this you can give the whole community a chance to benefit from your changes.

Open source¶

You can read Sylow's Theorem and its proof in Huppert's book in the library without even buying the book and then you can use Sylow's Theorem for the rest of your life free of charge, but...for many computer algebra systems license fees have to be paid regularly for the total time of their use.

— J. Neubüser. An invitation to computational group theory. 1995.

Open source¶

  • Open access: everyone can read
  • Open development: everyone can contribute
  • Open management: everyone can decide

History of Sage¶

  • Started in 2005 by William Stein as SAGE = Software for Algebra and Geometry Exploration (read William's recollections from that time)
  • 2006: development of the Sage Notebook Web UI
  • Sage 8 (2017): Jupyter becomes the default UI
  • Sage 9 (2020): migrated to Python 3
  • Sage 10 (2023): development migrated to GitHub

What's in Sage?¶

  • C libraries: BLAS, GMP, FLINT, NTL, fplll, ...
  • Python libraries: NumPy, SciPy, mpmath, matplotlib ...
  • Mathematical systems: Pari/GP, GAP, Maxima, Singular, ...
  • Interfaces: gmpy, fpylll, cypari, ...
  • Glue code written in Python/Cython
  • Native code written in Python
  • Preparser for the Sagemath language
  • Jupyter notebook web UI

Using Sage¶

  • Terminal REPL based on IPython: type sage
  • Jupyter Notebook Web UI: type sage -n
  • JupyterLab cloud environment
  • Running Python scripts: type: sage myscript.py
  • Running Sagemath scripts through the preparser: type sage myscript.sage

Interactive¶

In [4]:
2^4
Out[4]:
16
In [5]:
preparse('2^4')
Out[5]:
'Integer(2)**Integer(4)'
In [6]:
2**4
Out[6]:
16
In [7]:
preparser(False)
In [8]:
2^4
Out[8]:
6

Types and parents¶

In [9]:
preparser(True)
In [10]:
a = 2^4
type(a)
Out[10]:
<class 'sage.rings.integer.Integer'>
In [11]:
type(int(16))
Out[11]:
<class 'int'>
In [12]:
parent(a)
Out[12]:
Integer Ring
In [13]:
Integers()
Out[13]:
Integer Ring
In [14]:
ZZ
Out[14]:
Integer Ring
In [15]:
ZZ.random_element()
Out[15]:
-1
In [16]:
ZZ.cardinality()
Out[16]:
+Infinity
In [17]:
parent(2)
Out[17]:
Integer Ring
In [18]:
parent(2/1)
Out[18]:
Rational Field

Tab completion and function discovery¶

In [ ]:
ZZ.  # hit tab key
In [ ]:
search_doc("isogeny")
In [ ]:
search_src("isogeny")

Docs and source code¶

In [ ]:
ZZ?
In [ ]:
ZZ??
In [20]:
import_statements(ZZ)
# ** Warning **: several names for that object: Z, ZZ
from sage.rings.integer_ring import Z

Contributing to Sage¶

  • Clone and compile from source: https://github.com/sagemath/sage/
  • Familiar GitHub workflow: Pull Requests, Issues
  • Automated testing and CI
  • Every PR is peer reviewed
  • Community guidelines and CoC to resolve disputes

What are Sage Days?¶

Your next step in Sage:

  • Discover Python/Sage
  • Become a developer
  • Test, fix bugs
  • Implement new functionalities
  • Plan for the future, boost your career
  • Make new friends!