Ask Your Question
0

eigenvector corresponding to largest eigenvalue

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

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

edit retag flag offensive 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 .

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

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-09-21 10:32:40 -0600

fidbc gravatar image

updated 2017-09-21 10:36:06 -0600

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.

edit flag offensive delete link more

Comments

Thanks for your answer.

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

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

fidbc gravatar imagefidbc ( 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

Question Tools

1 follower

Stats

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

Seen: 51 times

Last updated: Sep 21