Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-040

Eigenvector Check

Problem

Determine whether vector v is an eigenvector of square matrix A.

If A*v = lambda*v for some scalar lambda, return lambda as a float. If v is the zero vector or not an eigenvector, return None.

Hint

Pick a nonzero component of v to read off lambda, then verify every component.

Test cases

case 1
in: [[[2,0],[0,3]],[1,0]]
expected: 2
case 2
in: [[[2,0],[0,3]],[1,1]]
expected: null
case 3
in: [[[0,1],[1,0]],[1,1]]
expected: 1
case 4
in: [[[0,1],[1,0]],[1,-1]]
expected: -1
Starter codePython
def is_eigenvector(A, v):
    # Your code here
    pass

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