Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Solving Eigenvalues for a 3x3 matrix 4

Status
Not open for further replies.

IJR

Structural
Dec 23, 2000
774
Pals

anyone has or would like to type here a faster vb code for finding eigenvalues of a 3x3 matrix

respects
ijr
 
Replies continue below

Recommended for you

GregLocock

you mean to say there is a built in function. Why didnt you just say that?

thanks anyway
ijr
 
Didnt find any eigenvalue function in xls
 
No, there isn't one funcyion. There are three functions in excel that allow you to rapidly compute lambda, MINVERT, MDETERM and MMULT.

Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
I can't think of any simple way to combine those functions to solve Lambda in
Ax = Lambda*x
where A is nxn, x is nx1, Lambda is scalar.

But I might be wrong. If there is can you outline it Greg?

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
I have modified the spreadsheet in Greg's link to find the eigenvalues by solving a cubic polynomial, rather than using goalseek. That should be quicker.

Here's the code:

Code:
Public Function Eigen3x3(MatrixA As Variant) As Variant
Dim a As Double, b As Double, c As Double
Dim d As Double, e As Double, f As Double
Dim g As Double, h As Double, i As Double
Dim ac As Double, bc As Double, cc As Double, dc As Double

MatrixA = MatrixA.Value2

a = MatrixA(1, 1)
b = MatrixA(1, 2)
c = MatrixA(1, 3)
d = MatrixA(2, 1)
e = MatrixA(2, 2)
f = MatrixA(2, 3)
g = MatrixA(3, 1)
h = MatrixA(3, 2)
i = MatrixA(3, 3)

ac = -1
bc = a + e + i
cc = f * h + b * d + c * g - a * e - a * i - e * i
dc = b * f * g + c * d * h - a * f * h - b * d * i - c * e * g + a * e * i

Eigen3x3 = CubicC(ac, bc, cc, dc)

End Function

The function to solve the cubic is included in the attached file.

Doug Jenkins
Interactive Design Services
 
GregLocock and IDS

Thanks for the great posts. This solves my problem. I can move on from here.

Sorry for keeping you busy with the word "fast". How can you make me so responsible for that pals? Anyway, let me explain. No standard calculator around me or excel does it easily, so anything that can make me enter a matrix and gets me eigenvalues and eigenvectors is "fast". The algorithm above gets me eigenvalues, thats helpful.

There are numerical analysis that explain this, but I just figured out pals here have a better way around that would save me from learning the power method etc.

respects
ijr
 
Hey we were just ribbing you. If you really want fast for large matrices don't use Excel. Matlab and Octave both have a function (eig) that will rip out eigenvalues for big matrices, very quickly, say <4 seconds for a 500x500 matrix.



Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376
 
That is another great bit of info GregoLocock

I am now going into Matlab.

Anyway, your posts and IDS's simplified life for now.

respects

IJR

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor