Direct linear solver (source code)

= Direct linear solver

A direct linear solver computes the solution of a finite <linear system> by a fixed sequence of algebraic eliminations or <matrix factorizations>, rather than successive approximate iterates until a stopping tolerance is met. For a nonsingular square matrix, a typical method uses <Pivoted LU decomposition> followed by forward and back substitution.

For $2x+y=1$ and $x+3y=2$, subtracting half the first row from the second gives $(5/2)y=3/2$. Hence $y=3/5$ and $x=1/5$. Elimination produces a triangular system whose unknowns are recovered in reverse order.

The adjective direct describes the method's finite algebraic structure; floating-point computation still incurs roundoff. Pivoting avoids unusable or dangerously small pivots, while the <condition number> controls how perturbations can affect the answer. Factoring a matrix once and reusing the factors can efficiently handle many different right-hand sides.