0

I'm trying to create an application in java which does several matrix modifications like calculating the invereses and determinants. Now I would also like to include the option for the application to calculate the eigenvalues and the eigenvectors for matrices. Since the only 'solid' way to calculate eigenvalues, by my knowledge, is by using the characteristic formula given by:

det(A-λI) = 0

Where A is an nxn matrix and λ a real number. To my knowledge, there is no simple, maybe none at all, way to use algebra in Java. Also I would like to program this myself, so I would like not to use external packages like Jama or others.

Can someone explain me how I can program this equation in Java or maybe tell me another way of doing it?

borisjo
  • 158
  • 1
  • 16
  • 3
    Implement one of the many available [algorithms](http://en.wikipedia.org/wiki/Eigenvalue_algorithm). – assylias Oct 22 '14 at 13:29
  • You would have to implement matrix operations on your own. There is no built in support like there is in Matlab. – Simon Oct 22 '14 at 13:30
  • Implementing numerical analysis tools is notoriously difficult. If this is a class project or something where the accuracy of the results is not critical, it's OK to do this yourself. Otherwise, you are much better off using a library. http://math.nist.gov/javanumerics/ – mattm Oct 22 '14 at 13:45
  • It's not a class project, just trying to improve my programming skills. Also for my application I prefer to use my own written programs to calculate stuff. – borisjo Oct 22 '14 at 14:19
  • A useful reference for numerical algorithms is the "Numerical Recipes" books. There might be a Java version of the book but it doesn't matter, any version will do for your purpose. Just read about the algorithms and create your own implementation. By the way, I think that writing your own implementation is indeed a great way to learn. – Robert Dodier Oct 22 '14 at 21:03
  • Only 'solid' way? It's the only way. This is the definition of eigenvalues - there is no other. No way to use algebra? Do you mean symbolic manipulation? Of course there are libraries. – duffymo Oct 23 '14 at 12:31

2 Answers2

0

One way you could do it is have a look at Jama and see how it is calculated in there and interpret that. And don't just Copy and Paste :P we all know who tempting that can be.

0

Finding eigenvalues and eigenvectors is a bit tricky, and there are many algorithms with varying positives and negatives. I'll suggest a few that are quite good and that are not that difficult to implement.

First, compute the characteristic polynomial and then find the roots using. Then you have the eigenvalues. Then you can solve a set of equations to find the eigenvectors given the eigenvalues.

Martin Johansen
  • 131
  • 1
  • 4