🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: sci.math.num-analysis
8 messages
8 total messages Started by jonmach Wed, 07 Nov 2001 10:30
Very simple eigenvector/eigenvalue calculation
#1217
Author: jonmach
Date: Wed, 07 Nov 2001 10:30
14 lines
1697 bytes
Hi All,

I've trawled the net and have found some very comprehensive libraries
and source for calculating the eigenvalues/eigenvectors of an nxn
matrix.  However, this is very much overkill for what I need.

I have a single 2X2 matrix holding real values and simply need to
calculate the 2 eigenvalues and corresponding eigenvectors.  Is there
a very simple algorithm for this that already exists in
C/Fortran/Java/C++?

Many many thanks in advance for any assistance on this.

Jon
Re: Very simple eigenvector/eigenvalue calculation
#1218
Author: Uwe Schmitt
Date: Wed, 07 Nov 2001 10:44
26 lines
2318 bytes
In sci.math.num-analysis jonmach <jonmach@informix.com> wrote:
| Hi All,

| I've trawled the net and have found some very comprehensive libraries
| and source for calculating the eigenvalues/eigenvectors of an nxn
| matrix.  However, this is very much overkill for what I need.

| I have a single 2X2 matrix holding real values and simply need to
| calculate the 2 eigenvalues and corresponding eigenvectors.  Is there
| a very simple algorithm for this that already exists in
| C/Fortran/Java/C++?

| Many many thanks in advance for any assistance on this.


use the charateristic polynomial of your 2x2 matrix. this polynomial
has the degree two and can be solved analytically. you gain the
corresponding eigenvectors by appropriate linear equations.

hope that helps, yours, uwe.

-- 
Dr. Uwe Schmitt                                 Uwe.Schmitt@num.uni-sb.de
Universitaet des Saarlandes                     Angewandte Mathematik
Building 36.1 Room 4.17         PO-Box 151150   D-66041 Saarbruecken
Mobile:0177/6806587    Fax:+49(0)681/302-4435   Office:+49(0)681/302-2468
Re: Very simple eigenvector/eigenvalue calculation
#1219
Author: Alan Miller
Date: Wed, 07 Nov 2001 11:06
39 lines
2948 bytes
jonmach wrote in message ...
>Hi All,
>
>I've trawled the net and have found some very comprehensive libraries
>and source for calculating the eigenvalues/eigenvectors of an nxn
>matrix.  However, this is very much overkill for what I need.
>
>I have a single 2X2 matrix holding real values and simply need to
>calculate the 2 eigenvalues and corresponding eigenvectors.  Is there
>a very simple algorithm for this that already exists in
>C/Fortran/Java/C++?
>
>Many many thanks in advance for any assistance on this.
>
>Jon

The matrix:-
( a  b )
( c  d )
has eigenvalues obtained by solving (a-x)(d-x) - bc = 0 for x.
This is simply a quadratic equation, and the solutions are:
2x = -(a+d) +/- sqrt[ (a-d)^2 + 4bc ]
The roots can of course be complex, if b & c have opposite signs
and are moderately large compared with the diagonal elements a & d.
The eigenvectors can then be written as (b, x-a) or (x-d, c).

Complex operations and variables are intrinsic in Fortran, so that
may be the easiest language to use.

Now I have done your homework for you, you may like to look up
the numerical solution of quadratic equations to minimize cancellation
errors.   If (a-d)^2 is approximately equal to -4bc, the cancellation errors
could be very large, if you use the simple formula above.

--
Alan Miller (Honorary Research Fellow, CSIRO Mathematical
& Information Sciences)
http://www.ozemail.com.au/~milleraj
http://users.bigpond.net.au/amiller/
Re: Very simple eigenvector/eigenvalue calculation
#1220
Author: jonmach
Date: Wed, 07 Nov 2001 14:30
73 lines
3648 bytes
Alan,

Many many thanks for this.

I got to the point where I worked out that I could calculate the
polynomial, and can calculate the roots for this.  I just didn't know
how to get the eigenvectors from this.

e.g. [ 2 1 ]
     [ 3 4 ]

gives the polynomial x^2 - 6x + 5 = 0
giving roots (x - 1) (x - 5)

As you state,

> The eigenvectors can then be written as (b, x-a) or (x-d, c).

Your solution provides me with 4 potential eigenvectors.

(1, 1-2) = (1, -1) IS an eigenvector for the eigenvalue 1.
(1, 5-2) = (1, -3) IS NOT an eigenvector for the eigenvalue 5.
(1-4, 3) = (-3, 3) IS NOT an eigenvector for the eigenvalue 1.
(5-4, 3) = (1, 3) IS an eigenvector for the eigenvalue 5.

However, it is a simple matter to work out which 2 work, and discard
the others.

Problem solved.  Thanks again

Jon








"Alan Miller" <amiller@bigpond.net.au> wrote in message news:<iB8G7.310759$bY5.1235789@news-server.bigpond.net.au>...
> jonmach wrote in message ...
> >Hi All,
> >
> >I've trawled the net and have found some very comprehensive libraries
> >and source for calculating the eigenvalues/eigenvectors of an nxn
> >matrix.  However, this is very much overkill for what I need.
> >
> >I have a single 2X2 matrix holding real values and simply need to
> >calculate the 2 eigenvalues and corresponding eigenvectors.  Is there
> >a very simple algorithm for this that already exists in
> >C/Fortran/Java/C++?
> >
> >Many many thanks in advance for any assistance on this.
> >
> >Jon
> 
> The matrix:-
> ( a  b )
> ( c  d )
> has eigenvalues obtained by solving (a-x)(d-x) - bc = 0 for x.
> This is simply a quadratic equation, and the solutions are:
> 2x = -(a+d) +/- sqrt[ (a-d)^2 + 4bc ]
> The roots can of course be complex, if b & c have opposite signs
> and are moderately large compared with the diagonal elements a & d.
> The eigenvectors can then be written as (b, x-a) or (x-d, c).
> 
> Complex operations and variables are intrinsic in Fortran, so that
> may be the easiest language to use.
> 
> Now I have done your homework for you, you may like to look up
> the numerical solution of quadratic equations to minimize cancellation
> errors.   If (a-d)^2 is approximately equal to -4bc, the cancellation errors
> could be very large, if you use the simple formula above.
Re: Very simple eigenvector/eigenvalue calculation
#1221
Author: Guenter Rote
Date: Wed, 07 Nov 2001 16:28
54 lines
3325 bytes
jonmach wrote:
...
> e.g. [ 2 1 ]
>      [ 3 4 ]
> 
> gives the polynomial x^2 - 6x + 5 = 0
> giving roots (x - 1) (x - 5)
> 
> As you state,
> 
> > The eigenvectors can then be written as (b, x-a) or (x-d, c).
> 
> Your solution provides me with 4 potential eigenvectors.
> 
> (1, 1-2) = (1, -1) IS an eigenvector for the eigenvalue 1.
> (1, 5-2) = (1, -3) IS NOT an eigenvector for the eigenvalue 5.

you made an error in the calculation

> (1-4, 3) = (-3, 3) IS NOT an eigenvector for the eigenvalue 1.

it IS.

> (5-4, 3) = (1, 3) IS an eigenvector for the eigenvalue 5.
> 
> "Alan Miller" <amiller@bigpond.net.au> wrote in message news:<iB8G7.310759$bY5.1235789@news-server.bigpond.net.au>...
> > jonmach wrote in message ...
> > >Hi All,
> > >
> > >I've trawled the net and have found some very comprehensive libraries
> > >and source for calculating the eigenvalues/eigenvectors of an nxn
> > >matrix.  However, this is very much overkill for what I need.
> > >
> > >I have a single 2X2 matrix holding real values and simply need to
> > >calculate the 2 eigenvalues and corresponding eigenvectors.  Is there
> > >a very simple algorithm for this that already exists in
> > >C/Fortran/Java/C++?
> > >
> > >Many many thanks in advance for any assistance on this.
> > >
> > >Jon
> >
> > The matrix:-
> > ( a  b )
> > ( c  d )
> > has eigenvalues obtained by solving (a-x)(d-x) - bc = 0 for x.
> > This is simply a quadratic equation, and the solutions are:
> > 2x = -(a+d) +/- sqrt[ (a-d)^2 + 4bc ]
> > The roots can of course be complex, if b & c have opposite signs
> > and are moderately large compared with the diagonal elements a & d.
> > The eigenvectors can then be written as (b, x-a) or (x-d, c).
> ...
-- 
G"unter Rote, Freie Universit"at Berlin, Institut f"ur Informatik
Re: Very simple eigenvector/eigenvalue calculation
#1222
Author: Doug Magnoli
Date: Fri, 09 Nov 2001 06:07
89 lines
4986 bytes
The expressions Alan gave you for the eigenvectors aren't as you've interpreted them, instead they're different ways of
expressing the same thing and therefore they generate four eigenvectors, all of which are correct, but you'll notice
that two of them are duplicates.

For example, with the matrix you used below, the eigenvectors you get are:

(1,-1) for eigenvalue 1, which works
(-3,3) for eigenvalue 1, which works

(1,3) for eigenvalue 5, which works
(1,3) for eigenvalue 5, which works

Notice that the third and fourth eigenvectors are identical.  The first and second are identical because they're related
by a scalar constant, and remember that you can always multiply an eigenvector by any scalar and it will still be an
eigenvalue.

Hope that clears something up.

-Doug Magnoli


jonmach wrote:

> Alan,
>
> Many many thanks for this.
>
> I got to the point where I worked out that I could calculate the
> polynomial, and can calculate the roots for this.  I just didn't know
> how to get the eigenvectors from this.
>
> e.g. [ 2 1 ]
>      [ 3 4 ]
>
> gives the polynomial x^2 - 6x + 5 = 0
> giving roots (x - 1) (x - 5)
>
> As you state,
>
> > The eigenvectors can then be written as (b, x-a) or (x-d, c).
>
> Your solution provides me with 4 potential eigenvectors.
>
> (1, 1-2) = (1, -1) IS an eigenvector for the eigenvalue 1.
> (1, 5-2) = (1, -3) IS NOT an eigenvector for the eigenvalue 5.
> (1-4, 3) = (-3, 3) IS NOT an eigenvector for the eigenvalue 1.
> (5-4, 3) = (1, 3) IS an eigenvector for the eigenvalue 5.
>
> However, it is a simple matter to work out which 2 work, and discard
> the others.
>
> Problem solved.  Thanks again
>
> Jon
>
> "Alan Miller" <amiller@bigpond.net.au> wrote in message news:<iB8G7.310759$bY5.1235789@news-server.bigpond.net.au>...
> > jonmach wrote in message ...
> > >Hi All,
> > >
> > >I've trawled the net and have found some very comprehensive libraries
> > >and source for calculating the eigenvalues/eigenvectors of an nxn
> > >matrix.  However, this is very much overkill for what I need.
> > >
> > >I have a single 2X2 matrix holding real values and simply need to
> > >calculate the 2 eigenvalues and corresponding eigenvectors.  Is there
> > >a very simple algorithm for this that already exists in
> > >C/Fortran/Java/C++?
> > >
> > >Many many thanks in advance for any assistance on this.
> > >
> > >Jon
> >
> > The matrix:-
> > ( a  b )
> > ( c  d )
> > has eigenvalues obtained by solving (a-x)(d-x) - bc = 0 for x.
> > This is simply a quadratic equation, and the solutions are:
> > 2x = -(a+d) +/- sqrt[ (a-d)^2 + 4bc ]
> > The roots can of course be complex, if b & c have opposite signs
> > and are moderately large compared with the diagonal elements a & d.
> > The eigenvectors can then be written as (b, x-a) or (x-d, c).
> >
> > Complex operations and variables are intrinsic in Fortran, so that
> > may be the easiest language to use.
> >
> > Now I have done your homework for you, you may like to look up
> > the numerical solution of quadratic equations to minimize cancellation
> > errors.   If (a-d)^2 is approximately equal to -4bc, the cancellation errors
> > could be very large, if you use the simple formula above.
Re: Very simple eigenvector/eigenvalue calculation
#1223
Author: Virgil
Date: Fri, 09 Nov 2001 07:39
12 lines
1867 bytes
In article <3BEB72A2.964D5152@home.com>,
 Doug Magnoli <dmagnoli@home.com> wrote:

> remember that you can always multiply an eigenvector by any scalar and it 
> will still be an
> eigenvalue.


Shouldn't this be:

remember that you can always multiply an eigenvector by any *non-zero* 
scalar and it will still be an *eigenvector*.
Re: Very simple eigenvector/eigenvalue calculation
#1224
Author: Doug Magnoli
Date: Fri, 09 Nov 2001 19:46
20 lines
2267 bytes
Yes, of course, since, first of all, eigenvectors and eigenvalues are two very
different things.  Thanks.

-Doug



Virgil wrote:

> In article <3BEB72A2.964D5152@home.com>,
>  Doug Magnoli <dmagnoli@home.com> wrote:
>
> > remember that you can always multiply an eigenvector by any scalar and it
> > will still be an
> > eigenvalue.
>
> Shouldn't this be:
>
> remember that you can always multiply an eigenvector by any *non-zero*
> scalar and it will still be an *eigenvector*.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads