Sage 9.5 Release Tour

released Jan 30, 2022


Changes to symbolic expressions

Interface to Mathics, a free implementation of the Wolfram language

Sage now has an optional package providing Mathics, a free (open-source) general-purpose computer algebra system featuring Mathematica-compatible syntax and functions, and an interface to it.#31778

Linear Algebra


The full list of changes is available in this changelog.

De Rham cohomology and characteristic classes

The de Rham cohomology has been made an algebra (#32270).

The method characteristic_class for vector bundles is now outdated and replaced by the method characteristic_cohomology_class. This change reflects the difference between characteristic classes, seen as natural transformations, and characteristic cohomology classes in a more rigorous way (see #29581). The previous usability and syntax remains intact. Among other things, the following has been changed:

Furthermore, new features have been added. For example, characteristic cohomology classes now form an algebra:

sage: M = Manifold(4, 'M')
sage: E = M.vector_bundle(2, 'E', field='complex')
sage: R = E.characteristic_cohomology_class_ring(); R
Algebra of characteristic cohomology classes of the Differentiable complex vector bundle E -> M of rank 2 over the base space 4-dimensional differentiable manifold M
sage: R.gens()
[Characteristic cohomology class (c_1)(E) of the Differentiable complex vector bundle E -> M of rank 2 over the base space 4-dimensional differentiable manifold M,
 Characteristic cohomology class (c_2)(E) of the Differentiable complex vector bundle E -> M of rank 2 over the base space 4-dimensional differentiable manifold M]
sage: c_1, c_2 = R.gens()

Therefore, elements can be added and multiplied:

sage: c_1 + c_2
Characteristic cohomology class (c_1 + c_2)(E) of the Differentiable complex vector bundle E -> M of rank 2 over the base space 4-dimensional differentiable manifold M
sage: c_1 * c_1
Characteristic cohomology class (c_1^2)(E) of the Differentiable complex vector bundle E -> M of rank 2 over the base space 4-dimensional differentiable manifold M

Additive, multiplicative and Pfaffian cohomology classes are now related to the generators of the characteristic cohomology class ring via additive/multiplicative sequences:

sage: ch = E.characteristic_cohomology_class('ChernChar'); ch
Characteristic cohomology class ch(E) of the Differentiable complex vector bundle E -> M of rank 2 over the base space 4-dimensional differentiable manifold M
sage: ch == 2 + c_1 + c_1^2 / 2 - c_2  # additive sequence of exp(x)

As for the tangent bundle of a manifold, as long as an orientation and a metric is provided, the characteristic form of the Euler class (and therefore all Pfaffian classes) w.r.t. the Levi-Civita connection is now computed automatically (previously, a compatible curvature form matrix had to be provided by the user):

sage: M.<x,y> = manifolds.Sphere(2, coordinates='stereographic')
sage: g = M.metric()
sage: nab = g.connection()
sage: nab.set_immutable()
sage: TM = M.tangent_bundle()
sage: e = TM.characteristic_cohomology_class('Euler'); e
Characteristic cohomology class e(TS^2) of the Tangent bundle TS^2 over the 2-sphere S^2 of radius 1 smoothly embedded in the Euclidean space E^3
sage: e_form = e.get_form(nab)
sage: e_form
Mixed differential form e(TS^2, nabla_g) on the 2-sphere S^2 of radius 1 smoothly embedded in the Euclidean space E^3
sage: e_form.display_expansion()
e(TS^2, nabla_g) = 2/(pi + pi*x^4 + pi*y^4 + 2*pi*x^2 + 2*(pi + pi*x^2)*y^2) dx∧dy

Automatic coordinate change in curve plots

The method plot of curves is now allowed to perform a coordinate change to make the plot in terms of the coordinates specified via the argument chart, in case the curve is not known in these coordinates (#32578). For example, a cardioid is defined in terms of polar coordinates:

sage: E.<r, phi> = EuclideanSpace(coordinates='polar')
sage: c = E.curve((1 + cos(phi), phi), (phi, 0, 2*pi))
sage: c.display()
(0, 2*pi) → E^2
   phi ↦ (r, phi) = (cos(phi) + 1, phi)

and its plot in terms of Cartesian coordinates can now be obtained simply by

sage: c.plot(chart=E.cartesian_coordinates(), aspect_ratio=1)

The above command has triggered the computation of the curve's expression in terms of Cartesian coordinates:

sage: c.display()
(0, 2*pi) → E^2
   phi ↦ (r, phi) = (cos(phi) + 1, phi)
   phi ↦ (x, y) = (cos(phi)^2 + cos(phi), (cos(phi) + 1)*sin(phi))

Internal code improvements and bug fixes

Various improvements have been performed in the internal code, some of them in view of SageMath modularization:

Some bugs have been fixed: #31781, #32457, #32355, #32929.

Number theory


Binary quadratic forms

Prime counting

Elliptic curves and isogenies


Modular and quasimodular forms

David Ayotte's project in the 2021 Google Summer of Code has brought major new features and improvements to modular forms:

Also a conversion bug between spaces of modular forms was fixed. See Meta-ticket #31560 for an overview of tickets.


Lie algebras

New lazy Laurent series backend

The lazy Laurent series has been nearly completely rewritten using a new backend coefficient stream with a cache has both sparse and dense formatted input. This has been designed to increase speed and be very flexible. This has also been extensively doctested to make sure the code is robust. This constituted Tejavsi Chebrolu's 2021 GSoC project (metaticket). This is meant to be the eventual replacement of the coefficient streams used in the species code (including for lazy power series), which is known to be buggy (see, e.g., #15673). This also extends the functionality to include:

Lazy Dirichlet series

As a demonstration of the flexibility for the coefficient stream framework for lazy Laurent series, we also implement lazy Dirichlet series. We also give this a structure of a valuation ring by using the log of degree of the lowest nonzero coefficient.

Invariant algebras

A specialization of the invariant rings for finite dimensional vector spaces under an group actions were implemented for the Orlik-Solomon and Orlik-Terao algebras as part of Trevor Karn's GSoC project.

Package upgrades

Sage 9.5 continues to support system installations of Python 3.7.x, 3.8.x, and 3.9.x. New in Sage 9.5 is experimental support for system Python 3.10.x. If no suitable system Python is found, Sage builds its own copy from source; the SPKG has been upgraded to version 3.9.9. #30766, #32853

lcalc has been upgraded to the new 2.x series maintained by the Sage team (Release notes). #32037, #33043

NumPy has been upgraded from 1.20.3 to the 1.21 series, see the release notes.

SciPy has been upgraded from 1.6.3 to the 1.7 series, see the release notes.

Matplotlib has been upgraded from 3.3.4 to the 3.5 series. #31580, #33040

NetworkX has been upgraded from 2.5.1 to the 2.6 series, bringing various new features and improvements, see the changelog.

SymPy has been upgraded from 1.8 to 1.9, see the release notes.

polymake has been upgraded from 4.4 to 4.5, see the release notes. On macOS, Sage is now also able to use a polymake installation made via Homebrew.

IPython and Jupyter packages have been upgraded. In particular, notebook has been upgraded from 6.1.1 to the 6.4 series, see the changelog. #31280, #32930, #33020

For a list of all packages and their versions, see

Configuration changes

Separate virtual environment for Python packages

In non-incremental builds from source, Sage now defaults to setting up the virtual environment for the Python packages in a directory separate from SAGE_ROOT/local. #32442

At the end of a run of ./configure, you will see messages like the following:

config.status: executing links commands
config.status: creating convenience symlink prefix -> local
config.status: creating convenience symlink venv -> local/var/lib/sage/venv-python3.9

The symbolic link SAGE_ROOT/venv points to the location of the virtual environment. It depends on the version of Python that is in use. The symbolic link is not needed for build or runtime; it is only provided for convenience.

The previous behavior can be restored by using ./configure --without-sage-venv.

Thanks to this new default, it has become easier for developers to work with several Python versions: There is no need to run make distclean or similar if you want to switch to a different Python version; just reconfigure using ./configure --with-python3=..... The SageMath distribution keeps the installation records for Python packages separately for each venv.

New default: configure --with-system-gcc=force

The Sage distribution no longer attempts to build its own gcc if no suitable C/C++ compilers can be found. Instead, configure will exit with an error in this situation. #32060

The previous behavior can be restored by using ./configure --with-system-gcc=yes; alternatively, you can use ./configure --with-system-gcc=no.

New option: configure --disable-doc

If you do not intend to build the Sage documentation from source, you can now use ./configure --disable-doc. It suppresses the installation of several packages that are only needed for docbuilding and makes make (or make all) equivalent to make build. #32759

Packages atlas and mpir removed

The package atlas, which could be used as an alternative to openblas, and the corresponding configure options have been removed. #30350

The package mpir, which could be used as an alternative to gmp, and the corresponding configure options have been removed. #32549, #32727

psutil package removed

The psutil (memory management) python package has been removed. The version within sage was heavily patched and no longer feasible to maintain, and the upstream version is incompatible with one of our supported platforms. #32656

System singular detection

Sage is now able to use a suitable version of the Singular package from the system if one is detected by the ./configure script. #29024

For developers and packagers: Modularization and packaging changes

Sage 9.5 contains many changes that were made as part of the modularization project described in #29705 and in the new section of the developer's guide, Packaging the Sage Library.

New distribution package on PyPI: sage-setup

The build system of the Sage library, sage_setup, is now provided by a separate distribution package sage-setup. The source tree is the subdirectory pkgs/sage-setup/ of the Sage git repository. #29847

Since 9.5.rc0, the distribution packages sage-conf, sage-docbuild, sage-setup, sage-sws2rst, and sagemath-standard are uploaded automatically to PyPI on each release tag by a GitHub Actions workflow. #32062

Pynac merged into the Sage library

The core of the symbolic expressions subsystem of Sage, an adaptation of the GiNaC library to Python known as Pynac, has been merged into the Sage library source code as src/sage/symbolic/ginac/; all future development of Pynac is intended to happen here. #32386, #32387

Doctest annotation "# optional - FEATURE" for portions of the Sage library

In the Sage doctesting framework, a line of tests can be conditionalized on the presence of a feature, such as an installed optional package, using a comment of the form # optional - FEATURE.

In Sage 9.5, doctests can also be conditionalized on the presence of certain parts of the Sage library. #32614

For example, doctests that depend on the Symbolic Ring can be marked # optional - sage.symbolic, and doctests that need number fields can be marked # optional - sage.rings.number_field.

Also various runtime tests for external programs have been rewritten as Features. #27744, #32174, #32649, #32650, #32866, #32926

Module-level annotation "# sage.doctest: optional - FEATURE"

Moreover, Sage 9.5 extends this mechanism by allowing developers to mark all doctests in a Python file as conditional on a feature. #30778

These module-level directives go to the top of the source file and take the form

# sage.doctest: optional - FEATURE

Abstract base classes for "isinstance" testing

The new module defines a number of abstract base classes that can be used for isinstance testing with parent classes instead of importing is_... functions from various implementation modules. #32566, #32600, #32606, #32610, #32612, #32660, #32665, #32719, #32742, #32750

In a similar way, defines abstract base classes Polyhedron, ConvexRationalPolyhedralCone, etc. #32637

Likewise, sage.structure.element now defines an abstract base class Expression that can be used for isinstance testing, instead of importing is_Expression or the implementation class Expression from sage.symbolic.expression. #32638, #32730

See also Meta-ticket #32414.

Deprecated and removed functionality

Availability of Sage 9.5 and installation help

Sage 9.5 was released on 2022-01-30.


The Sage source code is available in the sage git repository, and the self-contained source tarballs are available for download.

SageMath 9.5 supports most platforms that were supported by Sage 9.4 and adds support for building on recent Linux distributions that use glibc ≥ 2.34 (fedora-35, ubuntu-impish, ubuntu-jammy, archlinux-latest, etc.) #32756

Sage 9.5 has dropped support for debian-jessie with the default compiler, GCC 4.9.x. This has allowed us to upgrade the package primecount to the latest version, which has stricter requirements for C++ 11, and to make it a standard package. (Sage 9.5 still supports distributions with compilers from the GCC 4.8.x series, such as ubuntu-trusty.) #25009

Here is a summary of the platforms on which Sage 9.5 is known to build from source. (On platforms marked with the superscript ⁺, installing optional packages is not supported unless you upgrade the toolchain (gcc, binutils).)

Sage 9.5 has initial support for system Python 3.10.x. It continues to support Python 3.7.x, 3.8.x, 3.9.x. #30766

Availability as binaries and in distributions


See in the source distribution for installation instructions.

See sage-release, sage-devel.

More details

ReleaseTours/sage-9.5 (last edited 2022-02-06 20:55:34 by mkoeppe)