All problems
Eigenvector via Row Cross Product
Problem
Find an eigenvector of an integer 3x3 matrix A for the given eigenvalue lam.
Form M = A - lam*I and take the cross product of two rows of M, which lies in the null space when those rows span the row space. Try row pairs (0,1), (0,2), (1,2) in order, returning the first nonzero cross product w with M*w exactly zero, or None if no pair works.
Hint
The cross product of two rows of M = A - lam*I is orthogonal to the row space, hence in the null space.
Test cases
case 1
in: [[[2,1,0],[0,3,0],[0,0,4]],2]
expected: [2,0,0]
case 2
in: [[[2,1,0],[0,3,0],[0,0,4]],3]
expected: [1,1,0]
case 3
in: [[[2,1,0],[0,3,0],[0,0,4]],4]
expected: [0,0,2]
case 4
in: [[[2,1,0],[0,3,0],[0,0,4]],1]
expected: null
case 5
in: [[[3,1,0],[0,3,0],[0,0,1]],1]
expected: [0,0,4]
Starter codePython
def eigenvector_row_cross(A, lam):
# Your code here
pass5 test cases · run your code against them in the editor