# program for eigenvalue calculation

I have a n x n matrix. I would like to

(a) take successively higher powers of the matrix and then multiply by projection vectors until the resulting vectors differ by only a scalar factor.

(b) calculate the dominant eigenvalue of the matrix to compare to (a)

and (c) calculate, using the same tactic as in (a), the dominant right and left eigenvectors.

This is too much work to do by hand, so my question is: can anyone recommend a program/language or package that would be ideal for the above calculations?

Thanks.

-

It seems to me that OP wants nothing more than a simple power method implementation, and the answers given thus far do quite a bit more than that... NAPACK has a power method implementation (in FORTRAN of course); translation to other computing environments shouldn't be too hard... – J. M. Apr 25 '12 at 12:07

## 3 Answers

You should check out a Computer Algebra System (CAS) and pick one that you like the interface for. There are commercial to open sourced - freeware ones and here is a comparison (many of the responses refer to these, but this is a nice list.

For example, Mathematica (\$) or Maxima or SAGE (both free).

See: http://en.wikipedia.org/wiki/Comparison_of_computer_algebra_systems

Enjoy - A

-

$$+\left(\text{multiplicative identity in}\; \mathbb R\right)$$ – amWhy 15 hours ago

There are various standardized answers for your question.

The most obvious solution would be to use a computer algebra system, e.g., Mathematica, Matlab or Maple (both commercial), as well as Axiom or Octave (free).

If you prefer to use a certain programming language, there are a number of linear algebra libraries that may help. For C and Fortran, the classic library to use is probably BLAS (basic linear algebra) in conjunction with something like LINPACK for more advanced operations.

-

High Level:

For a high level interface, you may use any commercial or free software including:

• MATLAB/Octave/SciLab and the many other clones
• Maple/Mathematica/R
• NumPy/SciPy

Low Level:

You might want to study LAPACK a little closely.

There are many many libraries which provide support for what you wish to achieve. Including Boost, GSL, Eigen etc.

-

Is it possible to compute steps a-c above in R, if I have a small sparse matrix (6 x 6)? I have tried using the basic functions svd() and qr() to get dominant eigenvalues and decomposition of the matrix, but the results are not ideal (i.e., wrong or not iterated enough to converge on a plausible answer). – eric Apr 25 '12 at 14:48
I haven't tried it myself but I don't see any reason why. Regd. (a), Computing $A^2$ is trivial in R. Calculating dominant eigenvalue is also trivial (using eigen(A)). I'm not as knowledgeable about (c). Also, it is not difficult to "extend" R to behave like MATLAB. Check out this and this. – Inquest Apr 25 '12 at 14:56
I hit the character cap, continuing, have you tried using eigen() function? Also, why not try using Octave or NumPy? I would have preferred Octave since it is high level and you wouldn't have to bother with implementation till I got the underlying math right. – Inquest Apr 25 '12 at 15:03
Using eigen(A) in R gives an odd result, not the one I'm expecting, anyhow, so I'll try my hand at Octave, see what comes out. Thanks again for your help. – eric Apr 25 '12 at 15:31
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9176220297813416, "perplexity_flag": "middle"}