C1W2_Assignment Exercise 2 ###

Hi,
I need help please!
In the comment line below, it says that indexing is similar as above, may I know above means ‘where’?
row_to_reduce = is expecting a vector [j,:] reference?

        # Get the row to be reduced. The indexing here is similar as above, with the row variable replaced by the j variable.
      
        row_to_reduce = None

Should the substitution row be substitution_row = row-1 ?

These are my results.
Wrong output for test case check_matrix_1.
Expected:
[-0.33333333 -1.33333333 2.33333333].
Got:
[2. 0.7 2.33333333].
Wrong output for test case check_matrix_2.
Expected:
[0.7857143 1.64285714 0. ].
Got:
[4. 0.64285714 0. ].
Wrong output for test case check_matrix_3.
Expected:
[19. -2. 1.].
Got:
[1. 5. 1.].
1 Tests passed
3 Tests failed

Would appreciate your help as long as I can have an improvement!

1 Like

I assume here you’re asking about the “back_substitution()” function?

Yes, you use that to specify a row of the ‘M’ matrix.

2 Likes

No. It is [row,:] from the ‘M’ matrix.

2 Likes

Could you explain the logic behind why it would be [row,:] rather than row-1? I also made the assumption it would be row-1. Does this have something to do with the eventuality of row-1 becoming 0-1?

1 Like

Yes.
Python uses zero-indexing. That means if you have a list of ‘n’ items, their index values are 0 to n-1.

You should already have for-loops that define ‘j’ or ‘row’ correctly. You don’t need any -1 in this case.

2 Likes

It works beautifully! Thank you TMosh!

2 Likes