Numerical Eigenvalue Evaluation As an example consider a column subject to axial forces and displacements. Recall that stress, , is defined as force divided by area and strain, , is defined as the rate of change in the displacement with respect to length. Then u x where u is the displacemnt in the x-direction. Hooke’s law requires that the forces are proportional to the displacements, or E . Using the figure at the right equilibrium requires that 2u 2u dx A A dm 2 Adx 2 x t t or 2u 2 . x t Substituting for the stress from Hooke’s law 2u E 2 , x t and now substituting for the strain E 2u x 2 2u t 2 Let c E / making 2 c 2 2u x 2 2u t 2 . Assume u ( x, t ) y ( x) sin(t ) (i.e., the column is driven at frequency ) then 2u t 2 y ( x) sin(t ) , 2 and 2u x 2 y ( x) sin(t ) . Making c 2 y ( x) sin( t ) 2 y ( x) sin( t ) . But the sin(t ) 0 at all t, hence d2y dx 2 2 c2 y 0. This is a second order homogeneous equation with constant coefficients, and the roots of the characteristic equation are pure imaginary and given by i , hence the general solution is y( x ) C1 sin( x / c ) C2 cos( x / c ) where C1 and C 2 are arbitrary constants. Since the column is fixed between two walls the boundary conditions are at x=(0,L), u=0, or at y=0 at x=(0,L). Then C2 0 since y(0)=0, and y( x ) C1 sin( x / c ) From y=0 at x=L, then C1 sin( L / c ) 0 . If C1 0 , then y(x)=0 everywhere, hence sin(L / c) 0 and L / c n where n 0,1,2,... n 0 produces only the trivial solution y(x)=0 , and the sign is only a change to the arbitrary constant C1 , hence we only need to consider n 1,2,3,... Then nc n , L are eigenvalues and nx nct u n ( x , t ) C n sin sin L L Are the corresponding eigenfunctions. Numerical Approximation Consider y k y 0, and y( 0 ) 0 , y( L ) 0 . The derivatives can be approximated using a central difference, or 2 yi and yi yi 1 yi 1 yi 1 / 2 yi 1 / 2 2h h yi1 / 2 yi1 / 2 yi 1 2 yi yi 1 . h h2 Then yi 1 2 yi yi 1 h 2 k 2 yi 0 , or yi 1 2 yi yi 1 k 2 h 2 yi 0 . Pick four intervals y 0 to y1 through y3 to y 4 . Since y 0 0 and y 4 0 , then 2 k 2 h 2 1 0 1 2 k 2h2 1 y1 0 0 1 y2 0 . 2 k 2 h 2 y3 0 Let 2 1 0 A 1 2 1 0 1 2 and k 2h2 . Then Ay y 0 or Ay y . For the case of three intervals y 0 to y1 through y 2 to y3 the eigenvalue problem is 2 1 y1 1 2 y 0 since y0 0 and y3 0 then for non-trivial solutions 2 2 1 1 0, 2 or ( 2 )2 1 0 , and ( 2 ) 1 , making 2 1 and 2 1 =(1,3). Since k / c , h L / 3 , and 2 3c c L (kh) (1,3) . Then (1, 3) (3,3 3) . The actual answers for the L L 3c c first two frequencies are given by ( ,2 ) . L 2 2 We can find the eigenvectors that correspond to the eigenvalues can be found. For 1 1 1 y1 1 1 y 0 2 is y1 y 2 0 and y1 y 2 and since we can set y1 y 2 1 then y1 y 2 1 / For 3 2 2 2. 1 1 y1 1 1 y 0 2 is y1 y 2 0 and y1 y 2 and since we can set y1 y 2 1 then y1 y 2 1 / For ( 1,3 ) the corresponding eigenvectors stored column-wise becomes 2 1 / 2 Y 1 / 2 2 1/ 2 . 1/ 2 Note that eigenvalue problems are common and not only occur in vibrations, but also in buckling, electromagnetism, quantum mechanics, and so on. 2. Power Method Consider the eigenvalue problem Ax x Let z N i xi i 1 where the eigenvalues are ordered according to 1 2 3 ... N . Now consider the sequence z k Azk 1 A2 z k 2 ... Ak z0 . Since N N N i 1 i 1 i 1 i xi i Axi i i xi . z1 Az0 A Similarly z2 N i i2 xi , i 1 and zk N i ik xi N kN x N . i 1 Then z k 1 N kN1 x N N zk N kN x N for each component of z. Hence z k 1 N . k z k lim As an example use 2 A 1 1 2 1 and z 0 . 0 Then 2 1 1 2 1 Az0 2 2 z1 1 2 0 1 1 / 2 2 1 1 2.5 1 Az1 2.5 2.5 z 2 1 2 1 / 2 2 0.8 2 1 1 2.8 1 Az 2 2.8 2.8 z 3 1 2 0.8 2.6 0.9 2 1 1 2.9 1 Az3 2.9 2.9 z 4 1 2 0.9 2.8 1 2 1 1 3 1 Az5 3 3z5 1 2 1 3 1 Hence the largest eigenvalue is 3 and 1 X 1 is the associated eigenvector. Power Method with Shifts For Ax x But sIx sx Adding ( A sI ) x ( s ) x By the power method we should get the max s . Using the example just completed for the power method, take s 3 then 1 1 A sI 1 1 Again starting with 1 z0 0 Then 1 1 1 1 1 Az 0 1 z1 1 1 0 1 1 1 1 1 2 1 Az1 2 2 z 2 1 1 1 2 1 1 1 1 2 1 Az 2 2 2 z 2 1 1 1 2 1 Hence s 3 2 or 1 . and the corresponding eigenvector is 1 X . 1 Inverse Power Method If Ax x then x A1 x or A 1 x The power method will converge to max 1 1 x or min . Perform an LU decomposition of A. Then A LU and since A1 x N x N 1 or AX N 1 X N which must be solved for X N 1 . Use LU decomposition so that LUX N 1 X N Use of Similarity Transformations Recall that if Ax x then R11 Ax R11 x . Let x R1 x1 then R11 AR1 x1 x1 . Let A1 R11 AR1 then A1 x1 x1 has the same egenvalues. We can place zeros in any off-diagonal position of A that we want (e.g., the maximum absolute value off-diagonal term) so that A gradually becomes diagonal. Let x x0 , A A0 where A0 x0 x0 . Then proceed according to xk 1 Rk1 xk , Ak 1 Rk1 Ak Rk . At the Nth iterations x N RN11RN1 2 RN1 3 ...R11 x0 or x R1 R2 R3 ...RN x N relates the eigenvector x to the eigenvector x N . The method is very efficient if R 1 R T (i.e., if the matrix A is Hermitian or symmetric). Jacobi’s Method Consider the 5x5 matrix We only need to consider the 2x2 matrices that effect the iteration. For the case above cos sin sin a33 a35 cos cos a35 a55 sin sin . cos Hence we only need to update using cos R 1 AR sin sin a11 a12 cos cos a12 a22 sin sin cos Then a cos a12 sin AR 11 a12 cos a22 sin a11 sin a12 cos a12 sin a 22 cos and since R 1 R T then ... a11 cos sin a12 cos 2 a12 sin 2 a 22 sin cos R T AR ... ... Now set the 1-2 term to zero or a11 cos sin a12 cos 2 a12 sin 2 a 22 sin cos ( a 22 a11 ) sin cos a12 (cos 2 sin 2 ) ( a 22 a11 ) sin 2 a12 cos 0 2 and tan 2 2a12 . a11 a22 We successively apply the transformations until the transformed matrix is nearly diagonal. Then RnT ...R2T R1T AR1 R2 ...Rn diagonal Example: 2 1 Use A we need to cancel the (1,2) term. 1 2 Then cos R(1,2) sin sin . cos and tan 2 2a12 2 . a11 a22 0 Then 2 / 2 or / 4 . Making 1 / 2 R 1 / 2 1 1 1 1 1 3 1/ 2 T , AR 1 3 , R , 1/ 2 2 2 1 1 Hence R T AR 1 2 0 1 0 2 0 6 0 3 the eigenvectors are stored column-wise in R. The example works in one iteration for a 2x2. For larger than a 2x2 it will take many iterations before the algorithm is close to converging (i.e., the transformed matrix is close to diagonal). Note that this method gets all the eigenvalues and eigenvectors at once, where the power method finds the eigenvalues one at a time. Example Jacobi’s method on a 3x3 1 0 2 A 0 2 1 A1 2 1 1 Using (p,q)=(1,3) tan 2 / 4 (i.e., 45º) then 0.7071 0 0.7071 R(1,3) 0 1 0 0.7071 0 0.7071 then 0.7071 0 3 A2 R (1,3) A1 R(1,3) 0.7071 2 0.7071 0 0.7071 1 T Using (p,q)=(1,2) tan 2 1.4142 then 0.8881 0.4596 0 R(1,2) 0.4596 0.8881 0 0 0 1 then 0 0.3250 3.3659 A3 R (1,2) A1 R(1,2) 0 1.6339 0.6280 0.3250 0.6280 1 T Similarly 0 0 1 R(2,3) 0 0.9753 0.2263 0 0.2263 0.9753 then 3.3659 0.0735 0.3170 A4 0.0735 1.6339 0 0.3170 0 1.1447 and 0.9976 0 0.0698 R(1,3) 0 1 0. 0.0698 0 0.9976 then 0 3.3883 0.0733 A5 0.0733 1.7801 0.0051 0 0.0051 1.1670 … etc., etc., etc. PROGRAM JAC_TEST C C TEST JACOBI ITERATION ROUTINE C IMPLICIT NONE C C Set matirx dimensions C INTEGER NDIM ! Maximum matrix dimension PARAMETER(NDIM=12) C C Declare variables C REAL*8 A(NDIM,NDIM) ! Input matrix to be transformed REAL*8 B(NDIM,NDIM) ! Original input matrix REAL*8 R(NDIM,NDIM) ! Rotation matrix REAL*8 EPS ! Maximum error measure for convergence INTEGER N ! Size of matrix INTEGER MAX ! Maximum number of iterations INTEGER I,J ! COunters C C Set the input matrix and parameters C N=3 A(1,1)=1. A(1,2)=0. A(1,3)=2. A(2,1)=0. A(2,2)=2. A(2,3)=1. A(3,1)=2. A(3,2)=1. A(3,3)=1. EPS=1.E-6 MAX=100 C C Save the original input matrix in B C DO I=1,N DO J=1,N B(I,J)=A(I,J) END DO END DO C C Perform Jacobi iteration for eigenvalues and eigenvectors C CALL Jacobi(A,R,N,NDIM,Eps,Max) C C Write input marix C DO I=1,N DO J=1,N WRITE(23,'(A,I1,A,I1,A,1PE10.3)') $ 'B(',I,',',J,')=',B(I,J) END DO END DO C C C Write the rotation (row-wise eigenvectors) matrix DO I=1,N DO J=1,N WRITE(23,'(A,I1,A,I1,A,1PE10.3)') $ 'R(',I,',',J,')=',R(I,J) END DO END DO C C C Write eigenvalue matrix with residuals DO I=1,N DO J=1,N WRITE(23,'(A,I1,A,I1,A,1PE10.3)') $ 'A(',I,',',J,')=',A(I,J) END DO END DO STOP END SUBROUTINE Jacobi(A,R,N,NN,Eps,Max) C C C C C C C C Find eigenvectors & eigenvalues by Jacobi iteration w. max.search A is input matrix for eigenvalue analysis and must be symmetric A is NxN Eps is off diagonal norm tolerence, Max is the maximum no. of iteration R is the matrix of eigenvectors stored rowwise A is putput w. eigenvalues on disgonal and residuals off disgonal IMPLICIT NONE C C C Declare variables INTEGER N,NN,Max,Knt,I,J REAL*8 Eps,E,D,Apq,Eo,Do REAL*8 A(NN,NN),R(NN,NN) C C Begin Iteration counter C Knt=1 C C Find original norms C CALL Jnorm(A,N,NN,Eo,Do) C C Set the origianl rotation matrix to the identity matrix C DO I=1,N DO J=1,N R(I,J)=0. END DO R(I,I)=1. END DO C C A 1x1 is automatically the eigenvalue C IF (N.EQ.1) RETURN C C If A is diagonal it is the eigenvalue matrix C IF (E.LE.0.) RETURN C C Write the column headings for the convergence summary C WRITE(6,'(1X,A,6X,A)') 'Iteration','Error' C C Loop over Jacobi iterations C DO Knt=1,Max CALL Iter(A,R,N,NN,Apq) ! Perform an iteration CALL Jnorm(A,N,NN,E,D) ! Find the new norms C C Write the convergence summary C WRITE(6,'(I10,1PE15.3)') Knt,E IF (E/D.LT.Eps) THEN ! Convergence Has Occurred C RETURN END IF END DO C C C C C Exiting the loop means there were too many iteration. Write the message. WRITE(6,*) 'ERROR: Jacobi iteration did not converge for',Eps WRITE(6,*) ' in less than ',Max,'iterations' Too many iterations return RETURN END SUBROUTINE Iter(A,R,N,NN,Apq) C C C Perform a single Jacobi iteration IMPLICIT NONE C C C Declare variables INTEGER P,Q INTEGER N INTEGER NN INTEGER I,J REAL*8 R1(2,2) REAL*8 A(NN,NN) REAL*8 Apq REAL*8 Th REAL*8 R(NN,NN) C C C ! ! ! ! ! ! ! ! ! Indices of maximum off diagonal term Size of input matrix Dimension of input marix Counters 2x2 rotation matrix Input matrix Maximum offdiagonal element Rotation angle NXN Rotation matrix Find the maximum off-diagonal term CALL Search(A,N,NN,P,Q) Apq=A(P,Q) C C C Find the corresponding angle CALL Angle(A,P,Q,Th,N,NN) C C C Form the 2X2 matrix rotation matrix CALL Formr(A,R1,P,Q,Th,N,NN) C C C Update the to the new NXN rotation matrix CALL Newr(R,R1,N,NN,P,Q) C C C Form the rotated A CALL Newa(A,R1,N,NN,P,Q) C C C Normal return RETURN END SUBROUTINE Search(A,N,NN,P,Q) C C C Find the location of the maximum off-diagonal element IMPLICIT NONE C C C Declare variables INTEGER P,Q INTEGER N INTEGER NN INTEGER I,J REAL*8 A(NN,NN) REAL*8 Max C C C ! ! ! ! ! ! Location of maximum element Size of A Dimension of A Counters Current inpt matrix Current maximum off-diagonal term Initialize maximum to 0, and P & Q to first off diagonal element to check Max=0 P=1 Q=2 DO I=1,N-1 C C C Loop over all off-diagonal elements to find maximum DO J=I+1,N IF (DABS(A(I,J)).GT.Max) THEN ! Update maximum P=I Q=J Max=DABS(A(I,J)) END IF END DO END DO C C C Normal maximum RETURN END SUBROUTINE Angle(A,P,Q,Th,N,NN) C C C Find the rotation angle from the maximum off-diagonal term IMPLICIT NONE C C C Declare variables INTEGER P,Q ! INTEGER N ! INTEGER NN ! REAL*8 A(NN,NN) ! REAL*8 Th ! REAL*8 Td,Tn ! REAL*8 FNItan ! Tn=2.*A(P,Q) ! Td=A(P,P)-A(Q,Q) ! Th=.5*FNItan(Tn,Td)! C C C Normal return RETURN END Location of maximum off-diagonal term Size of input matrix Dimension of input matrix Input matrix Rotation matrix Numerator and denominator of tangent of angle 2D inverse tangent Find numerator Find denominator Find angle REAL*8 FUNCTION FNItan(Y,X) C C Find the inverse tangent given the numerator and denominator of the tangent C IMPLICIT NONE C C Declare variables C REAL*8 Y,X ! Numerator and denominator REAL*8 PI ! Pi (~22/7) REAL*8 At ! Absolute value of tangent C C Set pi C PI=3.14159265357989 C C There is no angle defined at the origin C IF (X.EQ.0..AND.Y.EQ.0.) THEN WRITE(6,*) WRITE(6,*) '**********************************************' WRITE(6,*) '***ERROR: Inverse tangent of 0/0 in FNitan***' WRITE(6,*) '**********************************************' WRITE(6,*) Fnitan=0. ELSE FNItan=0 ! Angle on +x axis IF (Y.EQ.0..AND.X.GT.0.) RETURN FNItan=PI ! Angle on -x axis IF (Y.EQ.0..AND.X.LT.0.) RETURN FNItan=PI/2. ! Angle on +y axis IF (X.EQ.0..AND.Y.GT.0.) RETURN FNItan=3.*PI/2. ! Angle on -y axis IF (X.EQ.0..AND.Y.LT.0.) RETURN C C Angle not on an axis C At=Y/X ! Absolute value of tangent FNItan=DABS(DATAN(At)) IF (X.GT.0..AND.Y.GT.0.) RETURN ! Angle in quadrant 1 IF (X.GT.0..AND.Y.LT.0.) THEN FNItan=-FNItan ! Angle in quadrant 2 ELSE IF (X.LT.0..AND.Y.GT.0.) THEN FNItan=PI-FNItan ! Angle in quadrant 3 ELSE IF (X.LT.0..AND.Y.LT.0.) THEN FNItan=-(PI-FNItan) ! Angle in quadrant 4 END IF END IF C C Normal return C RETURN END SUBROUTINE Formr(A,R1,P,Q,Th,N,NN) C C C Form the new rotation matrix IMPLICIT NONE C C C Declare variables INTEGER P,Q INTEGER N INTEGER NN REAL*8 A(NN,NN) REAL*8 R1(2,2) REAL*8 Th C C C Location of maximum off-diagonal term Size of input matrix Dimension of matrix Input matrix 2X2 rotation matrix Rotation matrix Form the rotation matrix from the sine and cosine R1(1,1)=COS(Th) R1(2,2)=R1(1,1) R1(1,2)=SIN(Th) R1(2,1)=-R1(1,2) C C C ! ! ! ! ! ! Normal return RETURN END SUBROUTINE Newr(R,R1,N,NN,P,Q) C C C C Form the new rotation matrix Only update appropriate elements IMPLICIT NONE C C C Declare variables INTEGER P,Q INTEGER N INTEGER NN INTEGER I REAL*8 R(NN,NN) REAL*8 R1(2,2) REAL*8 Rpi C C C ! Location of maximum off-diagonal element ! Size of input matrix ! Dimension of input matrix ! Counter ! Rotation matrix ! 2X2 rotation matrix ! Temporarily store a transformed element Rotate R to its new form DO I=1,N Rpi=R1(1,1)*R(P,I)+R1(1,2)*R(Q,I) R(Q,I)=R1(2,1)*R(P,I)+R1(2,2)*R(Q,I) R(P,I)=Rpi END DO C C C Normal return RETURN END SUBROUTINE Newa(A,R1,N,NN,P,Q) C C C C Form the new input matrix Only update appropriate elements IMPLICIT NONE C C C Declare variables INTEGER P,Q ! Location of maximum off-diagonal element INTEGER N ! Size of input matrix INTEGER NN ! Dimension of input matrix INTEGER I ! Counter REAL*8 A(NN,NN) ! Input matrix REAL*8 R1(2,2) ! 2X2 rotation matrix REAL*8 Aip,App,Apq,Aqq ! Temporary variables C C C Rotate elements not in 2X2 sub-matrix DO I=1,N IF (I.NE.P.AND.I.NE.Q) THEN Aip=A(I,P)*R1(1,1)+A(I,Q)*R1(1,2) A(I,Q)=A(I,P)*R1(2,1)+A(I,Q)*R1(2,2) A(I,P)=Aip A(Q,I)=A(I,Q) A(P,I)=A(I,P) END IF END DO C C C Rotate elements in 2X2 sub-matrix App=A(P,P)*R1(1,1)**2+2.*A(P,Q)*R1(1,1)*R1(1,2)+A(Q,Q)*R1(1,2)**2 Aqq=A(P,P)*R1(1,2)**2+2.*A(P,Q)*R1(2,2)*R1(2,1)+A(Q,Q)*R1(2,2)**2 Apq=(A(Q,Q)-A(P,P))*R1(1,1)*R1(1,2)+A(P,Q)*(R1(1,1)**2-R1(1,2)**2) A(P,P)=App A(Q,Q)=Aqq A(P,Q)=Apq A(Q,P)=Apq C C C Normal return RETURN END SUBROUTINE Jnorm(A,N,NN,E,D) C C C Find norm of error IMPLICIT NONE C C C Declare variables INTEGER I,J ! Counters INTEGER N ! Size of input matrix INTEGER NN ! Dimension of input matrix REAL*8 A(NN,NN) ! Input matrix REAL*8 E ! Off-diagonal norm REAL*8 D ! Diagonal norm D=0. E=0. DO I=1,N DO J=1,N IF (I.NE.J) E=E+A(I,J)**2 IF (I.EQ.J) D=D+A(I,J)**2 END DO END DO RETURN END Iteration 1 2 3 4 5 6 Error 2.000E+00 1.000E+00 2.113E-01 1.029E-02 5.014E-05 9.816E-08 B(1,1)= 1.000E+00 B(1,2)= 0.000E+00 B(1,3)= 2.000E+00 B(2,1)= 0.000E+00 B(2,2)= 2.000E+00 B(2,3)= 1.000E+00 B(3,1)= 2.000E+00 B(3,2)= 1.000E+00 B(3,3)= 1.000E+00 R(1,1)= 5.618E-01 R(1,2)= 4.828E-01 R(1,3)= 6.718E-01 R(2,1)=-4.973E-01 R(2,2)= 8.460E-01 R(2,3)=-1.922E-01 R(3,1)=-6.611E-01 R(3,2)=-2.261E-01 R(3,3)= 7.154E-01 A(1,1)= 3.391E+00 A(1,2)= 3.773E-07 A(1,3)=-2.215E-04 A(2,1)= 3.773E-07 A(2,2)= 1.773E+00 A(2,3)= 2.888E-19 A(3,1)=-2.215E-04 A(3,2)= 2.888E-19 A(3,3)=-1.164E+00 > A:=array([[1 , 0 , 2], [0 , 2 , 1], [2 , 1 , 1]]); > é1 ê A := ê 0 ê ê ë2 0 2 1 2ù ú 1ú ú ú 1û > lambda:=evalf(Eigenvals(A,vecs)); l := [-1.164247939 , 1.772865556 , 3.391382378 ] > print(vecs); é -0.6611151976 ê ê -0.2260911964 ê ê ë 0.7154086016 -0.4972794848 0.8460411882 -0.1921650935 0.5618183072ù ú 0.4828012850ú ú ú 0.6717612003û