Module 28 of 39

Matrix algorithms: Gaussian elimination and linear systems

Connect linear systems, matrix factorization, inversion, and least squares while respecting numerical limits.

Many questions can be written as a set of linear equations. Suppose two products use different amounts of material and labor, and we know the totals. We may want to recover how many of each product were made. Write the coefficients in a matrix A, the unknown quantities in a vector x, and the totals in a vector b. The problem becomes Ax = b.

Background for this page. You need basic algebra and matrix dimensions. A matrix stores coefficients; a vector stores a list of unknowns or totals. Multiplying A by x combines coefficients with unknowns. Related explanations: Matrices: dimensions, products, and transposes · Divide and conquer: merge sort and recurrences.

One way to solve it is Gaussian elimination: use row operations to remove unknowns until the equations are easy to solve backward. A matrix factorization records those operations so we can reuse them. An LUP decomposition writes PA = LU for a suitable square matrix A. The permutation P records row swaps; L is lower triangular and U is upper triangular. We can then solve triangular systems instead of starting over from the original equations each time.

Valid row operations preserve the system's solutions.

An inverse matrix A⁻¹, when it exists, satisfies A⁻¹A = I. That suggests writing x = A⁻¹b. In actual numerical work, explicitly forming an inverse is often unnecessary when all we need is one solution. Solving the factored system is usually the more direct approach. Some matrices are singular and have no inverse; a method must detect or handle that case.

Sometimes there are more equations than unknowns, and no single x satisfies them all exactly. Least squares asks for the x that makes the sum of squared residuals as small as possible. A symmetric positive-definite matrix has useful properties that make certain factorizations and solutions well behaved in exact mathematics. In floating-point computation, we must also care about numerical stability: tiny rounding errors can grow during a calculation, especially for an ill-conditioned problem. A fast asymptotic bound alone does not tell us whether numerical answers will be trustworthy.

These matrix methods share useful design principles. Matrix multiplication can be reorganized with divide and conquer. Solving many systems with the same coefficient matrix rewards reusing a factorization. The right algorithm depends on matrix shape, whether we need one answer or many, and how accurate the answer must be.

Eliminate one unknown and verify the answer

Solve 2x+y=5 and x+y=3. Subtract half the first equation from the second. This gives y/2=1/2, so y=1. Substitute into the first equation: 2x+1=5, giving x=2. Check both originals: 4+1=5 and 2+1=3. Verification against the original system catches mistakes introduced during transformation.

If the pivot coefficient is zero, division is invalid. A row exchange may supply a nonzero pivot. If all candidates vanish, the system may lack a unique solution; it needs further analysis. With floating-point values, a tiny pivot can amplify rounding errors. Partial pivoting chooses a large available pivot in the current column to improve numerical behavior, though it does not cure every ill-conditioned problem.

Practice. If you must solve Ax = b for one vector b, why might you avoid explicitly computing A⁻¹? What changes if the same A is used for many different right-hand sides?

Answer. A factorization lets us solve the system directly without forming the whole inverse. If A is reused, we can compute its factorization once and solve a new triangular system for each new b.

Try another case. Do x+y=2 and 2x+2y=5 have a solution?

Reasoning. No. Doubling the first gives 2x+2y=4, contradicting the second. Elimination exposes an inconsistent zero-coefficient row with a nonzero right-hand side.

View the full course and choose another topic.

Image preview

Fit