{"course":{"slug":"maths-you-need","title":"The Maths You Actually Need","url":"https://addaly.com/learn/maths-you-need","level":"intermediate","track":"deep"},"lesson":{"slug":"determinants-and-volume","title":"The determinant, and what it says about collapse","url":"https://addaly.com/learn/maths-you-need/determinants-and-volume","position":14,"of":76,"minutes":8,"answer":"The determinant is the factor by which a transformation multiplies volume, so a determinant of zero means dimensions were flattened away and nothing downstream can restore them.","keyIdea":"The determinant is the factor by which a transformation multiplies volume, so a determinant of zero means dimensions were flattened away and nothing downstream can restore them."},"body":{"format":"markdown","text":"## One number for a whole transformation\n\nThe determinant of a square matrix is a single number, and it has a clean geometric meaning: **it is the factor by which the transformation multiplies area, or volume, or the higher-dimensional equivalent.**\n\nTake the unit square with corners at (0,0), (1,0), (0,1), (1,1): area 1. Apply\n\n```\nA = [ 3  0 ]\n    [ 0  2 ]\n```\n\nIt becomes a rectangle 3 wide and 2 tall, area 6. And `det(A) = 3*2 − 0*0 = 6`. The number is the area scaling, exactly.\n\nNow a shear:\n\n```\nB = [ 1  1 ]     det = 1*1 - 1*0 = 1\n    [ 0  1 ]\n```\n\nThe square becomes a slanted parallelogram: different shape, same area. The determinant says 1, and it is right.\n\n## Zero means collapse\n\nThe case that matters is `det = 0`.\n\n```\nC = [ 1  2 ]     det = 1*4 - 2*2 = 0\n    [ 2  4 ]\n```\n\nThe unit square is squashed onto a line segment. A line has zero area, so the scaling factor is zero. That is the geometric version of the fact from the previous lesson: this matrix destroys a dimension, and destroyed dimensions cannot be recovered. Determinant zero, no inverse, information gone. They are three statements of one thing.\n\nNegative determinants are also meaningful: they say the transformation flipped orientation, turning a left-handed arrangement into a right-handed one, like a mirror. `det = −2` means area doubled and the space was reflected.\n\n## Computing it, and why you usually should not by hand\n\nFor a 2×2, `ad − bc`. For a 3×3 there is a longer formula. For anything larger, do not use the recursive cofactor expansion you may have been taught: it costs on the order of `n!` operations, which for a 20×20 matrix is more arithmetic than the age of the universe permits. Real implementations use LU decomposition and cost about `n^3`, the same as a matrix multiplication.\n\nAnd even then, the determinant itself is a poor thing to compute. Multiply a 100×100 matrix's entries by 2 and its determinant multiplies by `2^100`, about `1.3 × 10^30`. Determinants overflow and underflow floating-point range almost immediately at realistic sizes, which is why any library that needs one offers `slogdet`: the sign and the *logarithm* of the absolute determinant, computed as a sum of logs rather than a product.\n\n```python\nimport numpy as np\nsign, logdet = np.linalg.slogdet(A)   # stable; det(A) = sign * exp(logdet)\n```\n\n## Where it appears in machine learning\n\nThe determinant is not a daily tool, but it sits under three things you may meet.\n\n**Normalising flows.** These are generative models built from invertible transformations. To know the probability density after a transformation you must correct for how much the transformation squeezed or stretched the space, and that correction is exactly the log absolute determinant of the Jacobian. The entire architectural game in that field (coupling layers, autoregressive flows) is about designing transformations powerful enough to be useful whose Jacobian determinant is cheap to compute, usually by making the Jacobian triangular so the determinant is just the product of the diagonal.\n\n**Multivariate Gaussians.** The density of a multivariate normal contains a `det(Σ)^(-1/2)` term. Fitting one requires the log determinant of the covariance, computed via Cholesky in every serious implementation.\n\n**Diagnosing collapse.** If a covariance matrix has a determinant of effectively zero, your features are linearly dependent (one is a combination of the others) and any method that inverts that covariance will fail. Checking the log determinant, or better the singular values, tells you before the failure.\n\n## What it does not tell you\n\nThe determinant is one number summarising an entire transformation, so it hides almost everything. A matrix that stretches by 100 in one direction and squashes by 100 in another has determinant 1, exactly like the identity, while being wildly ill-conditioned and dangerous to work with. Two matrices with the same determinant can behave nothing alike.\n\nThis is the honest limit: the determinant answers \"did total volume change\" and nothing else. The question you usually want answered is \"what happens in each direction\", and for that you need the singular values, which are the subject of a later lesson in this module. The determinant is their product. Knowing a product tells you very little about its factors, and here that gap is the whole story.\n\n## The rule to keep\n\nDeterminant zero means a dimension was flattened. Determinant far from zero tells you almost nothing useful on its own, and if you find yourself needing its actual value, reach for `slogdet` rather than `det`."},"check":{"question":"Two 512x512 weight matrices both have determinant 1.0. What can you conclude about how they behave?","options":[{"text":"Both preserve volume overall, and nothing more: one could be the identity while the other stretches enormously in some directions and crushes others.","correct":true},{"text":"Both are orthogonal rotations, since determinant 1 characterises rotation matrices.","correct":false,"tempting":"Rotations do have determinant 1, but so do many non-rotations; the condition is necessary, not sufficient."},{"text":"Both are well-conditioned and safe to invert, since a determinant far from zero means the matrix is not near-singular.","correct":false,"tempting":"This is the common and costly mistake: a matrix with singular values 100 and 0.01 has determinant 1 and is badly conditioned."},{"text":"Both leave the length of every input vector unchanged.","correct":false,"tempting":"That would require an orthogonal matrix; determinant 1 says total volume is preserved, not individual lengths."}]},"prev":{"slug":"identity-inverse-and-solving","title":"Undoing a matrix, and why you rarely should","url":"https://addaly.com/learn/maths-you-need/identity-inverse-and-solving"},"next":{"slug":"least-squares-and-the-normal-equations","title":"The best fit, and what \"best\" was defined to mean","url":"https://addaly.com/learn/maths-you-need/least-squares-and-the-normal-equations"},"authorship":"Founder and series editor: Dr Mustafa Mun. Written by AI models to a written standard. Source and assessment review continues. Academic review invited.","review":{"status":"Draft, open for academic review"},"cite":"Addaly (2026) 'The determinant, and what it says about collapse', in The Maths You Actually Need. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/maths-you-need/determinants-and-volume (Accessed: 29 November 2026).","licence":{"name":"CC BY-NC-SA 4.0","url":"https://creativecommons.org/licenses/by-nc-sa/4.0/"},"reader":{"schema":1,"title":"The determinant, and what it says about collapse","courseTitle":"The Maths You Actually Need","module":{"index":2,"slug":"matrices-and-layers","title":"Matrices, and what a layer really does"},"answer":null,"keyIdea":"The determinant is the factor by which a transformation multiplies volume, so a determinant of zero means dimensions were flattened away and nothing downstream can restore them.","hero":{"kind":"plate","image":"https://addaly.com/art/modules/maths-you-need/matrices-and-layers.webp","alt":"Three blocks of cells joined by arrows: a narrow column, a large square grid and a single tall bar.","caption":"A column of values entering a grid of weights and leaving as a shorter column, in that order: the shape change is what a layer does, and the grid’s rank decides whether two small matrices could stand in for it."},"blocks":[{"t":"h2","id":"one-number-for-a-whole-transformation","runs":[{"text":"One number for a whole transformation"}]},{"t":"p","runs":[{"text":"The determinant of a square matrix is a single number, and it has a clean geometric meaning: "},{"text":"it is the factor by which the transformation multiplies area, or volume, or the higher-dimensional equivalent.","b":true}]},{"t":"p","runs":[{"text":"Take the unit square with corners at (0,0), (1,0), (0,1), (1,1): area 1. Apply"}]},{"t":"code","lang":"","label":"Text","text":"A = [ 3  0 ]\n    [ 0  2 ]"},{"t":"p","runs":[{"text":"It becomes a rectangle 3 wide and 2 tall, area 6. And "},{"text":"det(A) = 3*2 − 0*0 = 6","code":true},{"text":". The number is the area scaling, exactly."}]},{"t":"p","runs":[{"text":"Now a shear:"}]},{"t":"code","lang":"","label":"Text","text":"B = [ 1  1 ]     det = 1*1 - 1*0 = 1\n    [ 0  1 ]"},{"t":"p","runs":[{"text":"The square becomes a slanted parallelogram: different shape, same area. The determinant says 1, and it is right."}]},{"t":"h2","id":"zero-means-collapse","runs":[{"text":"Zero means collapse"}]},{"t":"p","runs":[{"text":"The case that matters is "},{"text":"det = 0","code":true},{"text":"."}]},{"t":"code","lang":"","label":"Text","text":"C = [ 1  2 ]     det = 1*4 - 2*2 = 0\n    [ 2  4 ]"},{"t":"p","runs":[{"text":"The unit square is squashed onto a line segment. A line has zero area, so the scaling factor is zero. That is the geometric version of the fact from the previous lesson: this matrix destroys a dimension, and destroyed dimensions cannot be recovered. Determinant zero, no inverse, information gone. They are three statements of one thing."}]},{"t":"p","runs":[{"text":"Negative determinants are also meaningful: they say the transformation flipped orientation, turning a left-handed arrangement into a right-handed one, like a mirror. "},{"text":"det = −2","code":true},{"text":" means area doubled and the space was reflected."}]},{"t":"h2","id":"computing-it-and-why-you-usually-should-not-by-hand","runs":[{"text":"Computing it, and why you usually should not by hand"}]},{"t":"p","runs":[{"text":"For a 2×2, "},{"text":"ad − bc","code":true},{"text":". For a 3×3 there is a longer formula. For anything larger, do not use the recursive cofactor expansion you may have been taught: it costs on the order of "},{"text":"n!","code":true},{"text":" operations, which for a 20×20 matrix is more arithmetic than the age of the universe permits. Real implementations use LU decomposition and cost about "},{"text":"n^3","code":true},{"text":", the same as a matrix multiplication."}]},{"t":"p","runs":[{"text":"And even then, the determinant itself is a poor thing to compute. Multiply a 100×100 matrix’s entries by 2 and its determinant multiplies by "},{"text":"2^100","code":true},{"text":", about "},{"text":"1.3 × 10^30","code":true},{"text":". Determinants overflow and underflow floating-point range almost immediately at realistic sizes, which is why any library that needs one offers "},{"text":"slogdet","code":true},{"text":": the sign and the "},{"text":"logarithm","i":true},{"text":" of the absolute determinant, computed as a sum of logs rather than a product."}]},{"t":"code","lang":"python","label":"Python","text":"import numpy as np\nsign, logdet = np.linalg.slogdet(A)   # stable; det(A) = sign * exp(logdet)"},{"t":"h2","id":"where-it-appears-in-machine-learning","runs":[{"text":"Where it appears in machine learning"}]},{"t":"p","runs":[{"text":"The determinant is not a daily tool, but it sits under three things you may meet."}]},{"t":"p","runs":[{"text":"Normalising flows.","b":true},{"text":" These are generative models built from invertible transformations. To know the probability density after a transformation you must correct for how much the transformation squeezed or stretched the space, and that correction is exactly the log absolute determinant of the Jacobian. The entire architectural game in that field (coupling layers, autoregressive flows) is about designing transformations powerful enough to be useful whose Jacobian determinant is cheap to compute, usually by making the Jacobian triangular so the determinant is just the product of the diagonal."}]},{"t":"p","runs":[{"text":"Multivariate Gaussians.","b":true},{"text":" The density of a multivariate normal contains a "},{"text":"det(Σ)^(-1/2)","code":true},{"text":" term. Fitting one requires the log determinant of the covariance, computed via Cholesky in every serious implementation."}]},{"t":"p","runs":[{"text":"Diagnosing collapse.","b":true},{"text":" If a covariance matrix has a determinant of effectively zero, your features are linearly dependent (one is a combination of the others) and any method that inverts that covariance will fail. Checking the log determinant, or better the singular values, tells you before the failure."}]},{"t":"h2","id":"what-it-does-not-tell-you","runs":[{"text":"What it does not tell you"}]},{"t":"p","runs":[{"text":"The determinant is one number summarising an entire transformation, so it hides almost everything. A matrix that stretches by 100 in one direction and squashes by 100 in another has determinant 1, exactly like the identity, while being wildly ill-conditioned and dangerous to work with. Two matrices with the same determinant can behave nothing alike."}]},{"t":"p","runs":[{"text":"This is the honest limit: the determinant answers “did total volume change” and nothing else. The question you usually want answered is “what happens in each direction”, and for that you need the singular values, which are the subject of a later lesson in this module. The determinant is their product. Knowing a product tells you very little about its factors, and here that gap is the whole story."}]},{"t":"h2","id":"the-rule-to-keep","runs":[{"text":"The rule to keep"}]},{"t":"p","runs":[{"text":"Determinant zero means a dimension was flattened. Determinant far from zero tells you almost nothing useful on its own, and if you find yourself needing its actual value, reach for "},{"text":"slogdet","code":true},{"text":" rather than "},{"text":"det","code":true},{"text":"."}]}],"check":{"question":[{"text":"Two 512x512 weight matrices both have determinant 1.0. What can you conclude about how they behave?"}],"options":[{"text":[{"text":"Both preserve volume overall, and nothing more: one could be the identity while the other stretches enormously in some directions and crushes others."}],"correct":true,"tempting":null},{"text":[{"text":"Both are orthogonal rotations, since determinant 1 characterises rotation matrices."}],"correct":false,"tempting":[{"text":"Rotations do have determinant 1, but so do many non-rotations; the condition is necessary, not sufficient."}]},{"text":[{"text":"Both are well-conditioned and safe to invert, since a determinant far from zero means the matrix is not near-singular."}],"correct":false,"tempting":[{"text":"This is the common and costly mistake: a matrix with singular values 100 and 0.01 has determinant 1 and is badly conditioned."}]},{"text":[{"text":"Both leave the length of every input vector unchanged."}],"correct":false,"tempting":[{"text":"That would require an orthogonal matrix; determinant 1 says total volume is preserved, not individual lengths."}]}],"order":[1,2,0,3],"why":null},"prev":{"slug":"identity-inverse-and-solving","title":"Undoing a matrix, and why you rarely should","minutes":9},"next":{"slug":"least-squares-and-the-normal-equations","title":"The best fit, and what “best” was defined to mean","minutes":9}}}