Overview

SymPy 1.9, released on October 10, 2021, brings significant performance improvements for symbolic computation and the equation solver.

Main Features

Performance improvements

Simplification and substitution operations are significantly faster thanks to better internal caching and optimized comparison algorithms.

python
from sympy import symbols, expand, factor, simplify

x, y = symbols('x y')

# Improved simplification
expr = (x**2 + 2*x*y + y**2) / (x + y)
print(simplify(expr))  # x + y

# Faster factorization
poly = x**4 - y**4
print(factor(poly))  # (x - y)*(x + y)*(x**2 + y**2)

# Expansion
print(expand((x + y)**3))

Improved solver

The solve() equation solver handles nonlinear systems and transcendental equations better, with more complete results.

python
from sympy import symbols, solve, sin, cos, Eq

x, y = symbols('x y')

# Nonlinear system
solutions = solve([
    Eq(x**2 + y**2, 25),
    Eq(x + y, 7),
], [x, y])
print(f'Solutions: {solutions}')

# Transcendental equation
sol = solve(sin(x) - x/2, x)
print(f'sin(x) = x/2: {sol}')

Sources