Split a graph path of length at most into two consecutive parts of length at most , allowing a zero-length part. Conversely, concatenating two such parts gives a walk of length at most and hence the same reachability. Therefore
Start at , then square to obtain . Stop at equality of successive matrices, or after the length bound reaches . The invariant is now after squarings. Equality implies closure under composition, and the included identity matrix ensures reflexivity.
For the same elementary dense Boolean matrix multiplication and equality stopping test, the cost is
The additive constant covers the final stability check and the cases . Thus, with , the number of cubic passes falls from to . In terms of alone the worst-case bound improves from to for these implementations. A directed chain also requires logarithmically many squarings. This comparison uses ordinary triple-loop multiplication, rather than a faster matrix multiplication method.
Apply the elementary row operations from bottom to top: , , and . This order ensures that each subtraction uses the original preceding row. The result is the upper triangular matrix
Put , , , . Row is either zero if , or has its first nonzero entry in column . Thus, for arbitrary real parameters, a row echelon form is obtained by retaining the nonzero rows of in their existing order and moving every zero row to the bottom. This deals explicitly with vanishing parameters; an upper triangular matrix with an intermediate zero row is not yet a row echelon form.
The subtractions preserve the determinant, so the original matrix has
A square matrix is invertible exactly when its determinant is nonzero. Consequently,
These conditions concern consecutive parameters: no ordering, positivity, or pairwise distinctness of all four is required. More generally the rank of a matrix here is the number of nonzero , because the retained nonzero rows have distinct leading columns.
For a real matrix , the row space is the linear span of its rows in , and the column space is the linear span of its columns in . Its null space consists of the input vectors sent to zero:
The rank of a matrix is
The equality of row and column dimensions is the row-rank/column-rank theorem. Each displayed space is a linear subspace of the indicated ambient vector space.
The pivot columns of the reduced row echelon form are columns 1 and 3. Take those columns of the original matrix, since elementary row operations need not preserve the original column space:
For an explicit spanning check, column 2 is , column 4 is , and column 5 is . The first two coordinates of the displayed columns form a matrix of determinant , proving their linear independence. They are therefore a basis of the column space.
Every nonempty axis-aligned rectangle has a top-right corner. Enumerate all such corners and retain the greatest area from part (b).
var best = 0
var i = 0
while (i < N) {
  var j = 0
  while (j < N) {
    best = math.max(best, maxRectangleAt(i, j))
    j += 1
  }
  i += 1
}
The loop invariant is that best is the greatest area obtained from the corners processed so far, or zero if there are none. Consequently
The preprocessing cost from part (a) is included. An entirely false matrix, or an empty one, returns zero. In the printed example, rows through and columns through give area ; exhaustive corner enumeration confirms that no larger all-true rectangle exists.[ref]
Figure 1.
An area-15 rectangle and the row run lengths that certify its width
. Details.
The representation invariant is , rows.length == N, and every rows(i) is a nonnull finite list of entries satisfying
Strict increase excludes repeated columns. The abstraction function gives when the unique entry occurs in rows(i), and otherwise. Thus omitted positions represent zero; omission does not mean an unknown matrix entry.
For each source row, use a temporary dense array to accumulate contributions from nonzero pairs. For every stored , traverse stored entries in row of the other sparse matrix.
def mult(that: SparseMatrix): SparseMatrix = {
  require(N == that.N)
  val out = new SparseMatrix(N)
  for (i <- 0 until N) {
    val acc = Array.fill[Double](N)(0.0)
    for ((k, x) <- rows(i)) {
      for ((j, y) <- that.rows(k)) {
        acc(j) += x * y
      }
    }
    var j = N - 1
    var result: Row = Nil
    while (j >= 0) {
      if (acc(j) != 0.0) result = (j, acc(j)) :: result
      j -= 1
    }
    out.rows(i) = result
  }
  out
}
During accumulation, acc(j) is the sum of the already processed terms contributing to position . Missing entries multiply to zero, so ignoring them loses no contribution under the finite arithmetic convention of part (e). At completion,
Descending j and prepending produce strictly increasing stored indices. Omitting zero also handles cancellation. The temporary array uses auxiliary space beyond the output. The time complexity is
at worst , but potentially much smaller when the matrices are sparse. The term covers clearing and scanning the row accumulators. Finite-precision rounding can affect the numerical result, as in any Double matrix multiplication.
For a square matrix , an eigenvalue–eigenvector pair consists of a scalar and a nonzero vector satisfying
The linear map represented by therefore scales by . The exclusion of the zero vector matters: otherwise every scalar would satisfy the equation trivially.
For an matrix with real entries, its row space is the linear span of its rows, a linear subspace of . Its column space is the linear span of its columns, a linear subspace of and the image of a linear map . Its null space is
a linear subspace of . Finally,
Thus the rank of a matrix counts the number of linearly independent columns, equivalently rows. The nullity is by the rank-nullity theorem.
The pivot columns in the row echelon form are columns 1 and 3. Use those columns of the original matrix for a basis of the original column space:
For a direct spanning check, column 2 is twice column 1 and column 4 is times column 1 minus times column 3. The displayed columns are linearly independent, since the first two coordinates of give and , so .
Suppose an invertible matrix has two LU factorizations, , with unit lower triangular matrices and upper triangular matrices. All four factors are invertible matrices, since their square products are invertible. Multiplication by the appropriate inverse matrices gives
By the supplied closure properties, the left side is a unit lower triangular matrix and the right side is an upper triangular matrix. A matrix of both types is diagonal; its diagonal entries are all one. Thus both sides are the identity matrix, whence
Qualification of the printed wording: this establishes uniqueness if the specified LU factorization exists. Invertibility alone does not guarantee an unpivoted LU factorization. For example is invertible, but in a product , the zero top-left entry forces , making the bottom-left entry as well, contrary to the required value one. A permutation matrix is needed in general, as in PLU factorization.
Source gap / TODO: the original printed page 4, confirmed visually, omits the unknown vector. It literally equates a matrix with a vector, so it does not define a well-formed system of linear equations. The following answer is conditional on the usual intended interpretation ; the missing factor is not present in the source.
Under that interpretation, the rows satisfy . Applying this linear relation to the right-hand side gives the necessary consistency condition
It is sufficient too: the upper-left minor has determinant , so the first two rows are linearly independent. The third row is , and imposes precisely the condition already found. Therefore
For completeness, setting gives
and direct substitution satisfies all three linear equations exactly for those two values of . An unconditional answer to the malformed printed equality awaits a source correction.
A scalar is an eigenvalue of an matrix if there is a nonzero vector such that
Any such vector is an eigenvector corresponding to . The requirement that an eigenvector be nonzero is essential: the zero vector would satisfy the equation for every scalar and would convey no information.
For , the entries of are the column sums of . Hence
so is an eigenvalue of , with eigenvector .
The determinant is unchanged by matrix transposition, so
Thus has a nontrivial null space, giving
The same argument with shows that a matrix and its transpose have the same characteristic polynomial. It does not say that they have the same eigenvectors: here .
For a real matrix , the row space is the linear span of its rows in . The column space is the linear span of its columns in , equivalently . The null space is
The matrix rank is the dimension of the column space, which equals the dimension of the row space. In particular,
The last equality is the rank-nullity theorem.
Let be the original columns. The first three are linearly independent: restricting them to rows 2, 3 and 4 gives the triangular matrix
whose determinant is one. Also , so a basis for the column space is
These are columns of the original matrix. Taking columns of its reduced row echelon form would generally give the wrong column space.
No. Take the one-by-one matrices , . Both column spaces are , whereas has column space . More generally, taking cancels any nonzero column space. One always has , because each sum column lies in the vector subspace , but equality can fail through cancellation.
Write the determinant in its Leibniz formula for determinants, where is the set of permutations of :
The permutation sign is justified by the given row-interchange property: a permutation matrix is obtained from the identity matrix by row interchanges, and every interchange changes its determinant by a factor . Reversing a sequence of interchanges constructs the inverse permutation with the same number of interchanges. Consequently . The Leibniz formula for determinants can itself be obtained by expanding the rows multilinearly in the standard basis: repeated selected coordinate rows contribute zero, and the remaining terms are precisely these signed permutation matrices.
Since , the same formula gives
Reindex the product with and reindex the sum with . Both reindexings are bijections, so
Thus for every real square matrix, including singular matrices. This proof does not assume the analogous column-operation rules in order to establish the transpose identity.
An eigenvalue and eigenvector pair for a square matrix satisfies
The scalar and the coordinates of belong to the chosen field, usually or . The nonzero condition is essential: the zero vector satisfies the equation for every and therefore cannot define an eigenvalue.