SigmaField
Mathematical Foundations for Quant Finance
0 of 256 lessons
      1. 3.4.1 Determinants as volume scalingConcept · 35 min
      2. 3.4.2 Practice set: determinantsPractice set · 20 min
      3. 3.4.3 Case study: redundant assets in a payoff matrixCase study · 30 min

Level 3, Linear algebra 3.4 Determinants Lesson 1 of 3

ConceptLesson 3.4.1 in Level 3, Linear algebra. About 35 minutes.

Determinants as volume scaling

How a matrix changes area

A 2×22 \times 2 matrix AA maps the plane to itself (lesson 3.2.2). Its first column is where e1=(1,0)\mathbf{e}_1 = (1, 0) lands and its second is where e2=(0,1)\mathbf{e}_2 = (0, 1) lands. So the unit square, with corners 0\mathbf{0}, e1\mathbf{e}_1, e1+e2\mathbf{e}_1 + \mathbf{e}_2 and e2\mathbf{e}_2, lands on the parallelogram whose sides are the two columns.

Take

A=(3112)A = \begin{pmatrix} 3 & 1 \\ 1 & 2 \end{pmatrix}

The square lands on the parallelogram with sides (3,1)(3, 1) and (1,2)(1, 2). Its fourth corner is (3,1)+(1,2)=(4,3)(3, 1) + (1, 2) = (4, 3).

To find its area, draw the box around it, 4 wide and 3 tall, and cut away the six pieces outside it:

piecearea
the box, 4 by 312
two triangles along the long sides1.5+1.51.5 + 1.5
two triangles along the short sides1+11 + 1
two corner squares1+11 + 1
the parallelogram12−7=512 - 7 = 5

The matrix AA sends the unit square to a parallelogram with sides its columns. The box around it has area 12, the six pieces outside it 7, so the parallelogram has area 5.

Every grid square lands on a copy of this parallelogram, so AA multiplies every area by 5. A triangle of area 2 lands on one of area 10.

The same counting with letters gives the area for any 2×22 \times 2 matrix. It is ad−bcad - bc, the number lesson 3.2.3 divides by to find the inverse. For AA, 3⋅2−1⋅1=53 \cdot 2 - 1 \cdot 1 = 5.

Rule: Determinant of a 2 × 2 matrix

det⁡(abcd)=ad−bc\det \begin{pmatrix} a & b \\ c & d \end{pmatrix} = ad - bc

The determinant is the signed area of the parallelogram the unit square lands on. The map multiplies every area by ∣det⁡A∣\lvert \det A \rvert, so the determinant is a ratio: area out per unit of area in.

When the entries are plain numbers, so is the determinant. If every entry is in dollars, ad−bcad - bc is in dollars squared, so changing the units changes it; case study 3.4.3 shows why that matters.

Area can stay the same while the shape changes. The stretch (2000.5)\begin{pmatrix} 2 & 0 \\ 0 & 0.5 \end{pmatrix} turns the square into a 2 by 0.5 rectangle: det⁡=2⋅0.5−0⋅0=1\det = 2 \cdot 0.5 - 0 \cdot 0 = 1. The shear (1101)\begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} leans it over with the same base and height: det⁡=1\det = 1.

Try it

det2 is the rule. The second line is the box count, and np.linalg.det agrees: round(…, 10) hides rounding in the last digit.

The last line maps the four corners of the unit square, stored as columns. They land on (0,0)(0, 0), (3,1)(3, 1), (4,3)(4, 3) and (1,2)(1, 2).

⌘/Ctrl + Enter runs the cell

The sign: flipped or not

Swap the columns of AA and the parallelogram is the same shape, yet det⁡(1321)=1⋅1−3⋅2=−5\det \begin{pmatrix} 1 & 3 \\ 2 & 1 \end{pmatrix} = 1 \cdot 1 - 3 \cdot 2 = -5. The sign records the orientation: the direction you turn to go from the first column to the second.

For the unit square, turning from e1\mathbf{e}_1 to e2\mathbf{e}_2 is anticlockwise. Under AA, turning from (3,1)(3, 1) to (1,2)(1, 2) is anticlockwise too, and det⁡A=5>0\det A = 5 > 0. With the columns swapped, the turn from (1,2)(1, 2) to (3,1)(3, 1) is clockwise: the plane has been flipped over, as in a mirror.

matrixdet⁡\detwhat happens to the unit square
AA5area times 5, not flipped
AA with its columns swapped−5-5area times 5, flipped
stretch, (2000.5)\begin{pmatrix} 2 & 0 \\ 0 & 0.5 \end{pmatrix}1a 2 by 0.5 rectangle
quarter turn, (0−110)\begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}1turned, not flipped
reflection, (100−1)\begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}−1-1flipped, same size
Z=(120.51)Z = \begin{pmatrix} 1 & 2 \\ 0.5 & 1 \end{pmatrix}0flattened onto a line

The last row is lesson 3.2.3's singular matrix ZZ. Its second column, (2,1)(2, 1), is twice its first, (1,0.5)(1, 0.5), so the square is squashed onto a line and has no area left.

Rule: What the sign says

det⁡A>0:orientation keptdet⁡A<0:flipped overdet⁡A=0:flattened\begin{gathered} \det A > 0: \text{orientation kept} \\ \det A < 0: \text{flipped over} \\ \det A = 0: \text{flattened} \end{gathered}

The change in area is ∣det⁡A∣\lvert \det A \rvert in every case. A negative determinant is not a negative area: it is a positive area, flipped.

The explorer starts on ZZ, the "Flatten" matrix, with its square squashed flat. Raise dd from 1 to 1.5 and the square opens to area 0.5; lower it to 0.5 and the determinant is −0.5-0.5, a flip. Then try the reflection and the quarter turn.

Explore

Pick a matrix or set its entries. Its first column is where e₁ lands and its second where e₂ lands; the whole grid follows. Then drag the probe x and look for directions that A only stretches.

−4−4−2−22244Ae₁Ae₂xAx
Probe x = (1, 2) (drag its tip)
Matrix
A=(120.51)A = \begin{pmatrix} 1 & 2 \\ 0.5 & 1 \end{pmatrix}
Columns
Ae₁ = (1, 0.5), Ae₂ = (2, 1)
det A
1 × 1 − 2 × 0.5 = 0: the plane is flattened onto a line (or a point), so A has no inverse.
Probe
Ax = (5, 2.5): a different direction.
Eigenvalues
λ = 2 and 0

Try it

Each line prints a matrix of the table and its determinant.

Adding 0.0 turns a -0.0 into 0.0, as in lesson 3.2.3.

⌘/Ctrl + Enter runs the cell

Three by three: the volume of a box

A 3×33 \times 3 matrix maps space to itself. The unit cube, with edges e1\mathbf{e}_1, e2\mathbf{e}_2 and e3\mathbf{e}_3, lands on a slanted box whose edges are the three columns. The determinant is the signed volume of that box.

Take

B=(211021002)B = \begin{pmatrix} 2 & 1 & 1 \\ 0 & 2 & 1 \\ 0 & 0 & 2 \end{pmatrix}

Its first two columns, (2,0,0)(2, 0, 0) and (1,2,0)(1, 2, 0), lie flat on the floor, where the third component is 0. They span a parallelogram of area 2⋅2−1⋅0=42 \cdot 2 - 1 \cdot 0 = 4. The third column, (1,1,2)(1, 1, 2), rises to height 2, so the box has volume 4×2=84 \times 2 = 8.

BB sends the unit cube to a slanted box with edges its columns. Its floor has area 4 and its height is 2, so its volume is 8.

Most boxes do not sit so neatly on the floor. For any 3×33 \times 3 matrix, the determinant is built from 2×22 \times 2 ones.

Write aija_{ij} for the entry in row ii and column jj. Its minor MijM_{ij} is the determinant of what is left after deleting row ii and column jj.

Rule: Cofactor expansion along row 1

det⁡A=a11M11−a12M12+a13M13\begin{gathered} \det A = a_{11}M_{11} - a_{12}M_{12} \\ + a_{13}M_{13} \end{gathered}

Each entry of the first row times its minor, with signs ++, −-, ++. A signed minor is called a cofactor. The result is the signed volume of the box the unit cube lands on.

Take

C=(213041102)C = \begin{pmatrix} 2 & 1 & 3 \\ 0 & 4 & 1 \\ 1 & 0 & 2 \end{pmatrix}
entry a1ja_{1j}signminor M1jM_{1j}term
2++4⋅2−1⋅0=84 \cdot 2 - 1 \cdot 0 = 816
1−-0⋅2−1⋅1=−10 \cdot 2 - 1 \cdot 1 = -11
3++0⋅0−4⋅1=−40 \cdot 0 - 4 \cdot 1 = -4−12-12

So det⁡C=16+1−12=5\det C = 16 + 1 - 12 = 5. The middle term is subtracted, and its minor is negative, so it adds 1.

Any row or column works, with the signs of a checkerboard:

(+−+−+−+−+)\begin{pmatrix} + & - & + \\ - & + & - \\ + & - & + \end{pmatrix}

Row 2 of CC is (0,4,1)(0, 4, 1), with signs −-, ++, −-. Its minors are M22=2⋅2−3⋅1=1M_{22} = 2 \cdot 2 - 3 \cdot 1 = 1 and M23=2⋅0−1⋅1=−1M_{23} = 2 \cdot 0 - 1 \cdot 1 = -1, and the 0 saves working out M21M_{21}. So det⁡C=−0+4⋅1−1⋅(−1)=5\det C = -0 + 4 \cdot 1 - 1 \cdot (-1) = 5 again.

Expand along the row or column with the most zeros.

For BB, the first column has two zeros: det⁡B=2×(2⋅2−1⋅0)=8\det B = 2 \times (2 \cdot 2 - 1 \cdot 0) = 8. BB is upper triangular, with zeros below the diagonal, and its determinant is the product of the diagonal, 2⋅2⋅22 \cdot 2 \cdot 2.

As in the plane, a negative 3×33 \times 3 determinant means the map turns space into its mirror image. The volume is still ∣det⁡A∣\lvert \det A \rvert.

Try it

det3 is the expansion along row 1. The loop prints each entry of row 1 of CC with its minor: np.delete removes row 1, then column jj.

np.linalg.det(C) printed 4.999999999999998 when this lesson was written; the last digits can differ on another computer. Rounding fixes that.

⌘/Ctrl + Enter runs the cell

Determinant 0: no inverse

A determinant is 0 exactly when the box is flat: the columns lie in one plane, or on one line. Then some column is a combination of the others, and the columns are called dependent (lesson 3.5.1 studies this). Elimination finds fewer than nn pivots, so the rank is below nn (lesson 3.3.2).

A flattened space cannot be unflattened, so AA has no inverse: it is singular, as lesson 3.2.3 called ZZ. The inverse formula of lesson 3.2.3 divides by ad−bcad - bc, which is 0 here.

Rule: The invertibility test

det⁡A≠0  ⟺  A−1 exists\det A \neq 0 \iff A^{-1} \text{ exists}

For a square n×nn \times n matrix, four statements go together: det⁡A≠0\det A \neq 0, independent columns, rank nn, and exactly one solution of Ax=bA\mathbf{x} = \mathbf{b} for every b\mathbf{b}. When det⁡A=0\det A = 0, Ax=bA\mathbf{x} = \mathbf{b} has no solution or infinitely many.

A 3×33 \times 3 example:

S=(134314167)S = \begin{pmatrix} 1 & 3 & 4 \\ 3 & 1 & 4 \\ 1 & 6 & 7 \end{pmatrix}

Its third column is the sum of the first two, so the box is flat. Along row 1, the minors are −17-17, 17 and 17, and 1⋅(−17)−3⋅17+4⋅17=01 \cdot (-17) - 3 \cdot 17 + 4 \cdot 17 = 0. Its rank is 2.

On a computer, np.linalg.det(S) prints a tiny number, here 7.5×10−157.5 \times 10^{-15}, not 0; the exact digits depend on the computer's maths library. As lesson 3.3.2 found for rank, rounding hides zeros: elimination in decimals leaves a tiny number where a 0 pivot should be. Ask np.linalg.matrix_rank instead, which allows for rounding.

Try it

The first line checks ZZ: determinant 0, rank 1. The second checks that column 3 of SS is column 1 plus column 2.

The determinant of SS is printed to two significant figures, since its digits are rounding noise. matrix_rank says 2.

⌘/Ctrl + Enter runs the cell

Rules for products, transposes and rows

Doing one map after another multiplies their area factors: the product ABAB is "BB, then AA" (lesson 3.2.2). So det⁡(AB)=det⁡A⋅det⁡B\det(AB) = \det A \cdot \det B.

With AA as above, det⁡A=5\det A = 5, and B=(1203)B = \begin{pmatrix} 1 & 2 \\ 0 & 3 \end{pmatrix}, det⁡B=3\det B = 3. Both ABAB and BABA have determinant 15, although AB≠BAAB \neq BA (lesson 3.2.1). There is no rule for sums: A+B=(4315)A + B = \begin{pmatrix} 4 & 3 \\ 1 & 5 \end{pmatrix} has determinant 17, not 5+35 + 3.

Two more rules follow. A−1A^{-1} undoes AA, so it divides every area by det⁡A\det A: det⁡C−1=15\det C^{-1} = \frac{1}{5}. And det⁡A⊤=det⁡A\det A^\top = \det A: rows and columns play the same part, so each rule for rows below holds for columns too.

Row operations (lesson 3.3.1) change the determinant in set ways. Starting from CC, with det⁡C=5\det C = 5:

change to CCnew det⁡\det
swap rows 1 and 3−5-5
multiply row 2 by 315
subtract 2 × row 3 from row 15
multiply every entry by 223×5=402^3 \times 5 = 40

Multiplying every entry by 2 multiplies each of the 3 rows by 2, so the determinant grows by 2×2×22 \times 2 \times 2. In the box picture, every edge doubles and the volume grows 8 times.

Rule: Determinant rules

det⁡(AB)=det⁡A⋅det⁡Bdet⁡A⊤=det⁡Adet⁡A−1=1/det⁡Adet⁡(cA)=cndet⁡A\begin{gathered} \det(AB) = \det A \cdot \det B \\ \det A^\top = \det A \\ \det A^{-1} = 1 / \det A \\ \det(cA) = c^n \det A \end{gathered}

For an n×nn \times n matrix. A row swap flips the sign, and multiplying one row by cc multiplies the determinant by cc. Adding a multiple of one row to another changes nothing.

Try it

det rounds NumPy's answer. The first line prints det⁡(AB)\det(AB), det⁡(BA)\det(BA), det⁡A⋅det⁡B\det A \cdot \det B and det⁡(A+B)\det(A + B).

C[[2, 1, 0]] lists the rows of CC in the order 3, 2, 1, which swaps rows 1 and 3. .copy() keeps CC unchanged.

⌘/Ctrl + Enter runs the cell

How a computer finds a determinant

Elimination (lesson 3.3.1) uses only swaps and "add a multiple of one row to another". The second kind leaves the determinant alone, and each swap flips its sign. Elimination ends at a triangular matrix, whose determinant is the product of its diagonal, the pivots.

For CC: subtract 0.5×0.5 \times row 1 from row 3, giving (0,−0.5,0.5)(0, -0.5, 0.5). Then add 0.125×0.125 \times row 2, giving (0,0,0.625)(0, 0, 0.625). The pivots are 2, 4 and 0.625, and 2×4×0.625=52 \times 4 \times 0.625 = 5.

np.linalg.det works this way, in decimals, which is where its rounding comes from. A small determinant alone does not mean a matrix is nearly singular. Take 0.001 I0.001\,I, where II is the 3×33 \times 3 identity: its determinant is 10−910^{-9}, yet its columns point along the three axes and its rank is 3.

Try it

The two row operations on CC, then the product of the pivots.

The last line is the determinant and rank of 0.001 I0.001\,I.

⌘/Ctrl + Enter runs the cell

Case study 3.4.3 uses determinants to spot redundant assets, and lesson 3.6.1 finds eigenvalues by solving det⁡(A−λI)=0\det(A - \lambda I) = 0.

Common mistakes

  1. Multiply along the diagonals. det⁡(abcd)=ad−bc\det \begin{pmatrix} a & b \\ c & d \end{pmatrix} = ad - bc, not ab−cdab - cd.
  2. The sign is orientation, not negative area. A determinant of −5-5 means area times 5, flipped. The area is ∣det⁡A∣\lvert \det A \rvert.
  3. Mind the cofactor signs. Along row 1 they are ++, −-, ++; along row 2, −-, ++, −-. Forgetting the minus on the middle term is the usual slip.
  4. Scaling a matrix scales its determinant by cnc^n. det⁡(2C)=8det⁡C\det(2C) = 8 \det C for a 3×33 \times 3 matrix, not 2det⁡C2 \det C. Scaling one row multiplies by cc once.
  5. There is no rule for sums. det⁡(A+B)\det(A + B) is not det⁡A+det⁡B\det A + \det B; only products split.
  6. Only square matrices have determinants. A 3×23 \times 2 matrix has a rank but no determinant.
  7. Do not test det == 0 on a computer. Rounding leaves tiny numbers such as 10−1510^{-15}; use matrix_rank. And a tiny determinant can come from small units, as for 0.001 I0.001\,I.

Determinants

0 of 12 correct

  1. 1.
  2. 2.
  3. 3.
  4. 4.
  5. 5.
  6. 6.
  7. 7.
  8. 8.
  9. 9.
  10. 10.
  11. 11.
  12. 12.
How to type answers
  • Powers with ^: x^7, 2^(1/3), a^-2.
  • Multiply with * or by writing side by side: 3x^2, 2(x+1).
  • ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
  • sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
  • Your first answer to each question is saved: it counts towards your score and brings the question back for review.
  • Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.

Summary card

  • det⁡(abcd)=ad−bc\det \begin{pmatrix} a & b \\ c & d \end{pmatrix} = ad - bc: the signed area of the parallelogram the unit square lands on. The map multiplies every area by ∣det⁡A∣\lvert \det A \rvert.
  • The sign is orientation: positive keeps it, negative flips the plane over, 0 flattens it.
  • 3×33 \times 3: expand along a row, a11M11−a12M12+a13M13a_{11}M_{11} - a_{12}M_{12} + a_{13}M_{13}, with checkerboard signs; the result is the signed volume of the box the unit cube lands on. A triangular matrix has the product of its diagonal.
  • det⁡A=0\det A = 0 exactly when the columns are dependent, the rank is below nn and AA has no inverse: AA is singular.
  • det⁡(AB)=det⁡Adet⁡B\det(AB) = \det A \det B, det⁡A⊤=det⁡A\det A^\top = \det A, det⁡A−1=1/det⁡A\det A^{-1} = 1/\det A, det⁡(cA)=cndet⁡A\det(cA) = c^n \det A. A row swap flips the sign; scaling a row scales the determinant; adding a multiple of a row changes nothing.
  • np.linalg.det eliminates in decimals, so a 0 can print as 10−1510^{-15}; test with matrix_rank.

Free further reading

Optional. This lesson covers what you need; these add more examples and practice. All are free to read.