Algebra and linear algebra

Matrix Formulas

Check the matrix dimensions before doing any operations. Use the determinant to decide when an inverse exists, and keep row reduction handy for systems where the inverse method does not apply.

On this page

Find a formula

Open a formula for its definition and a worked example.

Dimensions and special matrices

  • Count rows before columnsA = [aij]m×n, 1 ≤ i ≤ m and 1 ≤ j ≤ na_{ij} is the entry in row i, column j. A square matrix has m = n.

    What it does

    A matrix’s dimensions list its row count before its column count. The first subscript of an entry names its row.

    Worked example

    For A = [[4,1,6],[0,−2,5]], find its dimensions and a23. Is it square?

    1. There are 2 rows and 3 columns. The entry at row 2, column 3 is 5.
    2. The dimensions differ, so A is rectangular.
    Link to this example
  • Zero matrix0m×n has 0 at every position.

    What it does

    A zero matrix has all entries zero and can have any valid row and column counts.

    Worked example

    Write the 2×3 zero matrix and add it to [[1,4,7],[3,2,6]].

    1. The zero matrix is [[0,0,0],[0,0,0]].
    2. Adding corresponding zero entries leaves [[1,4,7],[3,2,6]].
    Link to this example
  • Identity of size n(In)ij = 1 for i = j and 0 for i ≠ j

    What it does

    An identity matrix is square, with 1 on its main diagonal and 0 off that diagonal.

    Worked example

    Write I2 and apply it to the column vector [3,−2]ᵀ.

    1. I2 = [[1,0],[0,1]].
    2. The two dot products are 3 and −2, so the vector is unchanged.
    Link to this example

Add, scale, transpose and multiply

  • Work entry by entry(A + B)ij = aij + bij, (cA)ij = c aijFor addition, A and B must have the same dimensions.

    What it does

    Add matrices of equal dimensions entry by entry. Scalar multiplication scales every entry by the same number.

    Worked example

    For A = [[1,2],[0,3]] and B = [[4,−1],[2,5]], find A + B and 2A.

    1. Add corresponding entries to get [[5,1],[2,8]].
    2. Double every entry of A to get [[2,4],[0,6]].
    Link to this example
  • Exchange rows and columns(Aᵀ)ij = aji, (Aᵀ)ᵀ = A, (AB)ᵀ = BᵀAᵀ

    What it does

    Transposition swaps row and column indices. Transposing a product reverses the order of its transposed factors.

    Worked example

    Transpose A = [[2,−1,4],[3,0,5]] twice.

    1. Aᵀ has rows [2,3], [−1,0] and [4,5].
    2. Taking the transpose again restores the original two rows.
    Link to this example
  • Pair a row of A with a column of B(AB)ij = Σk=1n aikbkjMultiply an m×n matrix by an n×p matrix to obtain m×p. BA can differ from AB or be undefined.

    What it does

    Each product entry is the dot product of one left row and one right column. The left column count must equal the right row count.

    Worked example

    Take A = [[1,2],[0,1]] and B = [[2,0],[0,3]]. Compute AB and BA.

    1. AB has rows [2,6] and [0,3]. Its upper-right entry is 1(0) + 2(3) = 6.
    2. BA has rows [2,4] and [0,3], so the two products differ.
    Link to this example
  • Multiply by a matching identityIm A = A = A InHere A is m×n.

    What it does

    An identity factor preserves a matrix when its size matches the dimension on that side of the product.

    Worked example

    For A = [[4,7,2],[5,3,1]], which identity sizes leave A unchanged on the left and right?

    1. A has two rows, so I2A combines rows without changing them.
    2. It has three columns, so AI3 likewise leaves each column unchanged.
    Link to this example

A two-by-two matrix

  • Difference of diagonal productsFor A = [[a,b],[c,d]], det A = ad − bc.

    What it does

    A two-by-two determinant is the main diagonal product minus the other diagonal product.

    Worked example

    Find the determinant of [[4,3],[2,5]].

    1. Compute 4 × 5 and 3 × 2.
    2. Their difference is 20 − 6 = 14.
    Link to this example
  • Test invertibility and build the inverseA−1 = [[d,−b],[−c,a]]/(ad − bc)This exists exactly when ad − bc ≠ 0.

    What it does

    A two-by-two inverse exists exactly when the determinant is nonzero. Swap the main diagonal entries, negate the others and divide by the determinant.

    Worked example

    Invert A = [[3,2],[1,1]].

    1. The determinant is 3 − 2 = 1.
    2. The inverse is [[1,−2],[−1,3]]. Multiplication by A gives the identity.
    Link to this example

Build a determinant from smaller ones

  • Minor and signed cofactorMij = det A with row i and column j deleted, Cij = (−1)i+j MijDelete the row and column from the matrix before taking the smaller determinant.

    What it does

    A minor is the determinant left after deleting one row and one column. Its cofactor includes the alternating sign (−1)i+j.

    Worked example

    For A = [[1,2,0],[0,3,4],[2,0,1]], find M12 and C12.

    1. Deleting row 1 and column 2 leaves [[0,4],[2,1]], with determinant −8.
    2. The sign (−1)1+2 is −1, so C12 = 8.
    Link to this example
  • Cofactor expansion along row idet A = Σj=1n aij CijFor row 1 of a 3×3, use a₁₁M₁₁ − a₁₂M₁₂ + a₁₃M₁₃. Any row gives the same result.

    What it does

    Cofactor expansion adds the products of a chosen row’s entries and their signed cofactors.

    Worked example

    Expand det A along row 1 for A = [[1,2,0],[0,3,4],[2,0,1]].

    1. The first two minors are 3 and −8. The third entry is zero.
    2. The expansion is 1(3) − 2(−8) + 0 = 19.
    Link to this example

Track changes to a determinant

  • Multiply or transpose square matricesdet(AB) = det A · det B, det(Aᵀ) = det AFor the product, A and B are square of the same size.

    What it does

    The determinant of a product of square matrices is the product of their determinants. A transpose keeps the determinant.

    Worked example

    Let A = [[2,0],[0,3]] and B = [[1,2],[0,4]]. Find det(AB) and det(Bᵀ).

    1. The determinants are 6 and 4, so det(AB) = 24.
    2. Bᵀ has rows [1,0] and [2,4], and its determinant is still 4.
    Link to this example
  • Invert a nonsingular matrixdet(A−1) = 1/det A

    What it does

    A matrix times its inverse gives an identity, so their determinants are reciprocals.

    Worked example

    If A = [[2,0],[0,5]], find det(A−1).

    1. The original determinant is 2 × 5 = 10.
    2. The inverse determinant is 1/10. Its diagonal entries are 1/2 and 1/5.
    Link to this example
  • Scale an entire n-by-n matrixdet(cA) = cn det A

    What it does

    Scaling an n-by-n matrix by c scales each of its n rows, giving a total determinant factor of cn.

    Worked example

    A 3×3 matrix has determinant 4. Find det(−2A).

    1. The row scaling factor is −2 for each of three rows.
    2. det(−2A) = (−2)³ × 4 = −32.
    Link to this example
  • Swap two distinct rowsdet after the swap = −det before the swap

    What it does

    Exchanging two distinct rows multiplies the determinant by −1.

    Worked example

    Swap the rows of [[2,1],[3,4]] and compare determinants.

    1. The original determinant is 8 − 3 = 5.
    2. The swapped determinant is 3 × 1 − 4 × 2 = −5.
    Link to this example

Undo an invertible matrix

  • Transpose the cofactor matrix and divideadj A = Cᵀ, A−1 = adj A/det AHere C = [C_{ij}] and det A ≠ 0.

    What it does

    The adjugate is the transpose of the signed cofactor matrix. Dividing it by the nonzero determinant yields the inverse.

    Worked example

    Use the adjugate to invert A = [[3,1],[2,1]].

    1. The cofactor matrix is [[1,−2],[−1,3]], so adj A = [[1,−1],[−2,3]].
    2. det A = 1, so the inverse equals the adjugate.
    Link to this example
  • Inverse on either sideAA−1 = A−1A = I

    What it does

    An inverse cancels its square matrix from either side of a product.

    Worked example

    Verify the inverse of A = [[2,0],[0,4]] from both sides.

    1. Take B = [[1/2,0],[0,1/4]].
    2. In both AB and BA the diagonal entries multiply to 1, with off-diagonal entries 0.
    Link to this example
  • Undo a product in reverse order(AB)−1 = B−1A−1Both factors must be invertible square matrices of the same size.

    What it does

    To undo AB, first undo A acting last on a vector, then undo B. The inverse matrix product is written in reverse order.

    Worked example

    Take A = [[2,0],[0,3]] and B = [[0,1],[1,0]]. Find (AB)−1.

    1. B−1 = B and A−1 = [[1/2,0],[0,1/3]].
    2. Multiply in reverse order to get [[0,1/3],[1/2,0]]. This times AB gives I2.
    Link to this example

Solve simultaneous equations

  • Collect coefficients into a matrixAx = b ⇒ x = A−1b when A is invertible.

    What it does

    Matrix form puts coefficients into A, unknowns into x and constants into b. If A is invertible, multiplication by its inverse solves the system.

    Worked example

    Solve 2x + y = 7 and y = 3 using the inverse.

    1. Use A = [[2,1],[0,1]], A−1 = [[1/2,−1/2],[0,1]] and b = [7,3]ᵀ.
    2. Multiplication gives x = (7 − 3)/2 = 2 and y = 3.
    Link to this example
  • Find one component with determinantsxi = det(Ai)/det AA is invertible and A_i is A with column i replaced by b.

    What it does

    Cramer’s rule uses the determinant with the chosen variable’s coefficient column replaced by the constants.

    Worked example

    Find y in 2x + y = 5 and x − y = 1.

    1. det A = −3. Replacing the second column gives [[2,5],[1,1]], also with determinant −3.
    2. The ratio is y = (−3)/(−3) = 1.
    Link to this example
  • Apply row operations to the augmented system[A | b] → [I | x] when A is square and invertible.For a general system, row reduction also detects inconsistent rows and free variables.

    What it does

    Row operations on the augmented matrix preserve the solutions. Reducing the coefficient block to the identity exposes a unique solution.

    Worked example

    Solve x + y = 5 and x − y = 1 by row reduction.

    1. Replace row 2 by row 2 minus row 1, giving −2y = −4, hence y = 2.
    2. Subtract the scaled second row from row 1. The identity block now shows x = 3, y = 2.
    Link to this example
See Algebra Formula Sheet

Find invariant directions and scaling factors

  • Eigenvector and characteristic equationAv = λv with v ≠ 0, det(A − λI) = 0

    What it does

    An eigenvector is nonzero and is only scaled by the matrix. A candidate scale makes A − λI singular.

    Worked example

    Find the eigenvalues of A = [[4,1],[0,2]] and an eigenvector for 4.

    1. The characteristic determinant is (4 − λ)(2 − λ), so λ = 4 or 2.
    2. For v = [1,0]ᵀ, Av = [4,0]ᵀ = 4v.
    Link to this example
  • Read trace and determinant from eigenvaluestr A = Σi λi, det A = ∏i λiInclude complex eigenvalues if present and count each with its algebraic multiplicity.

    What it does

    The trace sums the eigenvalues, and the determinant multiplies them, counting algebraic multiplicity.

    Worked example

    Find trace and determinant for the triangular matrix [[3,7],[0,−2]].

    1. The eigenvalues are its diagonal entries 3 and −2.
    2. Their sum is 1 and their product is −6, matching the trace and determinant.
    Link to this example
See Vector Formulas

Preview the printable

Download the compact sheet for a quick review, or print the complete formula list from this page.

Practice these skills

Related references

Sources and review

Math Sheet prepares original print materials. See how we check formulas and printouts.

Browse all formula sheets →