资源描述:
《八、矩阵特征值的jacobi方法》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、1、用jacobi方法计算对称矩阵A的特征值和对应的特征向量。function[k,Bk,V,D,Wc]=jacobite(A,jd,max1)[n,n]=size(A);P0=eye(n);Vk=eye(n);Bk=A;k=1;state=1;while((k<=max1)&(state==1))aij=abs(Bk-diag(diag(Bk)));[m1i]=max(abs(aij));[m2j]=max(m1);i=i(j);Aij=(Bk-diag(diag(Bk)));mk=m2*sign(Aij(i,j));Wc=m2;Dk=diag(di
2、ag(Bk));Pk=P0;c=(Bk(j,j)-Bk(i,i))/(2*Bk(i,j));t=sign(c)/(abs(c)+sqrt(1+c^2));pii=1/(sqrt(1+t^2));pij=t/(sqrt(1+t^2));Pk(i,i)=pii;Pk(i,j)=pij;Pk(j,j)=pii;Pk(j,i)=-pij;B1=Pk'*Bk;B2=B1*Pk;Vk=Vk*Pk;Bk=B2;state=0;if(Wc>jd)state=1;endk,k=k+1;Pk,Vk,Bk=B2,Wc,endif(k>max1)disp('迭代次数k已经达到
3、最大迭代次数ma1,迭代次数k,对称矩阵Bk,以特征向量为列向量的矩阵V,特征值为对角元的对角矩阵D如下:')elsedisp('迭代次数k,对称矩阵Bk,以特征向量为列向量的矩阵V,特征值为对角元的对角矩阵D如下:')endk=k-1;Bk=B2;V=Vk;D=diag(diag(Bk));Wc;[V1,D1]=eig(A,'nobalance')>>A=[12-563-1;-56720;3251;-10112];>>[k,Bk,V,D,Wc]=jacobite(A,0.0001,100)k=1Pk=0.72270.691200-0.69120.72
4、2700001.000000001.0000Vk=0.72270.691200-0.69120.722700001.000000001.0000Bk=65.555800.7858-0.7227-0.0000-46.55583.5189-0.69120.78583.51895.00001.0000-0.7227-0.69121.000012.0000Wc=56k=2Pk=1.000000000.99770.067800-0.06780.997700001.0000Vk=0.72270.68960.04680-0.69120.72100.049000-0.
5、06780.997700001.0000Bk=65.5558-0.05330.7840-0.7227-0.0533-46.79480-0.75740.78400.00005.23910.9509-0.7227-0.75740.950912.0000Wc=3.5189k=3Pk=1.000000001.000000000.99060.136700-0.13670.9906Vk=0.72270.68960.04640.0064-0.69120.72100.04850.00670-0.06780.98830.136400-0.13670.9906Bk=65.
6、5558-0.05330.8754-0.6088-0.0533-46.79480.1035-0.75020.87540.10355.1079-0.0000-0.6088-0.7502-0.000012.1312Wc=0.9509k=4Pk=0.99990-0.0145001.0000000.014500.999900001.0000Vk=0.72330.68960.03590.0064-0.69040.72100.05850.00670.0143-0.06780.98820.1364-0.00200-0.13670.9906Bk=65.5685-0.0
7、518-0.0000-0.6087-0.0518-46.79480.1043-0.7502-0.00000.10435.09520.0088-0.6087-0.75020.008812.1312Wc=0.8754k=5Pk=1.000000000.99990-0.0127001.0000000.012700.9999Vk=0.72330.68960.0359-0.0024-0.69040.72110.0585-0.00250.0143-0.06600.98820.1372-0.00200.0126-0.13670.9905Bk=65.5685-0.05
8、95-0.0000-0.6080-0.0595-46.80440.10440.0000-0.0