Solve A·x = b
Shippingmatrix_solveSolve the linear system A·x = b directly via MKL LAPACK (preferred over forming A⁻¹)
Signature
Inputs
aSignal|Arrayrequired— The coefficient matrix $A$ (square 2-D).bSignal|Arrayrequired— The right-hand-side vector $b$.
Outputs
xVector— The solution vector $x$ satisfying $A x = b$.
Description
Solve A·x = b solves the linear system directly, dispatching to the MKL LAPACK backend (an LU factorization with partial pivoting). It is the correct, numerically stable way to invert a linear relationship — always preferred over computing matrix_inverse and multiplying, which is both slower and less accurate.
The coefficient matrix a is read as a 2-D matrix; the right-hand side b is read as a flat vector. The x output is the solution vector (dimensionless, per the toolkit's rank-≥2 convention). A singular or non-square coefficient matrix surfaces a graceful backend error rather than a panic.
Mathematics
Examples
A 2×2 system
With and , the x output is — the unique solution of the two equations and .
Applications
- Solving equilibrium / circuit / finite-element systems $A x = b$.
- Inverting calibration or mixing relationships to recover source quantities.
- Any place a naive graph might reach for matrix_inverse — solve is faster and more accurate.
Neat
It factorizes rather than inverting, so it inherits LU's stability and never materializes the (often ill-conditioned) explicit inverse.
The coefficient matrix and RHS use different readers — a 2-D matrix reader for A, a flat-vector reader for b — so shape handling matches the math exactly.
Known issues
A singular or numerically rank-deficient $A$ yields a backend error; for such systems use matrix_lstsq or matrix_pinv.
Non-square $A$ is rejected — use matrix_lstsq for over/under-determined systems.