You will write the three row operations and use them to find an inverse by turning into . The program uses exact fractions. A matrix is a list of rows. The checker tests many matrices.
The idea. Swap, scale and add-a-multiple change the rows of the augmented matrix. For each column, find a row with a non-zero entry, move it to the pivot place, scale it to , and clear the rest of the column. If no row has a non-zero entry, the matrix is singular.
Your tasks.
add_multiple(M, i, j, k). Change row i to row i plus k times row j.scale(M, i, k). Multiply row i by k.invert(A). Use the operations to return the inverse, or None if A is singular. The swap and the setting up of [A | I] are written for you.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…