反幂法Matlab程序设计
(Fortran编程)数值分析之反幂法

integer::N,i,k=1
real*8::P(N,N),L(N,N),U(N,N)
real*8::uk(N),u0(N),v(N),zc(N),y(N)
do i=1,N
u0(i)=1d0
!以上交换两行元素,然后开始消元
do I=K+1,N
TEMP=AB(I,K)/AB(K,K)
AB(I,:)=AB(I,:)-TEMP*AB(K,:)
end do
end do
AUP(:,:)=AB(1:N,1:N)
call MAX_ROU(v,N,m1)
uk=v/m1
write(21,98) k,v,uk,m1
98 format(I5,T15,3F16.10,T70,3F16.10,F16.10/)
ne SOLVE
real*8::AUP(N,N),BUP(N)
!A,B为增广矩阵
real*8::AB(N,N+1)
real*8::VTEMP1(N+1),VTEMP2(N+1)
AB(1:N,1:N)=A
AB(:,N+1)=B
!列主元消去法的核心部分
do K=1,N-1
end do
X(I)=X(I)/A(I,I)
end do
end subroutine UP_TRI
end module M_GAUSS
module POWER
use M_GAUSS
contains
subroutine SOLVE(P,L,U,N)
BUP(:)=AB(:,N+1)
数值方法课程设计幂法反幂法计算矩阵特征值和特征向量-附Matlab程序

矩阵的特征值与特征向量的计算摘要物理,力学,工程技术中的很多问题在数学上都归结于求矩阵特征值的问题,例如振动问题(桥梁的振动,机械的振动,电磁振动等)、物理学中某些临界值的确定问题以及理论物理中的一些问题。
矩阵特征值的计算在矩阵计算中是一个很重要的部分,本文使用幂法和反幂法分别求矩阵的按模最大,按模最小特征向量及对应的特征值。
幂法是一种计算矩阵主特征值的一种迭代法,它最大的优点是方法简单,对于稀疏矩阵比较合适,但有时收敛速度很慢。
其基本思想是任取一个非零的初始向量。
由所求矩阵构造一向量序列。
再通过所构造的向量序列求出特征值和特征向量。
反幂法用来计算矩阵按模最小特征向量及其特征值,及计算对应于一个给定近似特征值的特征向量。
本文中主要使用反幂法计算一个矩阵的按模最小特征向量及其对应的特征值。
计算矩阵按模最小特征向量的基本思想是将其转化为求逆矩阵的按模最大特征向量。
然后通过这个按模最大的特征向量反推出原矩阵的按模最小特征向量。
关键词:矩阵;特征值;特征向量;冥法;反冥法THE CALCULATIONS OF EIGENVALUE AND EIGENVECTOR OF MATRIXABSTRACTPhysics, mechanics, engineering technology in a lot of problems in mathematics are attributed to matrix eigenvalue problem, such as vibration (vibration of the bridge, mechanical vibration, electromagnetic vibration, etc.) in physics, some critical values determine problems and theoretical physics in some of the problems. Matrix eigenvalue calculation is a very important part in matrix computation. In this paper, we use the power method and inverse power method to calculate the maximum of the matrix, according to the minimum characteristic vector and the corresponding characteristic value.Power method is an iterative method to calculate the eigenvalues of a matrix. It has the advantage that the method is simple and suitable for sparse matrices, but sometimes the convergence rate is very slow. The basic idea is to take a non - zero initial vector. Construct a vector sequence from the matrix of the matrix. Then the eigenvalues and eigenvectors are obtained by using the constructed vector sequence.The inverse power method is used to calculate the minimum feature vectors and their eigenvalues of the matrix, and to calculate the eigenvalues of the matrix. In this paper, we use the inverse power method to calculate the minimum eigenvalue of a matrix and its corresponding eigenvalues. The basic idea of calculating the minimum characteristic vector of a matrix is to transform it to the maximum characteristic vector of the modulus of the inverse matrix. Then, according to the model, the minimum feature vector of the original matrix is introduced.Key words: Matrix;Eigenvalue;Eigenvector;Iteration methods;目录1 引言 (1)2 相关定理。
幂法和反幂法的matlab实现

幂法和反幂法的matlab实现幂法求矩阵主特征值及对应特征向量摘要矩阵特征值的数值算法,在科学和工程技术中很多问题在数学上都归结为矩阵的特征值问题,所以说研究利用数学软件解决求特征值的问题是非常必要的。
实际问题中,有时需要的并不是所有的特征根,而是最大最小的实特征根。
称模最大的特征根为主特征值。
幂法是一种计算矩阵主特征值(矩阵按模最大的特征值)及对应特征向量的迭代方法,它最大的优点是方法简单,特别适用于大型稀疏矩阵,但有时收敛速度很慢。
用java来编写算法。
这个程序主要分成了四个大部分:第一部分为将矩阵转化为线性方程组;第二部分为求特征向量的极大值;第三部分为求幂法函数块;第四部分为页面设计及事件处理。
其基本流程为幂法函数块通过调用将矩阵转化为线性方程组的方法,再经过一系列的验证和迭代得到结果。
关键字:主特征值;特征向量;线性方程组;幂法函数块POWER METHOD FOR FINDING THE EIGENVALUES AND CORRESPONDING EIGENVECTORS OF THEMATRIXABSTRACTNumerical algorithm for the eigenvalue of matrix, in science and engineering technology, alot of problems in mathematics are attributed matrix characteristic value problem, so that studies using mathematical software to solve the eigenvalue problem is very necessary. In practical problems, sometimes need not all eigenvalues, but the maximum and minimum eigenvalue of real. The characteristic value of the largest eigenvalue of the modulus maximum.Power method is a calculation of main features of the matrix values (matrix according to the characteristics of the largest value) and the corresponding eigenvector of iterative method. It is the biggest advantage is simple method, especially for large sparse matrix, but sometimes the convergence speed is very slow.Using java to write algorithms. This program is divided into three parts: the first part is the matrix is transformed into linear equations; the second part for the sake of feature vector of the maximum; the third part isthe exponentiation function block. The fourth part is the page design and eventprocessing .The basic process is a power law function block by calling the matrix is transformed into linear equations method, after a series of validation and iteration results.Power method for finding the eigenvalues and corresponding eigenvectors of the matrixKey words: Main eigenvalue; characteristic vector; linear equations; power function block、目录1幂法......................................................... . (1)1.1幂法的基本理论和推导 (1)1.2幂法算法的迭代向量规范化 (2)2概要设计........................................................ (3)2.1设计背景 (3)2.2运行流程........................................... . (3)2.3运行环境........................................... (3)3程序详细设计 (4)3.1矩阵转化为线性方程组……..………………………………………. .43.2特征向量的极大值 (4)3.3求幂法函数块............….....…………...…......…………………………3.4界面设计与事件处理..........................................................................4运行过程及结果................................................ (6)4.1 运行过程....................................... ..................………………………………………. .64.2 运行结果................................................ .. (6)4.3 结果分析.......................................... (6)5结论 (7)参考文献 (8)附录 (56)1 幂法设实矩阵nn ijaA ⨯=)(有一个完备的特征向量组,其特征值为n λλλ ,,21,相应的特征向量为nx x x ,,21。
matlab用规范化乘幂法求以下矩阵的按模最大特征值及其特征向量

竭诚为您提供优质文档/双击可除matlab用规范化乘幂法求以下矩阵的按模最大特征值及其特征向量篇一:幂法,反幂法求解矩阵最大最小特征值及其对应的特征向量数值计算解矩阵的按模最大最小特征值及对应的特征向量一.幂法1.幂法简介:当矩阵a满足一定条件时,在工程中可用幂法计算其主特征值(按模最大)及其特征向量。
矩阵a需要满足的条件为:(1)|1||2|...|n|0,i为a的特征值xn(2)存在n个线性无关的特征向量,设为x1,x2,...,1.1计算过程:n对任意向量x,有x(0)(0)iui,i不全为0,则有i1x(k1)ax(k)...ak1x(0)aαiuiαiλik1uik1i1i1nnnk12k1λ1u1()a2u2()anun11k111u1k112|越小时,收敛越快;且当k充分大时,有可见,当|1 (k1)k111u1x(k1)x(k1)(k)x1(k),对应的特征向量即是。
kxx11u12算法实现(1).输入矩阵a,初始向量x,误差限,最大迭代次数n(2).k1,0;y(k)x(k)max(abs(x(k))(3).计算xay,max(x);(4).若||,输出,y,否则,转(5)(5).若kn,置kk1,,转3,否则输出失败信息,停机.3matlab程序代码function[t,y]=lpowera,x0,eps,n)%t为所求特征值,y 是对应特征向量k=1;z=0;%z相当于y=x0./max(abs(x0));%规范化初始向量x=a*y;%迭代格式b=max(x);%b相当于ifabs(z-b) t=max(x);return;endwhileabs(z-b)>epsz=b;y=x./max(abs(x));x=a*y;b=max(x);end[m,index]=max(a(matlab用规范化乘幂法求以下矩阵的按模最大特征值及其特征向量)bs(x));%这两步保证取出来的按模最大特征值t=x(index);%是原值,而非其绝对值。
幂法与反幂法

幂法与反幂法1 功能 幂法是一种计算矩阵主特征值(矩阵按模最大的特征值)及对应特征向量的迭代方法, 特别是用于大型稀疏矩阵。
反幂法用来计算矩阵按模最小的特征值及其特征向量,也可用来计算对应与一个给定近似特征值的特征向量。
2算法描述2.1 幂法(1)取初始向量u)0((例如取u )0(=(1,1,…1)T ),置精度要求ε,置k=1. (2)计算v )(k =Au )1(-k ,m k =max(v )(k ), u )(k = v )(k / m k(3)若| m k = m 1-k |<ε,则停止计算(m k 作为绝对值最大特征值1λ,u)(k 作为相应的特征向量)否则置k=k+1,转(2) 2.2 反幂法(1)取初始向量u )0((例如取u )0(=(1,1,…1)T),置精度要求ε,置k=1. (2)对A 作LU 分解,即A=LU(3)解线性方程组 Ly)(k =u )1(-k ,Uv )(k =y )(k (4)计算m k =max(v )(k ), u )(k = v )(k / m k(5)若|m k =m 1-k |<ε,则停止计算(1/m k 作为绝对值最小特征值n λ,u)(k 作为相应的特征向量);否则置k=k+1,转(3).3 Matlab 程序的实现3.1 幂法function [m,u]=pow(A,ep,N)%A 为矩阵;ep 为精度要求;N 为最大迭代次数;m 为绝对值最大的特征值;u 为对应最大特征值的特征向量。
N=100;ep=1e-6;n=length(A);u=ones(n,1);index=0;k=0;m1=0;while k<=Nv=A*u;[vmax,i]=max(abs(v));m=v(i);u=v/m;if abs(m-m1)<epindex=1;break;endm1=m;k=k+1;end输入:A=[7 3 -2;3 4 -1;-2 -1 3];[m,u]=pow(A,1e-6) Enter结果:m = 9.6056u =1.00000.6056-0.39444.2 反幂法function[m ,u]=pow_inv(A,ep,N)%A为矩阵;ep为精度要求;N为最大迭代次数;m为绝对值最大的特征值;u为对应最大特征值的特征向量。
matlab反解方程

matlab反解方程标题:使用MATLAB反解方程的实用方法引言:在科学研究和工程应用中,解决非线性方程组是一个常见的问题。
尽管有许多数值方法可以用于求解这些方程,但MATLAB作为一种强大的计算工具,提供了一种更加直观和便捷的方式来反解方程。
本文将介绍如何使用MATLAB来反解方程,并提供一些实用的方法和技巧。
一、MATLAB基础知识在使用MATLAB反解方程之前,我们需要了解一些基础知识。
MATLAB是一种高级编程语言和数值计算环境,它具有强大的数值计算和图形处理能力。
我们可以使用MATLAB来进行数值计算、矩阵运算、符号计算、绘图等操作。
二、使用MATLAB反解方程的步骤1. 定义方程:首先,我们需要将要反解的方程用MATLAB的语法进行定义。
例如,我们要反解方程 f(x) = 0,可以使用MATLAB的符号计算工具箱来定义这个方程。
2. 求解方程:接下来,我们可以使用MATLAB提供的数值计算工具箱来求解方程。
MATLAB提供了许多求解非线性方程的函数,例如fzero、fsolve等。
这些函数可以帮助我们找到方程的根。
3. 分析结果:在求解方程之后,我们可以使用MATLAB的绘图和数据分析工具来分析结果。
例如,我们可以绘制方程的图像,或者计算方程的根的性质。
三、MATLAB反解方程的实例为了更好地理解如何使用MATLAB反解方程,我们将通过一个实例来演示。
假设我们要反解方程x^2 + 2x + 1 = 0。
我们可以使用MATLAB的符号计算工具箱来定义这个方程:syms xeqn = x^2 + 2*x + 1;然后,我们可以使用MATLAB的数值计算工具箱来求解方程:x = solve(eqn, x);我们可以绘制方程的图像来分析结果:fplot(eqn, [-5, 5]);通过MATLAB的求解和绘图功能,我们可以得到方程的根为x = -1。
同时,我们还可以观察到方程的图像是一个开口向上的抛物线。
幂法,反幂法求解矩阵最大最小特征值及其对应的特征向量

数值计算解矩阵的按模最大最小特征值及对应的特征向量一.幂法1. 幂法简介:当矩阵A 满足一定条件时,在工程中可用幂法计算其主特征值(按模最大)及其特征向量。
矩阵A 需要满足的条件为:(1) 存在n 个线性无关的特征向量,设为n x x x ,...,,211.1计算过程:i n i i i u xx αα,1)0()0(∑==,有对任意向量不全为0,则有 可见,当||12λλ越小时,收敛越快;且当k 充分大时,有1)1111)11111λαλαλ=⇒⎪⎩⎪⎨⎧==+++(k )(k k (k k )(k x x u x u x ,对应的特征向量即是)(k x 1+。
2 算法实现3 matlab 程序代码function [t,y]=lpowerA,*0,eps,N) % t 为所求特征值,y 是对应特征向量k=1;z=0; % z 相当于λy=*0./ma*(abs(*0)); % 规化初始向量*=A*y; % 迭代格式b=ma*(*); % b 相当于 βif abs(z-b)<eps % 判断第一次迭代后是否满足要求t=ma*(*);return ;endwhile abs(z-b)>eps && k<Nk=k+1;z=b;y=*./ma*(abs(*));*=A*y;b=ma*(*);end[m,inde*]=ma*(abs(*)); % 这两步保证取出来的按模最大特征值t=*(inde*); % 是原值,而非其绝对值。
end4 举例验证选取一个矩阵A ,代入程序,得到结果,并与eig(A)的得到结果比拟,再计算A*y-t*y ,验证y 是否是对应的特征向量。
结果如下:结果正确,说明算法和代码正确,然后利用此程序计算15阶Hilb 矩阵,与eig(A)的得到结果比拟,再计算 A*y-t*y ,验证y 是否是对应的特征向量。
设置初始向量为*0=ones(15,1),结果显示如下可见,结果正确。
幂法和反幂法的matlab实现

幂法求矩阵主特征值及对应特征向量摘要矩阵特征值的数值算法,在科学和工程技术中很多问题在数学上都归结为矩阵的特征值问题,所以说研究利用数学软件解决求特征值的问题是非常必要的。
实际问题中,有时需要的并不是所有的特征根,而是最大最小的实特征根。
称模最大的特征根为主特征值。
幂法是一种计算矩阵主特征值(矩阵按模最大的特征值)及对应特征向量的迭代方法,它最大的优点是方法简单,特别适用于大型稀疏矩阵,但有时收敛速度很慢。
用java来编写算法。
这个程序主要分成了四个大部分:第一部分为将矩阵转化为线性方程组;第二部分为求特征向量的极大值;第三部分为求幂法函数块;第四部分为页面设计及事件处理。
其基本流程为幂法函数块通过调用将矩阵转化为线性方程组的方法,再经过一系列的验证和迭代得到结果。
关键字:主特征值;特征向量;线性方程组;幂法函数块POWER METHOD FOR FINDING THE EIGENVALUES AND CORRESPONDING EIGENVECTORS OF THEMATRIXABSTRACTNumerical algorithm for the eigenvalue of matrix, in science and engineering technology, a lot of problems in mathematics are attributed matrix characteristic value problem, so that studies using mathematical software to solve the eigenvalue problem is very necessary. In practical problems, sometimes need not all eigenvalues, but the maximum and minimum eigenvalue of real. The characteristic value of the largest eigenvalue of the modulus maximum.Power method is a calculation of main features of the matrix values (matrix according to the characteristics of the largest value) and the corresponding eigenvector of iterative method. It is the biggest advantage is simple method, especially for large sparse matrix, but sometimes the convergence speed is very slow.Using java to write algorithms. This program is divided into three parts: the first part is the matrix is transformed into linear equations; the second part for the sake of feature vector of the maximum; the third part is the exponentiation function block. The fourth part is the page design and event processing .The basic process is a power law function block by calling the matrix is transformed into linear equations method, after a series of validation and iteration results.Power method for finding the eigenvalues and corresponding eigenvectors of the matrixKey words: Main eigenvalue; characteristic vector; linear equations; power function block、目录1幂法 (1)1.1幂法的基本理论和推导 (1)1.2幂法算法的迭代向量规范化 (2)2概要设计 (3)2.1设计背景 (3)2.2运行流程 (3)2.3运行环境 (3)3程序详细设计 (4)3.1矩阵转化为线性方程组 (4)3.2特征向量的极大值 (4)3.3求幂法函数块............….....…………...…......…………………………3.4界面设计与事件处理............….....…………...…......…………………………4 运行过程及结果 (6)4.1 运行过程.........................................................………………………………………. .64.2 运行结果 (6)4.3 结果分析 (6)5结论 (7)参考文献 (8)附录 (56)1 幂法设实矩阵n n ij a A ⨯=)(有一个完备的特征向量组,其特征值为n λλλ ,,21,相应的特征向量为n x x x ,,21。