You will write three functions: one that removes a row and a column, one that finds a determinant by expanding along the first row, and one that finds the cofactor of an entry. A matrix is a list of rows. The checker tests many matrices.
The idea. The minor of the entry in row and column is the determinant that is left when row and column are deleted. A determinant is the sum, along the first row, of (entry times cofactor), and the cofactor is the minor times . A determinant is its only entry.
Your tasks.
submatrix(M, i, j). Return M without row i and column j.det(M). Expand along the first row, and call det again on the smaller matrices.cofactor(M, i, j). Return the sign times the determinant of submatrix(M, i, j).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…