Notes
1P4 Mathematics · Topic 9

Matrix toolkit, transpose, determinant and inverse

Lecture 13 · Fri 20 Nov

What is a vector and what is a matrix?

The words “vector” and “matrix” are used for two different kinds of object.

1. Containers of numbers. A matrix is a two-dimensional container of numbers. An (column) vector is a one-dimensional container. Neither needs to have any physical meaning:

2. Physical vectors. A vector with physical meaning (a force, a position) is defined by its components and a basis:

Definition Physical vector: components need a basis

The column only means something once the basis is given. If no basis is stated, assume (Right-handed Cartesian basis). The same physical vector has different components in different bases (treated later in the course).

In this part of the course the matrices are those that transform physical vectors. Such a matrix represents a linear mapping that takes physical vectors to physical vectors.

Definition Linear mapping

A mapping that respects addition and scaling:

Every matrix acting on column vectors has this property, because each component of is a sum of terms each linear in the components of (Matrix product (element form)).

Explanation Why does the basis matter if the vector is the same?

Take . In the basis its components are . Now use the basis , , . Then , so the components are . The arrow has not moved; only the column of numbers describing it has changed. A matrix acting on that column therefore also depends on the basis you are working in.

  • “Matrix/vector” can mean a plain container of numbers, or a physical object.
  • Physical vector = components + basis. With no basis stated, assume .
  • The matrices in this part are linear maps that send physical vectors to physical vectors.

Example: shear in two dimensions

Shear a piece of material parallel to the -axis, so that lines that were vertical end up at angle to the -axis. A point at moves to at .

Equation Shear parallel to the x-axis memorise

is the angle the sheared “vertical” lines make with the -axis.

Show derivation
  1. In a shear parallel to , each horizontal layer slides sideways and keeps its height, so .
  2. A material line that was vertical, , becomes a straight line through at angle to the vertical.
  3. On that line, the point at height is displaced horizontally by “opposite = adjacent ”: . Hence , i.e. .
  4. By the Matrix product (element form) rule, , which reproduces both equations.

Writing the map as separates the transformation from the coordinates. does not depend on the particular and , so to study the transformation we only need to study the matrix .

Interactive figure

Drag . Every point moves sideways by , so the top edge moves most and the bottom edge not at all. The columns of are where and end up (see Columns of A = images of the basis vectors). The area stays 1 at every , which is why .

Figure Shear of a unit square
Explanation Does a shear change area?

No. The square becomes a parallelogram with the same base (1) and the same height (1). This is the first example of the rule in |det A| is the area/volume scale factor: , so areas are unchanged.

  • Shear parallel to : unchanged, shifted by , giving .
  • : the matrix is the transformation, independent of the point.

Three dimensional transformations

Matrices represent transformations in three (or more) dimensions in the same way. The lecture’s example is

The slide prints for the element. The stated sequence of operations gives (see the extra below), which is used here.

The matrix represents, in this order:

  1. a rotation about the -axis;
  2. a shear parallel to the -axis;
  3. a compression parallel to and a stretch parallel to .

Applied to a cube, it gives a slanted parallelepiped.

Interactive figure

Step through the operations and drag to rotate. The rotation and the shear keep the volume at 1. The scaling ( in , in ) changes it to . The coloured edges are the columns of the matrix built so far.

Figure A cube under rotation, shear and scaling
Watch out

Order of composition. “First , then , then ” is the matrix . The matrix applied first sits next to the vector: .

Explanation Where do the numbers in A come from?

Take the rotation about by , a shear , and the scaling :

Multiplying out:

  • ;
  • halves row 2 and multiplies row 3 by 1.5, which gives exactly above, including in position .

As a check, .

  • Successive transformations multiply: first , then , then gives (right-to-left).

Vector and matrix notation (revision)

  • Vectors are columns, written in bold: or . Components are in normal type.
  • A column vector transposes to a row vector, (Column vector and transpose).
  • In , the element sits in row , column (Matrix and its elements).
  • Sometimes subscripts replace numbers, e.g. stress in a solid or fluid: .
  • : row first, then column.

Dot product and multiplication rules (revision)

The scalar (inner) product (Scalar product in components, written with the Einstein summation convention):

The matrix product (Matrix product (element form)), referred to as eq. (1) in this lecture:

For example, .

Row-times-column view

Element of is row of dotted with column of (Product as row · column). Here denotes the rows of and the columns of :

  • This works for non-square matrices too, provided the product is defined: . The inner dimensions must match (When a product exists, Shapes in a matrix product).
  • Vectors are just non-square matrices (a length-4 column is ), so eq. (1) applies to them as well.
Explanation How do I remember the index pattern in (1)?

The summed index is the inner one and sits between the free indices: . It matches the shape rule : the repeated, inner dimension is the one summed over, and the outer ones survive as and .

  • = row of · column of .
  • ; inner dimensions must match.

Algebra

Definition Identity matrix

For a square matrix , the identity satisfies

Check (not a proof)

With (Kronecker delta), eq. (1) gives by the substitution property (Substitution property of δ). Similarly .

Result Matrix multiplication is associative memorise
Show derivation

(The lecture leaves this as an exercise using eq. (1).) Apply eq. (1) twice to each side:

Both are the same finite double sum, only summed in a different order, so they are equal for every .

Result Distributive over addition and subtraction memorise
Show derivation

By eq. (1), . Subtraction is the same with .

Result Not commutative: order matters memorise
Show derivation

A single counterexample is enough:

Watch out

The second product in the counterexample is the zero matrix, although neither factor is zero. So:

  • does not imply or ;
  • you cannot “cancel” a matrix, i.e. , unless exists (Inverse of a square matrix).
  • Associative and distributive: brackets can be moved and products expanded as in ordinary algebra.
  • Not commutative: keep left/right order in every manipulation. When multiplying both sides of an equation, do it on the same side.
  • is only defined for square matrices; .

Transpose

Definition

Definition Transpose

is with rows and columns interchanged:

Row of becomes column of . An matrix transposes to . Transposing twice gives back the original: .

a11 a12 a13 a21 a22 a23 a31 a32 a33 A

Transposing swaps each pair of same-coloured elements across the shaded leading diagonal. The diagonal itself stays put.

Figure Transpose: reflection in the leading diagonal
Explanation Words you will meet with the transpose
  • A square matrix is symmetric if ().
  • It is antisymmetric (skew-symmetric) if (, which forces ).
  • The trace is the sum of the diagonal elements, . Transposing leaves it unchanged, since the diagonal stays put.

Transpose of a product

Equation Transpose of a product databook p.17

The order reverses. Valid for , .

Show derivation

Index form (lecture). Use Transpose and eq. (1):

The step that swaps is allowed because these are numbers. It is what puts the indices into the “inner index adjacent” pattern of eq. (1).

Row/column form (lecture). Write , with row of and column of (Product as row · column). Then

This is row of a matrix whose rows are the , dotted with column of a matrix whose columns are the :

Longer products. Use associativity (Matrix multiplication is associative) and the two-matrix rule repeatedly:

and so on by induction.

Explanation Quick sanity check that the order must reverse

Check the shapes. is and is , so is .

  • is , which is correct.
  • is , which is not even defined unless .

Same idea as taking off socks and shoes: the last thing put on comes off first.

Dot product as a matrix product

Equation Dot product as aᵀb memorise

are column vectors of the same length. The result is a matrix, i.e. a scalar.

Show derivation

is with , and is with . Eq. (1) gives a result:

which is Scalar product in components.

Example Length-four vectors

Outer product: a matrix from two vectors

Equation Outer product abᵀ memorise

has length and has length (treated as and matrices). The product is an matrix.

Show derivation

is with . is with (Transpose). The inner dimension is 1, so eq. (1) has a single term:

Example Lengths three and two
Watch out

(row × column) is a scalar. (column × row) is a matrix. Check by shapes: , but .

  • ; .
  • Transpose of a product reverses the order: (databook).
  • To prove matrix identities, work with index form and eq. (1).
  • = scalar (dot product); = matrix with entries .

Determinant and inverse

Determinant by cofactor expansion

Definition Minor and cofactor
  • The minor is the determinant of the matrix left after deleting row and column of .
  • The cofactor is .

The signs follow a chessboard pattern starting with at the top left:

The cofactor matrix has elements .

Equation Determinant by cofactors databook p.15

For : .

Where it comes from

Where it comes from. This is the definition of the determinant used earlier in the course: expansion along the first row, (databook maths p15). It is applied recursively down to determinants, . For it equals the scalar triple product of the rows.

That expanding along any row or column gives the same value is stated in the course but not proved (the lecturer says so in Appendix A2). For you can confirm it by writing out all six products for each expansion: every expansion produces the same six terms with the same signs.

Check (not a proof)

Take the worked example below. Expanding along row 1 instead of row 2:

which is the same answer.

Choose the row or column with the most zeros: every zero element removes a whole minor from the work.

Example Expanding a 3×3 determinant along row 2

Row 2 is and its signs are :

The slide gives the middle cofactor a minus sign. In fact = (chessboard sign ). The slip is harmless here only because .

  • Cofactor ; chessboard signs, top left.
  • Expand along any row or column; pick the one with most zeros.
  • Each term is element × cofactor; don’t forget the chessboard sign.

The determinant as a scale factor

Result |det A| is the area/volume scale factor memorise

When is used as a transformation, is its scale factor : it maps a unit “volume” to times the unit “volume”.

  • :
  • :
Show derivation

2D case (Appendix A1).

  1. Take elemental vectors along the axes, and . By |a × b| is the area of the parallelogram, the magnitude of their cross product is the area they sweep out:
  2. Embed a general map in 3D, leaving alone: . Then and .
  3. By Vector product in components, only the -component of their cross product survives:
  4. So the area has changed from to .
  5. A small rectangle at any other position maps to the same shape at , because by linearity . Any region can be filled with such rectangles, so every area scales by .

3D case.

  1. The unit cube spanned by maps to the parallelepiped spanned by the columns of (Columns of A = images of the basis vectors).
  2. Its volume is base × height. The base area is (|a × b| is the area of the parallelogram). The height is the projection of onto the unit normal (a·b as |a| times the projection of b onto a). So the volume is .
  3. Write and expand with Vector product in components and Scalar product in components:
    This is exactly the column-1 Determinant by cofactors .
  4. Small cubes anywhere scale the same way (as in step 5 of the 2D case), so every volume scales by .
Interactive figure

The columns are the images of ; the dashed square (area 1) maps to the shaded parallelogram. Rotate with . The area always equals . When lines up with , the parallelogram collapses and . Past that point the determinant goes negative (purple): the square has been flipped over.

Figure det A as the area of the image of the unit square

For interest only (Appendix A1, not examinable). The cross product exists only in 3D. In dimensions one uses the outer product (a different object from the matrix above, despite the shared name): is an -dimensional volume element. The rules of the outer product show that equals times the original, which gives a short proof for any .

Explanation What does the sign of det A mean?

gives the size change. The sign gives the orientation:

  • : a right-handed set maps to a right-handed set (rotations, shears, positive stretches).
  • : the image is “turned inside out”, as in a mirror reflection (e.g. has determinant ).
  • : the square or cube is squashed flat onto a line or plane. Many points land on the same image point, so the map cannot be undone. This is the geometric reason there is then no inverse (When does the inverse exist?).
  • = factor by which multiplies areas (2D) or volumes (3D).
  • means orientation is reversed (reflection); means space is squashed flat, so no inverse.

The inverse

Definition Inverse of a square matrix

For a square matrix , the inverse satisfies

The inverse is not guaranteed to exist.

The inverse can be computed in several ways. This course uses cofactors.

Equation Inverse from cofactors databook p.15

Recipe for an matrix:

  1. Calculate the cofactor matrix .
  2. Transpose it to get .
  3. Divide by .
Show derivation

Show that . By eq. (1) and Transpose:

  • : this is , the Determinant by cofactors along row , so it equals .
  • : let be with row replaced by a copy of row . The cofactors never use row , so they are the same for as for . Hence is the expansion of along row . But has two equal rows, so (Properties 1–4: row and column operations, property 3).

So . In the same way, is a column expansion (equal to if ; equal to 0 otherwise, because there are two equal columns), so .

If , dividing by it gives , which is the Inverse of a square matrix definition.

Definition Adjugate

The transpose of the cofactor matrix, , is called the adjugate of . So .

Result When does the inverse exist? memorise
Show derivation
  • : steps 1 and 2 of the recipe (Inverse from cofactors) always work. The only thing that can go wrong is step 3, dividing by . That is fine when , and the result satisfies the definition.
  • : if an inverse existed, Property 7: det of a product would give , which is impossible when .
Watch out

Two common errors in step 1–2 of the recipe:

  • forgetting to transpose ;
  • dropping a chessboard sign in .

Always check that . One row × column takes seconds.

Explanation Is there a quick formula for 2×2?

Yes (databook maths p15). For :

  • the cofactors are , , , ;
  • so and

In words: swap the diagonal, negate the off-diagonal, divide by the determinant.

Explanation What is the inverse of a product?

(databook maths p17). The order reverses, just as for the Transpose of a product. Check:

Undoing “first , then ” means undoing first.

  • : cofactors, then transpose (adjugate), then divide.
  • The inverse exists if and only if ; check first.
  • Verify with .

Properties of the determinant

These hold for square . The lecturer’s sketch proofs (Appendix A2) use the scale-factor picture and start from property 7. Each box also gives a direct proof from the Determinant by cofactors, which is what “going back to the definition” means.

Result Properties 1–4: row and column operations memorise
  1. Multiplying any row or column by a constant multiplies by .
  2. Exchanging two rows (or two columns) changes the sign of .
  3. If two rows (or columns) are equal, .
  4. Adding a multiple of one row to another row leaves unchanged. The same holds for columns.
Show derivation Lecturer’s sketch (Appendix A2): via elementary matrices and property 7

Each row operation is left-multiplication by a simple matrix , so by Property 7: det of a product . Column operations are right-multiplication. The determinants of the s follow by expanding along a row that contains a single 1.

  • 4. To add row to row , use the identity with in position (row , column ). For columns, multiply on the right with in position . For example, adds row 1 to row 2. Such a matrix has determinant 1, so is unchanged.
  • 3. If two rows are equal, subtract one from the other. By 4 this does not change , but it leaves a row of zeros, and expanding along that row gives 0. Similarly for columns.
  • 2. Swapping two rows is left-multiplication by a permutation matrix: the identity with the two relevant 1s moved, e.g. . Its determinant is , so the sign flips. For columns, multiply on the right.
  • 1. Multiplying row (column) by is left (right) multiplication by the identity with its th 1 replaced by . That matrix has determinant .
Show derivation Direct proof from the cofactor expansion
  • 1. Expand along the scaled row . The cofactors do not involve row , so every term gains a factor .
  • 3. For with equal rows: . For larger , expand along a row that is not one of the two equal ones. Every minor still contains the two equal rows, so by induction every minor is 0.
  • 2. For : . For larger , expand along a row not involved in the swap. Each minor has two of its rows swapped, so by induction each minor changes sign.
  • 4. Replace row by row row and expand along row :
    The last sum is the determinant of a matrix whose rows and are both row . By 3 it is zero.

Columns: the same arguments with column expansions.

h a1 a2 a2 + αa1

Replacing column by slides the top edge parallel to the base. The base and the height are unchanged, so the area, and hence , is unchanged.

Figure Property 4 is a shear: same base, same height
Result Property 5: det Aᵀ = det A memorise

So every statement about rows has a matching statement about columns.

Show derivation

The lecturer notes that this follows because the determinant can be expanded along any row or column (Determinant by cofactors, stated without proof). In detail, by induction on the size :

  1. For : .
  2. For larger , expand along its first row. The elements are . The minor of at is the transpose of the minor of at , so by the induction hypothesis it has the same value .
  3. Hence
    which is the expansion of along its first column.
Show derivation proved later in the course

The lecturer’s second route uses results from later in the course. There, is shown to be the product of the eigenvalues of , and and are shown to have the same eigenvalues. So their determinants are equal.

Careful: arguing that the eigenvalues agree because would use property 5 itself, which is circular. The induction proof above does not have this problem.

Result Property 6: det of the inverse memorise
Show derivation

By Property 7: det of a product:

( by expanding repeatedly along the first row.) Divide by . Geometrically, undoing a map that scales volumes by must scale them by .

Result Property 7: det of a product databook p.17

square, of the same size. More generally, .

Show derivation Lecturer’s sketch (Appendix A2)
  1. Let and . By |det A| is the area/volume scale factor, each is a volume scale factor.
  2. applies , which scales every volume by , and then , which scales by . Composition simply multiplies the scale factors.
  3. The signs also multiply: each negative determinant reverses orientation, and two reversals restore it.
  4. is the same number, because the determinants are scalars, which commute (even though ).

A fully rigorous proof from the index definition is beyond this course.

Check (not a proof)

For matrices and :

Its determinant is
The terms and cancel. Grouping the rest:

Watch out

Two common traps:

  • Scaling the whole matrix. For , , not . Each of the rows picks up a factor (property 1). So for , .
  • Sums. in general.
Explanation How do these properties save work in practice?

Use property 4 to create zeros before expanding. For example:

The determinant is 0 because rows 2 and 3 are now equal (property 3). Direct expansion agrees: .

  • Row/column ops: multiplies by ; a swap flips the sign; adding a multiple of another row changes nothing; two equal rows (or a zero row) give .
  • Use the row ops to make zeros, then expand.
  • for .
  • ; ; .
  • Proof idea: each row op is multiplication by an elementary matrix, with equal to , or .

Revision exercise: inverse of a 3 × 3 matrix

Example Inverse of a 3×3 matrix by cofactors

Find for

1. Cofactor matrix. Each entry is a minor with its chessboard sign, e.g. and :

2. Transpose (the adjugate).

3. Determinant, then divide. Expand along row 1, reusing the first row of :

Check.

For example, row 1 × column 2 gives .

Explanation Why can det A reuse the cofactors?

You need the cofactors for step 1 anyway. The Determinant by cofactors along row 1 is just row 1 of dotted with row 1 of , so comes for free.

This is also a built-in check. Row 1 of dotted with row 2 or row 3 of must give 0. Here . If it does not, a cofactor is wrong.

Try now

Transformations: columns are images of the basis vectors

Write by its columns and apply it to the basis vectors:

Result Columns of A = images of the basis vectors memorise

The columns are where the -, - and -unit basis vectors go. So to build the matrix of a transformation, find where the basis vectors map to and write those images in as the columns.

Show derivation

has components (Kronecker delta). By eq. (1) and Substitution property of δ:

which is element of column .

i j A a1 = Ai a2 = Aj

The unit square spanned by maps to the parallelogram spanned by the columns of . Here .

Figure Where i and j go fixes the matrix
Explanation Why is knowing three images enough?

Any vector is a combination of the basis vectors, . By linearity:

i.e. is the combination of the columns with weights . Once the images of the basis vectors are known, the image of everything is known.

Check on the shear (Shear parallel to the x-axis):

  • stays put, giving column 1 ;
  • tips over to , giving column 2.

This is exactly the shear matrix. The next lecture builds rotation matrices the same way.

  • Column of = image of basis vector .
  • To build a transformation matrix: find where go and write them in as columns.
  • .