You will build the inverse of a square matrix from cofactors. The functions submatrix and det are already written. A matrix is a list of rows. The checker tests many matrices.
The idea. The cofactor of the entry in row and column is times the determinant of the matrix with that row and column deleted. The adjoint is the transpose of the cofactor matrix. The inverse is the adjoint divided by the determinant, and it does not exist when the determinant is .
Your tasks.
cofactor_matrix(M). Return the matrix of all the cofactors.adjoint(M). Return the transpose of the cofactor matrix.inverse(M). Return the inverse as a list of rows, or None if the determinant is 0.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…