I’m currently working on a linear algebra assignment involving Gaussian elimination in Python. My row_echelon_form implementation is working perfectly — all tests pass (see first screenshot). However, my back_substitution function is failing all four unit tests (see second screenshot), and I’m stuck figuring out why.
What’s working:
row_echelon_form: all tests pass and outputs are as expected.
I’ve followed the standard approach: iterating from bottom to top, identifying pivots, and reducing rows above. But clearly something’s wrong in my logic or indexing. I’d really appreciate if anyone could spot what might be going wrong — happy to clarify anything or share more context.
Of course back substitution is different logic than in row echelon form. Here we start with an input matrix that is already in row echelon form. I added print statements to my code so that I can see the test cases. Here’s what I see when I run the test cell for back substitution: