Sage 9.4 Release Tour

current development cycle (2021)

Symbolics

Extended interface with SymPy

The SymPy package has been updated to version 1.8.

SageMath has a bidirectional interface with SymPy. Symbolic expressions in Sage provide a _sympy_ method, which converts to SymPy; also, Sage attaches _sage_ methods to various SymPy classes, which provide the opposite conversion.

In Sage 9.4, several conversions have been added. Now there is a bidirectional interface as well for matrices and vectors. #31942

sage: M = matrix([[sin(x), cos(x)], [-cos(x), sin(x)]]); M
[ sin(x)  cos(x)]
[-cos(x)  sin(x)]
sage: sM = M._sympy_(); sM
Matrix([
[ sin(x), cos(x)],
[-cos(x), sin(x)]])
sage: sM.subs(x, pi/4)           # computation in SymPy
Matrix([
[ sqrt(2)/2, sqrt(2)/2],
[-sqrt(2)/2, sqrt(2)/2]])

Work is underway to make SymPy's symbolic linear algebra methods available in Sage via this route.

Sage has added a formal set membership function element_of for use in symbolic expressions; it converts to a SymPy's Contains expression. #24171

Moreover, all sets and algebraic structures (Parents) of SageMath are now accessible to SymPy by way of a wrapper class SageSet, which implements the SymPy Set API. #31938

sage: F = Family([2, 3, 5, 7]); F
Family (2, 3, 5, 7)
sage: sF = F._sympy_(); sF
SageSet(Family (2, 3, 5, 7))          # this is how the wrapper prints
sage: sF._sage_() is F
True                                  # bidirectional
sage: bool(sF)
True
sage: len(sF)
4
sage: sF.is_finite_set                # SymPy property
True

Finite or infinite, we can wrap it:

sage: W = WeylGroup(["A",1,1])
sage: sW = W._sympy_(); sW
SageSet(Weyl Group of type ['A', 1, 1] (as a matrix group acting on the root space))
sage: sW.is_finite_set
False
sage: sW.is_iterable
True
sage: sB3 = WeylGroup(["B", 3])._sympy_(); sB3
SageSet(Weyl Group of type ['B', 3] (as a matrix group acting on the ambient space))
sage: len(sB3)
48

Some parents or constructions have a more specific conversion to SymPy. #31931, #32015

sage: ZZ3 = cartesian_product([ZZ, ZZ, ZZ])
sage: sZZ3 = ZZ3._sympy_(); sZZ3
ProductSet(Integers, Integers, Integers)
sage: (1, 2, 3) in sZZ3

sage: NN = NonNegativeIntegers()
sage: NN._sympy_()
Naturals0

sage: (RealSet(1, 2).union(RealSet.closed(3, 4)))._sympy_()
Union(Interval.open(1, 2), Interval(3, 4))

sage: X = Set(QQ).difference(Set(ZZ)); X
Set-theoretic difference of
 Set of elements of Rational Field and
 Set of elements of Integer Ring
sage: X._sympy_()
Complement(Rationals, Integers)

sage: X = Set(ZZ).difference(Set(QQ)); X
Set-theoretic difference of
 Set of elements of Integer Ring and
 Set of elements of Rational Field
sage: X._sympy_()
EmptySet

See Meta-ticket #31926: Connect Sage sets to SymPy sets

ConditionSet

Sage 9.4 introduces a class ConditionSet for subsets of a parent (or another set) consisting of elements that satisfy the logical "and" of finitely many predicates.

The name ConditionSet is borrowed from SymPy. In fact, if the given predicates (condition) are symbolic, a ConditionSet can be converted to a SymPy ConditionSet; the _sympy_ method falls back to creating a SageSet wrapper otherwise.

symbolic_expression(lambda x, y: ...)

Sage 9.4 has added a new way to create callable symbolic expressions. #32103

The global function symbolic_expression now accepts a callable such as those created by lambda expressions. The result is a callable symbolic expression, in which the formal arguments of the callable are the symbolic arguments.

Example:

symbolic_expression(lambda x,y: x^2+y^2) == (SR.var("x")^2 + SR.var("y")^2).function(SR.var("x"), SR.var("y"))

This provides a convenient syntax in particular in connection to ConditionSet.

Instead of

sage: predicate(x, y, z) = sqrt(x^2 + y^2 + z^2) < 12  # preparser syntax, creates globals
sage: ConditionSet(ZZ^3, predicate)

one is now able to write

sage: ConditionSet(ZZ^3, symbolic_expression(lambda x, y, z: 
....:     sqrt(x^2 + y^2 + z^2) < 12))

Convex geometry

ABC for convex sets

Sage 9.4 has added an abstract base class ConvexSet_base (as well as abstract subclasses ConvexSet_closed, ConvexSet_compact, ConvexSet_relatively_open, ConvexSet_open) for convex subsets of finite-dimensional real vector spaces. The abstract methods and default implementations of methods provide a unifying API to the existing classes Polyhedron_base, ConvexRationalPolyhedralCone, LatticePolytope, and PolyhedronFace. #31919, #31959, #31990

As part of the API, there are new methods for point-set topology such as is_open, relative_interior, and closure. For example, taking the relative_interior of a polyhedron constructs an instance of RelativeInterior, a simple object that provides a __contains__ method and all other methods of the ConvexSet_base API. #31916

sage: P = Polyhedron(vertices=[(1,0), (-1,0)])
sage: ri_P = P.relative_interior(); ri_P
Relative interior of
 a 1-dimensional polyhedron in ZZ^2 defined as the convex hull of 2 vertices
sage: (0, 0) in ri_P
True
sage: (1, 0) in ri_P
False

ConvexSet_base is a subclass of the new abstract base class Set_base. #32013

This makes various methods that were previously only defined for sets constructed using the Set constructor available for polyhedra and other convex sets. As an example, we can now do:

sage: polytopes.cube().union(polytopes.tetrahedron())                                                                                                                                                
Set-theoretic union of 
 Set of elements of A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices and 
 Set of elements of A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 4 vertices

Polyhedral geometry

Manifolds

Defining submanifolds and manifold subsets by pullbacks from Sage sets

pullbacks #31688

Polyhedron.affine_hull_manifold #31659

Families and posets of manifold subsets

Meta-ticket #31740

Configuration changes

Support for system gcc/g++/gfortran 11 added

Sage can now be built using GCC 11. #31786

This enables building Sage using the default compiler on Fedora 34, and on macOS with homebrew using the default compilers. (Previously, in Sage 9.3, specific older versions of the compilers had to be installed.)

Support for system Python 3.6 dropped

It was already deprecated in Sage 9.3. #30551

It is still possible to build the Sage distribution on systems with old Python versions, but Sage will build its own copy of Python 3.9.x in this case.

Support for optional packages on systems with gcc 4.x dropped

Sage is phasing out its support for building from source using very old compilers from the gcc 4.x series.

As of Sage 9.4, on systems such as ubuntu-trusty (Ubuntu 14.04), debian-jessie (8), linuxmint-17, and centos-7 that only provide gcc from the outdated 4.x series, it is still supported to build Sage from source with the system compilers. However, building optional and experimental packages is no longer supported, and we have removed these configurations from our CI. #31526

Users in scientific computing environments using these platforms should urge their system administrators to upgrade to a newer distribution, or at least to a newer toolchain.

For developers: ./configure --prefix=SAGE_LOCAL --with-sage-venv=SAGE_VENV

Sage 9.4 makes it possible to configure the build to make a distinction between:

Package installation records are kept within each tree, and thus separately. This allows developers to switch between different system Python versions without having to rebuild the whole set of non-Python packages. See #29013 for details.

Package upgrades

Availability of Sage 9.4 and installation help

The first beta of the 9.4 series, 9.4.beta0, was tagged on 2021-05-26.

More details