Overview

SciPy 1.8, released on February 6, 2022, brings new linear algebra functions and improves solver performance.

Main Features

New linear algebra functions

The scipy.linalg module adds new decompositions and optimized solvers for structured linear systems.

python
from scipy import linalg
import numpy as np

# LU decomposition
A = np.array([[2, 1, 1], [4, 3, 3], [8, 7, 9]], dtype=float)
P, L, U = linalg.lu(A)
print(f'L diagonal: {np.diag(L)}')

# Linear system solving
b = np.array([1, 2, 3], dtype=float)
x = linalg.solve(A, b)
print(f'Solution: {x}')

Performance optimizations

Optimization and integration solvers have been accelerated through better use of underlying BLAS/LAPACK libraries.

python
from scipy import optimize
import numpy as np

# Function minimization
def rosenbrock(x):
    return (1 - x[0])**2 + 100 * (x[1] - x[0]**2)**2

result = optimize.minimize(
    rosenbrock, x0=[0, 0], method='L-BFGS-B'
)
print(f'Minimum: {result.x}')  # ~[1, 1]
print(f'Value: {result.fun:.6f}')  # ~0

Sources