Linear Algebra for AI

Chapter 6
Determinants, Rank and Invertibility

Bachelors Program in AI & ML
Linear Algebra for AI   •   Bachelor

Determinants, Rank and Invertibility

Introduction

Determinants, rank, and invertibility are central ideas in linear algebra and provide different ways to understand a square matrix. A determinant compresses important information about a matrix into a single scalar. It indicates whether a linear transformation preserves or collapses volume, whether a system of equations has a unique solution, and whether a square matrix has an inverse. Rank measures the number of independent directions represented by a matrix. Together, these concepts support data analysis, optimization, computer vision, machine learning, numerical computation, and scientific modelling.

For AI and machine learning, the concepts are useful in understanding feature dependence, solving linear systems, analysing covariance matrices, diagnosing redundant data, and evaluating numerical stability. However, determinants must be interpreted carefully. Although they are mathematically important, directly computing them is often inefficient and numerically unreliable for large matrices.

Learning Objectives

By the end of this chapter, students should be able to:

1. Define and interpret determinants algebraically and geometrically.

2. Compute determinants using properties, expansion by minors, and row reduction.

3. Explain minors, cofactors, and the adjugate matrix.

4. Define matrix rank and determine rank using row-echelon form and minors.

5. State and apply equivalent conditions for invertibility.

6. Distinguish nonsingularity from numerical well-conditioning.

7. Apply these ideas to linear systems and AI-related problems.

8. Recognize computational and interpretive limitations of determinants.

1. Determinants as Scalar Invariants

For a square matrix A, the determinant is a scalar denoted by det(A) or |A|. It is defined so that it reflects how the associated linear transformation changes oriented volume.

For a 2 × 2 matrix

A = [[a, b], [c, d]],

its determinant is

det(A) = ad − bc.

For example, if

A = [[3, 2], [1, 4]],

then

det(A) = (3)(4) − (2)(1) = 10.

The determinant is not simply a measure of matrix size. A large determinant does not necessarily mean that every entry is large, and a small nonzero determinant does not by itself guarantee numerical reliability.

Geometric interpretation

The columns of a 2 × 2 matrix can be viewed as vectors in the plane. The absolute value of the determinant is the area of the parallelogram formed by those vectors. The sign records orientation:

  • det(A) > 0: orientation is preserved.
  • det(A) < 0: orientation is reversed.
  • det(A) = 0: the parallelogram has zero area because the columns are linearly dependent.

For a 3 × 3 matrix, |det(A)| is the volume of the parallelepiped formed by the column vectors. In n dimensions, it represents the factor by which n-dimensional volume is scaled.

If a linear transformation is represented by A, then a region with volume V is transformed into a region with volume |det(A)|V. This interpretation assumes the transformation acts on an n-dimensional space and that volume is measured in the corresponding dimension.

2. Fundamental Properties of Determinants

The determinant satisfies several properties that make calculation and interpretation easier.

Row and column operations

For a square matrix:

1. Interchanging two rows changes the sign of the determinant.

2. Multiplying one row by a scalar k multiplies the determinant by k.

3. Adding a multiple of one row to another row leaves the determinant unchanged.

The same properties apply to columns.

If two rows or two columns are identical, the determinant is zero. More generally, if rows or columns are linearly dependent, the determinant is zero.

A triangular matrix has determinant equal to the product of its diagonal entries. Thus, if

U = [[u11, , ], [0, u22, *], [0, 0, u33]],

then

det(U) = u11u22u33.

The identity matrix I has determinant 1. For compatible square matrices A and B,

det(AB) = det(A)det(B).

Also,

det(A^T) = det(A),

where A^T is the transpose of A. If A is invertible, then

det(A^{-1}) = 1/det(A).

These properties imply that the determinant of a product describes the combined volume-scaling effect of successive transformations.

3. Minors and Cofactors

Let A be an n × n matrix. The minor M_ij is the determinant of the (n − 1) × (n − 1) matrix obtained by deleting row i and column j from A.

The cofactor C_ij is defined by

C_ij = (−1)^(i+j) M_ij.

The signs follow a checkerboard pattern:

+ − + − ...

− + − + ...

+ − + − ...

Cofactor expansion

The determinant can be calculated by expanding along any row or column. Expanding along row i gives

det(A) = a_i1 C_i1 + a_i2 C_i2 + ... + a_in C_in.

Expanding along column j gives

det(A) = a_1j C_1j + a_2j C_2j + ... + a_nj C_nj.

The result is independent of the selected row or column, although a row or column containing many zeros is usually computationally preferable.

Worked example: cofactor expansion

Consider

A = [[1, 2, 0], [3, 4, 5], [0, 6, 7]].

Expanding along the first row:

det(A) = 1 det([[4,5],[6,7]]) − 2 det([[3,5],[0,7]]) + 0.

Therefore,

det(A) = 1(28 − 30) − 2(21 − 0) = −2 − 42 = −44.

Thus A is nonsingular because its determinant is nonzero.

4. Determinants and Linear Transformations

A matrix A defines a transformation T(x) = Ax. If det(A) = 0, the transformation maps the whole space into a lower-dimensional subspace. For example, a three-dimensional region may be flattened into a plane. Information is lost because different input vectors can produce the same output vector.

If det(A) ≠ 0, the transformation is one-to-one and onto for a square matrix. It does not collapse any nonzero direction, and every output vector has exactly one input vector.

This geometric viewpoint explains why determinants occur in change-of-variables formulas in multivariable calculus and probability. If y = T(x) and T is differentiable, the Jacobian determinant measures the local volume scaling. In probabilistic modelling, the absolute Jacobian determinant is used when transforming probability densities, provided the transformation is sufficiently regular and locally invertible.

5. Rank of a Matrix

The rank of a matrix is the maximum number of linearly independent rows or columns. The row rank and column rank are always equal, so “rank” is unambiguous.

For an m × n matrix A,

rank(A) ≤ min(m,n).

The rank represents the dimension of the column space and the dimension of the row space. It also indicates how many independent constraints or independent output directions the matrix provides.

A matrix has full column rank if rank(A) = n, and full row rank if rank(A) = m. A square n × n matrix has full rank when rank(A) = n.

Rank from row reduction

Elementary row operations preserve rank. After reducing a matrix to row-echelon form, the rank equals the number of nonzero rows, or equivalently the number of pivots.

Consider

A = [[1, 2, 3], [2, 4, 6], [1, 1, 2]].

Subtracting 2 times row 1 from row 2 gives

[[1,2,3], [0,0,0], [1,1,2]].

Subtracting row 1 from row 3 gives

[[1,2,3], [0,0,0], [0,−1,−1]].

There are two nonzero rows, so rank(A) = 2. The second row of the original matrix is twice the first, which explains the dependence.

Rank and minors

The rank of A is the largest integer r for which A contains an r × r submatrix with nonzero determinant. This provides a determinant-based rank criterion:

rank(A) = r if at least one r × r minor is nonzero and every (r + 1) × (r + 1) minor is zero.

For large matrices, row reduction is normally much more efficient than checking many minors.

6. Invertibility and Equivalent Conditions

A square matrix A is invertible if there exists a matrix A^−1 such that

AA^−1 = A^−1A = I.

For an n × n matrix, the following conditions are equivalent:

1. A is invertible.

2. det(A) ≠ 0.

3. rank(A) = n.

4. The columns of A are linearly independent.

5. The rows of A are linearly independent.

6. The equation Ax = 0 has only the trivial solution x = 0.

7. For every b in R^n, Ax = b has exactly one solution.

8. The reduced row-echelon form of A is I.

9. Zero is not an eigenvalue of A.

These equivalences apply to square matrices. For rectangular matrices, one must distinguish left inverses, right inverses, full row rank, and full column rank.

Why determinant zero prevents inversion

If det(A) = 0, then the columns of A are linearly dependent. Therefore, some nonzero vector x satisfies Ax = 0. If an inverse existed, multiplying by A^−1 would give x = A^−1Ax = A^−10 = 0, a contradiction. Hence A cannot be invertible.

7. Computing an Inverse Using Cofactors

For an invertible n × n matrix A, define the cofactor matrix C = [C_ij]. Its transpose is called the adjugate, written adj(A). Then

A^−1 = (1/det(A)) adj(A).

This formula is mathematically important but usually not the preferred computational method for large matrices because it requires many determinant calculations and can be inefficient.

For a 2 × 2 matrix,

A = [[a,b],[c,d]],

if ad − bc ≠ 0, then

A^−1 = 1/(ad − bc) [[d,−b],[−c,a]].

For the matrix

A = [[3,2],[1,4]],

det(A) = 10, so

A^−1 = (1/10)[[4,−2],[−1,3]].

Direct multiplication verifies that AA^−1 = I.

8. Solving Systems and Cramer's Rule

For a square system Ax = b with det(A) ≠ 0, Cramer's rule gives

x_i = det(A_i)/det(A),

where A_i is formed by replacing column i of A with b.

For example, consider

2x + y = 5,

x + 3y = 6.

Here,

A = [[2,1],[1,3]], b = [5,6]^T,

det(A) = 6 − 1 = 5.

Replacing the first column:

A_1 = [[5,1],[6,3]], det(A_1) = 15 − 6 = 9,

so x = 9/5. Replacing the second column:

A_2 = [[2,5],[1,6]], det(A_2) = 12 − 5 = 7,

so y = 7/5.

Cramer's rule is useful for theoretical analysis and very small systems. It is generally unsuitable for large systems because it requires repeated determinant computation. In practical numerical linear algebra, LU, QR, or iterative methods are preferred.

9. Singular, Nonsingular, and Ill-Conditioned Matrices

A square matrix with determinant zero is singular. A matrix with nonzero determinant is nonsingular or invertible. However, nonsingularity does not guarantee numerical stability.

A matrix can have a very small nonzero determinant and still be difficult to use computationally. More informative measures of sensitivity include the condition number. For a chosen matrix norm,

κ(A) = ||A|| ||A^−1||.

This definition assumes A is invertible. A large condition number indicates that small perturbations in the data may produce relatively large changes in the computed solution. A condition number near one generally indicates better conditioning, although interpretation depends on the norm and problem scale.

The determinant depends strongly on units and scaling. If every row of an n × n matrix is multiplied by 1000, the determinant is multiplied by 1000^n. Consequently, determinant magnitude alone is not a reliable general-purpose measure of stability.

10. Computational Practice

For hand calculation, the choice of method depends on matrix structure:

  • Use the 2 × 2 formula for a 2 × 2 matrix.
  • Use cofactor expansion when a row or column contains many zeros.
  • Use triangularization for larger matrices.
  • Track row swaps and row scaling carefully.
  • Use pivoting in numerical implementations.

If Gaussian elimination transforms A into U using only row replacements and row swaps, the determinant can be recovered from the diagonal of U while accounting for row swaps. If a row is scaled during elimination, the scaling factor must also be tracked.

In software, one should usually avoid explicitly computing A^−1 merely to solve Ax = b. A solver based on factorization is faster and often more stable. For example, an LU factorization expresses A as

A = LU,

where L is lower triangular and U is upper triangular. The system is then solved through forward and back substitution.

For symmetric positive-definite matrices, Cholesky factorization is often preferred. QR factorization is valuable for least-squares problems and can be more stable than normal-equation methods.

11. Application to AI and Machine Learning

Feature dependence

Suppose a dataset contains features x_1, x_2, and x_3, with x_3 = 2x_1 − x_2 for every observation. The feature columns are linearly dependent, so the feature matrix cannot have full column rank. This creates redundancy and makes some parameter representations non-unique.

In linear regression, if the design matrix X has dependent columns, then X^TX is singular and the ordinary least-squares expression

β̂ = (X^TX)^−1X^Ty

cannot be used as written. This does not necessarily mean prediction is impossible. It means that the coefficient vector is not uniquely determined without additional constraints or regularization.

Possible responses include removing redundant features, using the Moore–Penrose pseudoinverse, applying QR or singular value decomposition, or using regularization such as ridge regression. Ridge regression replaces the problematic matrix with

X^TX + λI,

where λ > 0. Under standard conditions, this matrix is positive definite and invertible, although the resulting coefficients are intentionally biased toward smaller values.

Covariance matrices

A covariance matrix is singular when one variable is an exact linear combination of others. This affects methods such as multivariate Gaussian modelling, linear discriminant analysis, and some forms of dimensionality reduction. Numerical implementations often use eigenvalue thresholds, SVD, shrinkage, or small diagonal adjustments, but such adjustments should be documented because they alter the model.

12. Illustrative Case Study: Diagnosing Redundant Features

Background

A fictional university analytics team builds a model to predict student completion time using three features: completed credits c, remaining credits r, and total programme credits t. The programme structure guarantees

t = c + r.

Problem

The team attempts to fit a linear model with all three features and discovers that the estimated coefficients change substantially across software packages. The model also reports a singularity warning.

Analysis

The feature columns satisfy a linear relation, so the design matrix does not have full column rank. If the columns are represented as c, r, and t, then

c + r − t = 0.

Therefore, the columns are linearly dependent. The corresponding matrix has no unique coefficient representation. Different coefficient triples can produce the same predictions. For example, changing the coefficients by a multiple of (1,1,−1) leaves the fitted linear combination unchanged.

Approach and solution

The team removes t because it is exactly determined by c and r. Alternatively, it could remove one of c or r, depending on the interpretation required. The team then checks the rank of the revised design matrix and uses QR factorization rather than explicitly forming an inverse. If all three features must be retained for reporting reasons, the team uses a constrained model or regularization and clearly states the constraint.

Outcome

The revised model has unique coefficients under the selected specification, and the software warning disappears. The team also documents that removing a feature was not arbitrary: it was based on an exact structural dependency.

Learning points

1. Rank reveals redundancy that may not be obvious from individual feature summaries.

2. A singular matrix is a structural issue, not merely a software error.

3. Non-unique coefficients do not always imply non-unique predictions.

4. Feature removal, constraints, pseudoinverses, and regularization solve different versions of the problem.

5. Model documentation should explain any rank-reducing or stabilizing intervention.

13. Limitations, Governance, and Best Practice

Determinants and rank provide valuable structural information, but they do not answer every modelling question. A full-rank matrix may still represent biased data, irrelevant features, measurement error, or a poorly specified model. Conversely, rank deficiency may be expected in a deliberately overcomplete representation.

In AI systems, preprocessing decisions that alter rank can affect fairness and reproducibility. Removing a feature may remove information relevant to a protected group, while retaining highly correlated proxies may create governance concerns. Regularization may improve numerical performance but should not conceal problematic data collection or unjustified variables.

Best practice includes:

  • Inspecting rank and singular values during data preparation.
  • Reporting how missing values, scaling, and redundant features were handled.
  • Avoiding explicit matrix inverses when solving numerical systems.
  • Using pivoting and stable factorizations.
  • Distinguishing exact singularity from near-singularity.
  • Checking condition numbers or singular-value decay when sensitivity matters.
  • Validating that numerical modifications preserve the intended meaning of the model.
  • Recording software versions, tolerances, and preprocessing choices.

Contemporary Perspective

Modern numerical linear algebra increasingly relies on singular value decomposition, randomized matrix algorithms, automatic differentiation, and hardware-accelerated linear algebra. SVD is particularly useful because it exposes rank through singular values. In exact arithmetic, zero singular values indicate rank deficiency. In floating-point arithmetic, a tolerance is required, so numerical rank becomes a judgement based on scale and precision.

Large-scale AI systems rarely compute determinants directly. Instead, they use factorizations, matrix-free methods, iterative solvers, and structured representations. Determinants remain important conceptually and appear directly in probabilistic models, normalizing flows, Gaussian processes, and likelihood calculations, but efficient implementations exploit special matrix structure whenever possible.

Chapter Summary

The determinant is a scalar associated with a square matrix that measures signed volume scaling and determines whether the associated transformation collapses dimensions. A zero determinant indicates linear dependence among rows or columns and therefore singularity. Minors and cofactors provide a systematic method for determinant expansion, while determinant properties simplify calculations.

Rank is the dimension of the row space or column space and equals the number of pivots in row-echelon form. It can also be characterized through nonzero minors. For a square matrix, invertibility, nonzero determinant, full rank, linear independence of rows and columns, uniqueness of solutions, and absence of zero eigenvalues are equivalent conditions.

Determinants and inverses are useful for theory and small systems, but direct computation is often inefficient for large numerical problems. Factorizations such as LU, QR, Cholesky, and SVD are usually preferable. In AI and machine learning, rank analysis helps identify redundant features, singular covariance matrices, non-unique regression coefficients, and numerical instability. Sound practice distinguishes exact singularity from ill-conditioning and considers the statistical, ethical, and modelling consequences of preprocessing decisions.

Key Terms

Determinant: A scalar associated with a square matrix that represents signed volume scaling.

Singular matrix: A square matrix with determinant zero and no inverse.

Nonsingular matrix: A square matrix with a nonzero determinant and an inverse.

Minor: The determinant obtained after deleting one row and one column from a matrix.

Cofactor: A signed minor, defined by C_ij = (−1)^(i+j)M_ij.

Adjugate: The transpose of the cofactor matrix.

Rank: The maximum number of linearly independent rows or columns.

Pivot: A leading nonzero entry used in elimination.

Full rank: A matrix whose rank equals the maximum possible rank.

Linear independence: A property in which no vector can be expressed as a combination of the others.

Column space: The span of the columns of a matrix.

Null space: The set of vectors x satisfying Ax = 0.

Invertible matrix: A square matrix possessing a two-sided inverse.

Cramer's rule: A determinant-based method for solving a square linear system.

Condition number: A measure of sensitivity of a numerical problem to perturbations.

Ill-conditioned matrix: A matrix for which small input changes may cause large output changes.

Numerical rank: Rank estimated using a tolerance in finite-precision computation.

Regularization: A method that modifies a problem to improve stability or control complexity.

Pseudoinverse: A generalized inverse applicable to rectangular or rank-deficient matrices.

Review Questions

Short Answer Questions

1. What does the determinant of a 2 × 2 matrix represent geometrically?

2. Define the rank of a matrix.

3. What happens to a determinant when two rows are interchanged?

4. State two equivalent conditions for invertibility of a square matrix.

5. Why is directly computing a matrix inverse often discouraged in numerical applications?

Long Answer Questions

1. Explain the relationship between determinant zero, linear dependence, rank deficiency, and non-invertibility.

2. Describe minors and cofactors and demonstrate a cofactor expansion for a 3 × 3 matrix.

3. Compare determinant-based inversion, Gaussian elimination, LU factorization, and QR factorization.

4. Explain how rank deficiency affects the uniqueness of coefficients in linear regression.

5. Discuss the difference between singularity and ill-conditioning, including the role of the condition number.

Analytical / Application Questions

1. A feature matrix contains columns x, 2x, and y. Determine whether it can have full column rank and explain the consequences for regression.

2. A square matrix has determinant −0.0001 but a very large condition number. Explain why its nonzero determinant does not guarantee reliable numerical solutions.

3. An AI team finds that a covariance matrix is singular. Propose two technically different remedies and explain what each changes in the modelling process.

Multiple Choice Questions with Answers

Question 1

For A = [[3, 2], [1, 4]], what is det(A)?

A. 8

B. 10

C. 12

D. 14

Correct Answer: B. 10

Question 2

What does a zero determinant indicate for a square matrix?

A. Its rows and columns are linearly independent

B. It always has positive eigenvalues

C. It is singular and not invertible

D. Its inverse equals the transpose

Correct Answer: C. It is singular and not invertible

Question 3

The rank of a matrix in row-echelon form equals the number of:

A. Columns

B. Rows

C. Pivots

D. Zero entries

Correct Answer: C. Pivots

Question 4

Which operation leaves the determinant unchanged?

A. Interchanging two rows

B. Multiplying a row by 3

C. Adding a multiple of one row to another

D. Deleting a row

Correct Answer: C. Adding a multiple of one row to another

Question 5

For an invertible matrix A, which identity is correct?

A. det(A^−1) = det(A)

B. det(A^−1) = −det(A)

C. det(A^−1) = 1/det(A)

D. det(A^−1) = 0

Correct Answer: C. det(A^−1) = 1/det(A)

Question 6

A square matrix is invertible if and only if:

A. Its rank is less than its size

B. Its determinant is nonzero

C. Its rows are dependent

D. Its null space contains a nonzero vector

Correct Answer: B. Its determinant is nonzero

Question 7

For a triangular matrix, the determinant is:

A. The sum of the diagonal entries

B. The product of the diagonal entries

C. Always zero

D. The number of nonzero entries

Correct Answer: B. The product of the diagonal entries

Question 8

If a design matrix has linearly dependent columns, ordinary least squares using (X^T X)^−1 may fail because:

A. X^T X is necessarily rectangular

B. X^T X may be singular

C. The response variable becomes categorical

D. The determinant must be negative

Correct Answer: B. X^T X may be singular

Question 9

Which method is generally preferred for revealing numerical rank through singular values?

A. SVD

B. Cramer's rule

C. Cofactor expansion

D. Determinant multiplication

Correct Answer: A. SVD

Question 10

A large condition number generally indicates that a system is:

A. Highly insensitive to perturbations

B. Ill-conditioned

C. Guaranteed to have determinant zero

D. Orthogonal

Correct Answer: B. Ill-conditioned

Linear Algebra for AI
Chapter 6 of 15