Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-115

Nilpotent Matrix Check

Problem

Return True if A is nilpotent, meaning some power of A is the zero matrix.

For an n x n matrix it is enough to check A^n, within a tolerance of 1e-9. Otherwise return False.

Hint

Nilpotency index is at most n; the zero matrix is trivially nilpotent.

Test cases

case 1
in: [[[0,1],[0,0]]]
expected: true
case 2
in: [[[0,1,0],[0,0,1],[0,0,0]]]
expected: true
case 3
in: [[[1,0],[0,0]]]
expected: false
case 4
in: [[[0,0],[0,0]]]
expected: true
Starter codePython
def is_nilpotent(A):
    # Your code here
    pass

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