Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-288

Rank-Nullity Count

Problem

Apply the rank-nullity theorem to a matrix A with n columns.

Compute the rank by Gauss-Jordan elimination and return [rank, n - rank], where n - rank is the nullity (dimension of the null space).

Hint

Count pivot columns during elimination; every column is either a pivot or a free variable.

Test cases

case 1
in: [[[1,2],[3,6]]]
expected: [1,1]
case 2
in: [[[1,0],[0,1]]]
expected: [2,0]
case 3
in: [[[0,0],[0,0]]]
expected: [0,2]
case 4
in: [[[1,2],[2,4],[0,1]]]
expected: [2,0]
case 5
in: [[[1,0,1],[0,1,1]]]
expected: [2,1]
Starter codePython
def rank_nullity(A):
    # Your code here
    pass

5 test cases · run your code against them in the editor