Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-086

Idempotent Matrix Check

Problem

Return True if A*A equals A entrywise within a tolerance of 1e-9 (A is idempotent). Otherwise return False.

Projection matrices are the most common idempotent matrices.

Hint

Apply A twice and compare with A; the identity matrix is also idempotent.

Test cases

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

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