Eigenvalues and eigenvectors of a 3x3 matrix (principal stresses)[programming]

In summary, In order to compute the 3 eigenvalues and 3 eigenvectors of a symmetric 3x3 matrix, namely a stress tensor, in C++, you can use the formula for the roots of a cubic equation and solve for the eigenvectors using the system of equations Tv=\lambda v. Another option is to use the Jacobi (Givens) rotation method, which is relatively easy to code and quick for 3x3 matrices. Additionally, it is possible to analytically solve the cubic equation for an exact and fast solution.
  • #1
xiss burg
5
0
I need to compute the 3 eigenvalues and 3 eigenvectors of a symmetric 3x3 matrix, namely a stress tensor, computationaly (in C++). More specific details http://en.wikipedia.org/wiki/Principal_stress#Principal_stresses_and_stress_invariants". Basically 2 questions:

1. I am running into trouble in finding the 3 real roots. http://en.wikipedia.org/wiki/Cubic_equation#General formula of roots" we have the general formula for the roots. According to Wikipedia, again, "The characteristic equation has three real roots λ, i.e. not imaginary due to the symmetry of the stress tensor.", then I'm sure these huge formulas can be simplified, and it is indeed a hard work to try simplifying it. Have you ever seen a simplified formula for cubic equations where the discriminant is always greater than zero (then, three real roots).

2. After finding the eigenvalues how to find the eigenvectors? I read about general purpose methods like the Power Method but these are for nxn matrices. For a 3x3 matrix there must be a much simpler technique.


Thanks in advance.
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
You can find the eigenvector belonging to eigenvalue [itex]\lambda[/itex] by solving the system of equations [itex]Tv=\lambda v[/itex]. You will get three equations which you can solve for v_1,v_2 and v_3.
 
  • #3
Cyosis said:
You can find the eigenvector belonging to eigenvalue [itex]\lambda[/itex] by solving the system of equations [itex]Tv=\lambda v[/itex]. You will get three equations which you can solve for v_1,v_2 and v_3.

I know how to do this with pencil and paper, or in my mind perhaps ^^. But how to do it in programming? I don't know methods to compute a solution space (not only a single solution as most usual methods do like Gauss Seidel, Conugate Gradients, etc)..
 
  • #4
Mathematica would just give you the answer, Eigenvalues[matrix], done. To calculate yourself, sure get your cubic polynomial and figure out a way to solve it, numerically perhaps?
 
  • #6
jrosen13 said:
Mathematica would just give you the answer, Eigenvalues[matrix], done. To calculate yourself, sure get your cubic polynomial and figure out a way to solve it, numerically perhaps?

Actually, I have to implement it myself in C++ code. Since there's a formula for the exact solution of a cubic equation I think its better to use it then. Numerical methods have problems finding all roots, don't they?

Lord Crc said:
There's probably an even easier way for 3x3 matrices, but Jacobi (Givens) rotation is fairly easy to code and should be quick. See http://scholar.lib.vt.edu/theses/available/etd-62597-173629/unrestricted/chapter5a.PDF and http://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm.

edit: Actually this page is more describing than the other Wikipedia link imho: http://en.wikipedia.org/wiki/Jacobi_rotation

Uh I think using these methods is a waste for 3x3 matrices. After looking more thoroughly into this problem I got a few conclusions which I am still unsure about. The eigen space of λ (vector space generated by all eigenvectors of λ) is the null space of the matrix (A-λI), or equivalently the solution space of the system (A-λI)x=0. We know that the row space of a matrix is orthogonal to its null space, then we can compute the eigenvector(s) of an eigenvalue by verifying the linear independence of the rows of (A-λI). I could compute the cross product of two pairs of row vectors, like r0Xr1 and r1Xr2 , then
-if these two cross products are zero, the rows of (A-λI) are linearly dependent, then the eigenspace is a plane orthogonal to any of the rows of (A-λI)
-if one of the cross products is different zero, then the cross product is the eigenvector itself
-it should not be possible for both to be different zero because then the eigenspace would be zero dimensional

What you think eh?

Thanks
 
Last edited by a moderator:
  • #7
xiss burg said:
Uh I think using these methods is a waste for 3x3 matrices.

Perhaps. All I know is that it would get you the eigenvalues and the eigenvectors in one go, and the code I got is shorter than the stable cubic equation solver I use (formatted C).
 
  • #8
Now I see that its better to use a numerical method, specially because I don't need a very accurate approximation for my specific application. Then I will give a try to that Jacobi method. Do you guys think this is one of the best choices for symmetrical 3x3 matrices?

Thanks.
 
  • #9
That was my feeling before, that numerically you can solve a cubic polynomial to whatever accuracy you desire, up to some fundamental limit of time cost perhaps, but that you should be able to get really close without too much trouble. However, it is possible to analytically solve it! e.g. http://en.wikipedia.org/wiki/Cubic_function

That should be really fast! And exact too!
 

What are eigenvalues and eigenvectors?

Eigenvalues and eigenvectors are concepts in linear algebra that describe certain properties of a square matrix. Eigenvalues are the values that, when multiplied by a corresponding eigenvector, result in the same vector. Eigenvectors are the special vectors that remain in the same direction when multiplied by the matrix.

What is a 3x3 matrix?

A 3x3 matrix is a matrix with three rows and three columns. It is a square matrix, meaning that it has the same number of rows and columns. In the context of principal stresses, a 3x3 matrix is used to represent the stress tensor at a point in a material.

Why are eigenvalues and eigenvectors important in programming?

Eigenvalues and eigenvectors are important in programming because they allow us to analyze and manipulate data in a more efficient and meaningful way. In the context of principal stresses, using eigenvalues and eigenvectors can help us identify the principal directions of stress and their corresponding magnitudes. This information is useful in understanding the behavior of materials under stress.

How can I calculate the eigenvalues and eigenvectors of a 3x3 matrix?

There are several methods for calculating the eigenvalues and eigenvectors of a 3x3 matrix, including the characteristic polynomial method, the power method, and the QR algorithm. Depending on the programming language you are using, there may be built-in functions or libraries that can help you calculate these values.

What is the significance of principal stresses in materials science?

In materials science, principal stresses are important because they provide information about the behavior of a material under external forces. By understanding the principal directions and magnitudes of stress, we can predict how a material will deform or fail, which is crucial in designing and engineering structures. Furthermore, principal stresses can also help us determine the most efficient way to apply forces to a material in order to achieve a desired result.

Similar threads

  • Linear and Abstract Algebra
Replies
12
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
810
  • Linear and Abstract Algebra
Replies
3
Views
1K
  • Linear and Abstract Algebra
Replies
16
Views
2K
  • Linear and Abstract Algebra
Replies
1
Views
3K
  • Linear and Abstract Algebra
Replies
4
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
18
Views
2K
  • Introductory Physics Homework Help
Replies
8
Views
855
  • Calculus and Beyond Homework Help
Replies
2
Views
524
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
Back
Top