Exercise 3: Why np.linalg.solve Sometimes Raises LinAlgError — Possible Solution ==================================================================== WHAT PROPERTY OF A CAUSES THE CRASH ------------------------------ np.linalg.solve raises a LinAlgError specifically when the coefficient matrix A is singular - per this chapter's own forward reference to Chapter 7, this means A has a determinant of exactly zero. A zero determinant is precisely the signal, established in this chapter, that the system A x = b does not have a single unique solution: it either has no solution at all (an inconsistent system, like this chapter's own [0, 0 | 3] example) or infinitely many (a dependent system, like this chapter's own [0, 0 | 0] example). Since a teammate's code is looping over "many different systems," it's very plausible that at least one of those systems happens to have a coefficient matrix that is singular - two of its equations might be scaled copies of each other, or otherwise not genuinely independent. WHY THIS IS BETTER THAN A SILENT WRONG ANSWER ------------------------------ If np.linalg.solve instead tried to force out some numbers even for a singular A - rather than raising an error - the result would be mathematically meaningless: there either isn't a real answer to report (the no-solution case) or there are infinitely many equally valid answers and picking just one arbitrarily would misrepresent the true situation (the infinite-solutions case). A crash is loud and immediately visible in a test run or in production logs, which forces the actual problem (a genuinely singular system somewhere in the input data) to be investigated and fixed. A silently wrong number, by contrast, would look like a completely ordinary, trustworthy result - and could propagate through the rest of the program producing incorrect downstream behavior with no error anywhere to point back to the actual cause. WHY THIS WORKS AS AN ANSWER ------------------------------ It identifies the exact mathematical property (a zero determinant / singular matrix) that this chapter's own forward reference connects directly to the no-solution and infinite-solution cases already covered, and argues for the crash being preferable using this chapter's own established fact that neither of those two cases has a single correct numeric answer to silently return.