I try to solve the first exercise in assignment c1w2 (Gaussian Elimination), but can not figure out what I am doing wrong.
I need help from an instructor.
The grader give this error message:
Wrong output for test case check_matrix_1.
Expected:
[[ 1. 2. 3. 4. ]
[-0. 1. 1.3 1.7 ]
[-0. -0. 1. 2.33333333]].
Hi there, I am getting the same error as Espen and steven. Is there any chance someone could help me out? I have been going back through the videos to review the math and I am just not getting anywhere.
It’s pretty clear that there is a problem with your code if you get the same result as shown above. Look at the result: what could cause the -5. vaue at index (2,0) of that matrix. The value at that position should be 0., right? So how could that error happen? Time for some debugging. Add some print statements to understand what your code is doing.
I keep getting that same error too. Have tried print statements and debugging but am at a dead end. Would appreciate it if someone could share how they fixed it? Many thanks,
From looking at the code that was edited out (the mentors can look at the edit history), the way you are computing value_below_pivot is incorrect, which is probably the cause of the error. Think about what the column index should be there. Why is j - 1 relevant to that? Keep in mind what the point is of that loop: we are marching down the rows in the same column to zero all the values below the pivot in the same column, right? So how would we express that in terms of the column index? Note that in most cases there is more than one row to traverse there, unless you happen to be processing the second to last row of the matrix.
The below code mentions you to use pivot_row, but you have used M[j]
Perform row reduction using the formula:
row_to_reduce → row_to_reduce - value_below_pivot * pivot_row
Also as pointed by @paulinpaloalto
for value below point, you are suppose to use the below code recall to calculate the value below point which in your case seems to be missing.
Update the column index to agree with the new pivot position
You were also suppose to create a column index for pivot candidate which you didn’t create as the reason might be using an obsolete copy!!
So I suggest you to get a fresh copy and re-do the assignment as I suspect
PART 2 - NOT GRADED. This part deals with the case where the pivot isn’t in the main diagonal.
The above part is part of exercise 1 and I do not see in your codes as per the codes I could.
refer the below link 1a, on to get a fresh copy of your assignment
I know trying again and again with failure is not easy and encouraging but debugging skills actually improve when an error is tough to resolve as you are trying every way to resolve and getting better understandint at the codes.
When I used to get such frustration, I used to take a break, start fresh when I am ready to concentrate and focused on resolving the issue.
Hope you will keep trying!!! The excitement after too many trials and errors is too great to be left along, so all the best!!!
Thank you all for your help, it works now. That was so frustrating, I hope I do better with the next task! Thanks again, I would have given up without your advice.