Matrix-chain cost model 2026-10-18
For matrix dimensions and , ordinary matrix multiplication computes matrix entries, each using scalar multiplications. Thus its cost is scalar multiplications, with additions if each sum starts from its first term. Here we minimize only the scalar multiplication count, using this dense matrix multiplication rule throughout. The counts describe arithmetic operations, rather than measured elapsed time; matrix multiplication methods that exploit structure or use faster formulas require a different cost rule.
Take matrices , , with matrix dimensions , , . Both groupings produce a matrix product, but their intermediate matrix dimensions differ:
The second grouping first compresses into a matrix, avoiding the intermediate matrix . The saving is scalar multiplications, although both groupings use exactly two matrix multiplications. This is why counting only matrix multiplication operations hides the interesting choice.
Figure 1.
The same matrix product can require 3840 or 780 scalar multiplications
. Original binary trees for the three-matrix example. Leaves keep in the same order. Each internal node gives its resulting matrix dimensions and the local scalar multiplication cost; adding those costs gives the total. Details.
Associativity permits these regroupings in exact arithmetic; commutativity is neither assumed nor generally true for matrix multiplication. Swapping and here would even make their matrix product undefined. In floating-point arithmetic, round-off error can make the two groupings yield different computed matrix entries; the cost optimum alone does not guarantee the smallest numerical error.
Matrix entry 2026-10-18
The matrix entry is the value in row and column of a matrix .
Matrix rank Created 2026-09-24 Updated 2026-10-18
The matrix rank of an matrix over a field is the dimension of its column space, equivalently the dimension of its row space. It counts linearly independent column directions, with . Counting nonzero matrix entries gives a different quantity: an all-ones matrix can have arbitrarily many nonzero matrix entries and still have matrix rank one.[ref]
Consider the following matrix over the real numbers, with columns written as vectors:
The vectors are linearly independent: requires both and , so . The third column adds no new direction to their linear span, hence despite all nine matrix entries being nonzero. The second row likewise repeats twice the first row.
The column space is a plane through the origin:
Every output has second coordinate twice its first coordinate. Conversely, any vector equals , so this condition describes the entire plane, not just part of it. For example, is attainable, whereas lies outside the plane.
Figure 1.
Three column vectors span a two-dimensional plane: , is attainable, and is outside the column space
. Details.
Elementary row operations expose the same count algebraically. Apply and , interchange the last two rows, multiply the second row by , and subtract twice the second row from the first. The resulting reduced row echelon form is
There are two pivot columns, so the matrix rank is two. The corresponding original columns form a basis of the original column space. The pivot columns of itself span the different plane with third coordinate zero: row operations preserve column linear relations, but generally move the column space.[ref]
Solving the homogeneous linear system gives and . Taking the free variable gives
The kernel is the input direction that trades one unit of each of the first two columns for one unit of the third. This trade leaves the output unchanged. The rank-nullity theorem expresses the general balance: for an matrix of matrix rank , the nullity is . The column space describes reachable outputs; the kernel describes invisible changes to inputs.[ref]
For the attainable output , one solution is . Every solution lies in the affine solution space of a linear equation
Indeed, and . Conversely, subtracting from any solution gives a vector in the kernel, so this describes every solution. For , the same row operations on the augmented matrix expose : the second requirement demands where twice the first requires .
Figure 2.
Two pivot columns, one kernel direction, and the same row operations distinguishing attainable from impossible
. Details.
In general, a linear system is solvable exactly when appending leaves the matrix rank unchanged:
Appending a vector outside the column space adds an independent direction. When a solution exists, every solution is , because . Thus one count predicts both how many output directions are reachable and, through the rank-nullity theorem, how many independent input directions remain free.[ref]
Pivot column 2026-10-18
A pivot column of a matrix is a column whose position contains a leading nonzero matrix entry in its row echelon form. The corresponding columns of the original matrix form a basis of its column space. The column positions survive row operations, although the column vectors themselves generally change.[ref]
Row rank Created 2026-10-14 Updated 2026-10-18
The row rank of a matrix is the dimension of the vector space spanned by its rows. Elementary row operations preserve this row space; multiplication on the right by an invertible matrix preserves all linear relations among the rows.
To see why row rank equals column rank, write a reduced row echelon form as , where is a product of elementary matrices and is an invertible matrix. Reversibility of the row operations gives equal row spaces for and . Also if and only if , so the columns have exactly the same linear relations. If has nonzero rows, its pivot columns are the first standard basis vectors of and span its column space. Its nonzero rows are linearly independent, since their matrix entries in the pivot positions form an identity matrix. Both dimensions therefore equal , and both counts transfer back to .