skip to content

Vectors and Matrix Operations

Vector and matrix arithmetic: dot products, multiplication and its shape rules, transpose, inverse, determinant and trace. Interviewers start here because shape and singularity errors surface fast.

on this pageshow

explore

questions

10

What does a determinant of zero tell you about a square matrix?

level: juniorimportance: must knowfreq 76%

answer

  1. one scalar summarising a square matrix
  2. it decides whether an inverse exists
  3. for a 2x2 it is ad - bc
  4. the inverse formula divides by it
  5. zero means singular

basics

~20 s

A zero determinant means the matrix is singular: no inverse exists. For a 2x2 matrix [[a, b], [c, d]] the determinant is ad - bc, so ad - bc = 0 is the exact test for non-invertibility.

solid answer

~50 s

A square matrix `A` is invertible exactly when `det(A)` is non-zero. When the determinant is zero the matrix is called singular, and there is no matrix `A^-1` satisfying `A A^-1 = A^-1 A = I`. For a 2x2 matrix `[[a, b], [c, d]]` the determinant is `ad - bc` and the inverse is `(1 / (ad - bc)) * [[d, -b], [-c, a]]`, so the test is visible in the formula itself: it divides by the determinant. Concretely, `[[1, 2], [2, 4]]` has determinant `1*4 - 2*2 = 0` and cannot be inverted, while `[[1, 2], [3, 4]]` has determinant `-2` and can. Determinants are defined only for square matrices, so a non-square matrix has neither a determinant nor a two-sided inverse. The test is exact but binary: it answers invertible or not, never how comfortably invertible.

go deeper

for a junior

Memorise the equivalence and the 2x2 formula: determinant is ad - bc, and zero means no inverse. Be ready to compute a 2x2 determinant and inverse by hand without hesitating.

for a middle

Explain why the test works rather than quoting it, pointing at the ad - bc denominator in the 2x2 inverse formula, and add that the determinant is defined for square matrices only.

for a senior

Add the geometric reading, that a zero determinant means the map collapses volume so information is lost and cannot be undone, and flag that determinant magnitude is not a graded measure of invertibility.

for a principal

Frame when the exact algebraic test is the right tool at all: it is clean on paper and for small hand examples, but on real data any scalar zero-or-not test needs a stated tolerance and an owner.

## The determinant in one sentence The determinant is a single number attached to a **square** matrix. It compresses the whole matrix into one scalar, and the single most useful thing that scalar decides is invertibility: a square matrix `A` has an inverse if and only if `det(A)` is not zero. ## What "inverse" means The inverse of a square matrix `A` is the matrix `A^-1` for which `A A^-1 = A^-1 A = I`, where `I` is the identity matrix (ones on the diagonal, zeros elsewhere). The identity is the do-nothing matrix: `I x = x` for every vector `x`. So the inverse is the matrix that exactly undoes what `A` does. A matrix that has an inverse is called **invertible** or **non-singular**; one that does not is **singular**. A useful fact for square matrices: a one-sided inverse is automatically two-sided. If `A` and `B` are both n-by-n and `B A = I`, then `A B = I` too. That is special to square matrices and is why we can talk about "the" inverse without qualifying which side. ## The 2x2 case, worked For ``` A = [[a, b], [c, d]] ``` the determinant is `det(A) = ad - bc`, and when it is non-zero ``` A^-1 = (1 / (ad - bc)) * [[ d, -b], [-c, a]] ``` This formula makes the theorem almost self-evident at 2x2: the construction divides by `ad - bc`, so the moment `ad - bc = 0` there is nothing to build. Check it on `A = [[1, 2], [3, 4]]`: `det(A) = 1*4 - 2*3 = -2`, so `A^-1 = (1 / -2) * [[4, -2], [-3, 1]] = [[-2, 1], [1.5, -0.5]]`. Multiplying `A A^-1` gives the identity. Now take `A = [[1, 2], [2, 4]]`. Here `det(A) = 1*4 - 2*2 = 0`. The second row is exactly twice the first, and no inverse exists. Notice the pattern: the determinant vanishing is the algebraic signature of the rows (equivalently the columns) being redundant rather than independent directions. ## Bigger matrices Beyond 2x2 the same theorem holds, only the arithmetic is heavier. A 3x3 determinant can be expanded along a row using 2x2 sub-determinants with alternating signs (cofactor expansion), and for a triangular matrix (all entries below or all entries above the diagonal are zero) the determinant is simply the product of the diagonal entries. The identity matrix, being diagonal with all ones, has determinant 1 — consistent with it being trivially invertible, since it is its own inverse. ## What zero means geometrically Read a square matrix as a linear map that sends vectors to vectors. The determinant is the factor by which that map scales area (in two dimensions) or volume (in higher dimensions). A determinant of zero says the map flattens: it sends the unit square onto a line segment or a single point, so the output has zero area. Flattening destroys information — many different inputs land on the same output — and a map that destroys information cannot be undone. That is the geometric reason a singular matrix has no inverse. ## Square only Determinants exist only for square matrices. Asking for the determinant of a 3x4 matrix is a category error, not a computation with answer zero. Likewise a non-square matrix never has a two-sided inverse, since `A B` and `B A` cannot both be identity matrices of the same size. ## Traps interviewers watch for - **Additivity.** `det(A + B)` is generally *not* `det(A) + det(B)`. Take `A = I` and `B = -I` at 2x2: `det(A) = 1`, `det(B) = 1`, but `A + B` is the zero matrix with determinant 0, not 2. - **Transpose.** `det(A^T) = det(A)`. So `A` is invertible exactly when `A^T` is. - **Small versus zero.** The theorem is an exact statement about the number being zero. A small non-zero determinant still means invertible; determinant magnitude is not a graded measure of invertibility, because rescaling the whole matrix rescales the determinant. - **Sign.** A negative determinant is perfectly fine — it means invertible with the orientation flipped. Only zero is special. ## How to answer in the room State the equivalence first (`det(A) = 0` if and only if `A` is singular), give the 2x2 formula and its `ad - bc` denominator as the reason, then offer the geometric reading: determinant zero means the map collapses volume, and a collapse cannot be reversed. That is a complete answer in under a minute.

  • If a square matrix B satisfies BA = I, does that alone make A invertible?
    Yes, for square matrices. A one-sided inverse of a square matrix is automatically two-sided, so `BA = I` forces `AB = I` and `B = A^-1`. This is not true for non-square matrices, where a matrix can have a left inverse and no right inverse, or vice versa.
  • How does det(A^T) relate to det(A)?
    They are equal: `det(A^T) = det(A)`. The determinant is unchanged by transposing, which is why every statement about rows has a mirror statement about columns. A practical consequence is that `A` is invertible exactly when `A^T` is invertible, and `(A^T)^-1 = (A^-1)^T`.
  • Is det(A + B) equal to det(A) + det(B)?
    No — the determinant is not additive. A quick counterexample at 2x2: take `A = I` and `B = -I`. Then `det(A) = 1` and `det(B) = 1`, so the sum of determinants is 2, but `A + B` is the zero matrix with determinant 0. Determinants multiply across products, not add across sums.

It is like a stamp pressed onto paper: if the stamp flattens the shape to a line, you can never work backwards to the original, and the determinant is exactly the number that reports that flattening.

saying these in an interview costs you the question

  • Says a zero determinant means the matrix contains only zeros
  • Claims a 3x4 matrix has a determinant
  • Treats det(A + B) as det(A) + det(B)
  • Says a small non-zero determinant means the matrix is not invertible
  • Confuses the determinant with the sum of the matrix entries

context

open as a page

For the matrix product AB, what shapes must A and B have, and what shape is the result?

level: juniorimportance: must knowfreq 86%

basics

~20 s

Matrix multiplication needs matching inner dimensions: if A is m x n and B is n x p, then AB is m x p. Entry (i,j) is the dot product of row i of A with column j of B.

open as a page

Why can the matrix products AB and BA differ, even when both are defined?

level: middleimportance: must knowfreq 71%

basics

~20 s

A matrix product is a composition of linear maps, and composition depends on order. In AB the right factor acts first, so rotating then stretching is a different transformation from stretching then rotating. Only special pairs commute.

open as a page

Why does det(AB) equal det(A) times det(B) for square matrices?

level: middleimportance: should knowfreq 46%

basics

~10 s

Because the determinant is a volume scaling factor, and applying B and then A scales volume by det(B) and then by det(A). Scaling factors multiply, so det(AB) = det(A)det(B).

open as a page

Geometrically, what does the determinant of a 2x2 matrix measure?

level: middleimportance: should knowfreq 58%

basics

~20 s

The determinant is the signed area scaling factor of the map: the unit square is sent to a shape whose area is the absolute value of the determinant. A negative sign means orientation was flipped.

open as a page

Why does the trace satisfy tr(AB) = tr(BA) even when AB and BA differ?

level: middleimportance: should knowfreq 38%

basics

~20 s

The trace is the sum of a square matrix's diagonal entries, and both tr(AB) and tr(BA) expand to the same double sum over every pair of entries. The order of summation changes, so the totals match.

open as a page

What does the matrix-vector product Ax compute in terms of the columns of A?

level: middleimportance: should knowfreq 56%

basics

~20 s

Ax is a linear combination of the columns of A, weighted by the entries of x. Applying A to the basis vector with a single 1 in slot j returns column j, so the columns are where the axes go.

open as a page

Why does the transpose of a matrix product equal B^T A^T rather than A^T B^T?

level: middleimportance: should knowfreq 47%

basics

~20 s

Transposing swaps each matrix's row and column counts, so the factors must reverse for the shapes to line up. Entry (i,j) of (AB)^T is entry (j,i) of AB, which is row i of B^T dotted with column j of A^T.

open as a page

Why is a tiny determinant not by itself evidence that a matrix is nearly singular?

level: seniorimportance: nice to knowfreq 28%

basics

~10 s

Because the determinant depends on scale: for an n x n matrix, det(cA) = c^n det(A). Shrinking every entry drives the determinant toward zero without making the matrix any harder to invert.

open as a page

How does associativity of matrix multiplication let you cut the cost of a three-matrix chain?

level: seniorimportance: nice to knowfreq 33%

basics

~20 s

Associativity means (AB)C and A(BC) give identical results, so the grouping is yours to choose. An (m x n) by (n x p) product costs about mnp multiply-adds, so pick the grouping whose intermediate is smallest.

open as a page