Ask Your Question
0

eigenvector corresponding to largest eigenvalue

asked 7 years ago

anonymous user

Anonymous

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

Preview: (hide)

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 .

dan_fulea gravatar imagedan_fulea ( 7 years ago )

1 Answer

Sort by » oldest newest most voted
0

answered 7 years ago

fidbc gravatar image

updated 7 years ago

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.

Preview: (hide)
link

Comments

Thanks for your answer.

rewi gravatar imagerewi ( 7 years ago )

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

fidbc gravatar imagefidbc ( 7 years ago )

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 7 years ago

Seen: 1,252 times

Last updated: Sep 21 '17