Solving Linear Systems
Solve $Ax = b$.
Direct Methods
1import numpy as np
2from scipy.linalg import solve, lu
3
4# Direct solve
5x = np.linalg.solve(A, b)
6
7# LU decomposition
8P, L, U = lu(A)
Iterative Methods
1from scipy.sparse.linalg import cg, gmres
2
3# Conjugate gradient (for symmetric positive definite)
4x, info = cg(A, b)
5
6# GMRES (general)
7x, info = gmres(A, b)
Further Reading
Related Snippets
- Interpolation Methods
Linear, polynomial, and spline interpolation - Numerical Differentiation
Finite differences and automatic differentiation - Numerical Integration
Trapezoidal rule, Simpson's rule, Gaussian quadrature - Optimization Methods
Gradient descent, Newton's method, BFGS - Regularization Techniques
L1, L2, Tikhonov, and elastic net regularization - Root Finding Methods
Newton's method, bisection, and secant method