Ask Your Question

# eigenvector corresponding to largest eigenvalue

I have tried this code to find the eigenvector corresponding to eigenvalue 3.732050807568878. But it is not giving the result.

A = matrix( AA, 6,6, [2,1,0,0,1,0, 1,2,1,0,0,0, 0,1,2,1,0,0, 0,0,1,1,0,0, 1,0,0,0,2,1, 0,0,0,0,1,1] )

E = matrix.identity( A.nrows() )

n=A.eigenvalues()

n.sort()

print n

k=( A -3.732050807568878*E ).kernel().basis()

print k

edit retag close merge delete

## Comments

The following works:

sage: A = matrix( AA, 6,6, [2,1,0,0,1,0, 1,2,1,0,0,0, 0,1,2,1,0,0, 0,0,1,1,0,0, 1,0,0,0,2,1, 0,0,0,0,1,1] )
sage: E = matrix.identity( AA, 6 )
sage: lambda1 = A.eigenvalues()[0]
sage: k = ( A - lambda1*E ).kernel().basis()
sage: k
[
(1.000000000000000?, 1.000000000000000?, 0.732050807568878?, 0.267949192431123?, 0.732050807568878?, 0.267949192431123?)


Just use the exact value of the eigenvalue as it lives in AA .

( 2017-09-21 10:48:44 -0600 )edit

## 1 answer

Sort by ยป oldest newest most voted

Why not just use the following?

sorted(A.eigenvectors_left(),reverse=True)[0][1]


Here A.eigenvectors_left() returns a list of triples (ev, EVS,n), where ev is an eigenvalue, EVS is the list of associated eigenvectors, and n is the algebraic multiplicity of ev. Output seems to be sorted, but just in case we wrap the output inside a call to sorted (in reverse order).

In your example this outputs:

[
(1.000000000000000?, 1.000000000000000?, 0.732050807568877?, 0.267949192431123?,
0.732050807568877?, 0.267949192431123?)
]


The proposed code does not work since

A -3.732050807568878*E


is invertible (determinant very close to zero). Note that 3.732050807568878 is just an approximation to the eigenvalue, not the actual value.

more

## Comments

Thanks for your answer.

( 2017-09-21 11:50:05 -0600 )edit

@A You can always upvote/accept if it helped ;-)

( 2017-09-21 13:46:10 -0600 )edit

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2017-09-21 09:51:55 -0600

Seen: 282 times

Last updated: Sep 21 '17