Skip to content
DeepForgeby svx
All problems
HardLinear Algebrala-316

Integer Eigenvectors of 3x3

Problem

Find an integer eigenvector of a 3x3 integer matrix A for each given eigenvalue, in order.

For each lam, form M = A - lam*I and take the cross product of two rows of M, accepting the first pair whose cross product w satisfies M*w = 0 exactly. Reduce w by the gcd of its entries and flip the sign so its first nonzero entry is positive. Return the list of eigenvectors, or None if some eigenvalue has no such direction.

Hint

A cross product of two rows of A - lam*I is orthogonal to the row space, so it lies in the null space when the rows span it.

Test cases

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

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