2 Matrices and Matrix Operations
A progressive guide to matrix notation, core operations, transposes, inverses, row reduction, and reliable computational methods for solving linear systems.
Reading and representing matrices
A is a rectangular array organized by rows and columns. If it has rows and columns, its size is , and an entry is written , where is the row number and is the column number.
For example,
has size , and its entry is . A square has the same number of rows and columns. A row has one row, while a column has one column.
The of size is written . Its main diagonal contains ones and all other entries are zero. The zero , written , contains zeros everywhere.
Matrices provide a compact form for linear systems. The equations
can be written as
The associated augmented is
Takeaway: Read indices as row first, column second, and use dimensions to determine which operations are possible.
Addition, equality, and scalar multiplication
Addition and subtraction are defined only for matrices with the same dimensions. The operations are performed entry by entry:
For example,
A scalar multiple multiplies every entry by the same scalar. Thus,
The zero is the additive identity because . equality also depends on both dimensions and corresponding entries: two matrices are equal exactly when they have the same dimensions and every corresponding entry is equal.
These operations should not be confused with . Entrywise addition is possible only for matching dimensions, whereas multiplication uses a row-by-column rule and has a different dimension condition.
Takeaway: Before adding or subtracting, verify equal dimensions; for scalar multiplication, apply the scalar to every entry.
Computing products
For matrices of size and of size , the product is defined and has size . The inner dimensions must match.
Each entry is obtained by taking the dot product of a row of with a column of :
For
we get
is generally not commutative: , and may not even be defined. It is associative and distributive when all products involved are defined:
The acts as a multiplicative identity whenever the dimensions are compatible:
Multiplying a by a column vector can also be viewed as forming a linear combination of the 's columns. If the columns are , then
Takeaway: Check compatibility first, then compute each result entry using one row of the first and one column of the second.
Transposes and structural identities
The exchanges rows and columns. An becomes an , with entries satisfying
For example,
Important identities are
For a product, the order reverses:
The reversal is required to preserve dimension compatibility. A square satisfying is symmetric. For complex matrices, the analogous conjugate both transposes the and takes the complex conjugate of each entry.
Takeaway: by reflecting entries across the main diagonal, and reverse factor order when transposing a product.
Inverses and solving with matrices
An is a square with an inverse. The inverse satisfies
If and is invertible, multiplying by the inverse gives
For
an inverse exists when , and then
The quantity is the determinant for this . If it is zero, the is singular and has no inverse.
To find an inverse by Gauss–Jordan elimination, augment the with an and row-reduce:
For example,
Therefore,
Useful identities include
The order reversal in is essential. Although the inverse gives a theoretical formula for solving systems, numerical computation usually favors a direct solve rather than explicitly forming the inverse.
Takeaway: An inverse exists only for an invertible square ; use row reduction or an appropriate factorization to compute or apply it.
Row operations and elimination
An results from applying one elementary row operation to an . The three operations are:
Interchange two rows: .
Multiply a row by a nonzero scalar: , where .
Add a multiple of one row to another: , where .
If represents one of these operations, then left multiplication applies it to another :
For example, adding three times row one to row two in a uses
Every is invertible, and its inverse reverses the associated row operation. Thus, a sequence of row operations can be represented as
This explains why row reduction preserves the solution set of a linear system: each elementary row operation produces an equivalent system.
transforms an augmented into row-echelon form, after which back-substitution finds the solution. Gauss–Jordan elimination continues to reduced row-echelon form. For a unique solution, the final augmented has the form
For example,
The second row gives , and substituting into the first gives .
Takeaway: Elementary matrices encode row operations, while uses those operations to solve systems without changing their solutions.
Reliable numerical computation
Exact arithmetic permits any nonzero pivot, but floating-point arithmetic can magnify rounding errors. Partial pivoting reduces this risk by interchanging the current row with a lower row whose entry in the pivot column has the largest absolute value. This also helps avoid division by a very small pivot.
A can be mathematically invertible but numerically ill-conditioned. In that situation, small errors in the entries or right-hand side can produce relatively large changes in the computed solution. The condition number measures one aspect of this sensitivity.
When several systems share the same coefficient , is efficient. Write
where is a permutation , is lower triangular, and is upper triangular. To solve , solve two triangular systems:
The factorization requires an initial setup, but each additional right-hand side can then be handled efficiently.
For numerical work, solve a system directly rather than computing explicitly whenever possible. Direct solvers generally avoid unnecessary work and reduce numerical error. In NumPy, numpy.linalg.solve(A, b) is the standard choice for a square system, .T represents a , and @ performs .
Common checks:
Do not add or subtract matrices with different dimensions.
Do not multiply entries position by position when is required.
Do not assume .
Do not replace with .
Do not invert a nonsquare or singular .
Do not divide by a zero or extremely small pivot without considering a row interchange.
Takeaway: Choose algorithms based on numerical reliability: pivot carefully, reuse LU factors for repeated systems, and prefer direct solves to explicit inverses.