Overview

SymPy 1.11, released on August 14, 2022, improves code generation and algebraic capabilities.

Main Features

Code generation

The codegen module is improved to generate optimized C, Fortran, and Python code from symbolic expressions.

python
from sympy import symbols, sin, cos
from sympy.utilities.codegen import codegen

x, y = symbols('x y')
expr = sin(x) ** 2 + cos(y) ** 2

# Generate C code
[(name, code), (name_h, header)] = codegen(
    ('f', expr), 'C', header=False
)
print(code)

Improved algebra

Algebraic simplifications and equation solvers are more performant, with better handling of nonlinear systems.

python
from sympy import symbols, solve, Eq

x, y = symbols('x y')

# Nonlinear equation system
equations = [
    Eq(x**2 + y**2, 25),
    Eq(x + y, 7),
]
solutions = solve(equations, [x, y])
print(solutions)  # [(3, 4), (4, 3)]

Sources