inverse power method.docx - 2012201369 周璟æ…...

Info icon This preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
2012201369 周璟慧 给潘大助教的话: 在本次作业前期,我编了初期算法,自己输入阶数以及 k 的数,然后这样做 了一些数只后,发现比较傻,因为最后得出的是近似逼近值,所以不如将最 后两个 x k-1 x k 进行比较,如果两数相差不太多那么就认为得出了结果(在 此处我用 e 来表示 Δ 值,即当 e<1E-7 时,认为得出了结果为 x k )。 然后我输出的是特征值,用时和用了迭代的层数。 Ps :本人电脑年岁老旧,所以也许出解的时间比平均时间 慢。。但我仍坚持刷完了数据!!!!是不是值得表 扬!!!!( 虽然作业交得比较迟, 但是纯手工打造 !!! 很细致很 精致有木有 !!! 一、 幂法 1. 原理 假设矩阵 A 按绝对值最大的特征值为 λ 1 (称为朱特征值),相应的特征向量是 u 1 。对于给定的非零初始向量 X 0 X k =AX k-1 称为计算特征值的幂法。假设 A n 个线性无关的特征向量 u i ,则 x k = A x k 1 = A 2 x k 2 = = A k x 0 = i = 1 n λ i k α i u i = λ 1 k ( α 1 u 1 + i = 2 n ( λ i / λ 1 ) k α i u i ) . 假设对所有的 i>1 | λ i / λ 1 | < 1 x k 最终会趋于 u i ,而 x k 前后两次迭代 范数的比值,就趋于矩阵 A 的主特征值 λ 1 2. 算法实现 module kk implicit none integer n,nn real*8,allocatable::x1(:),x2(:),x0(:) real,allocatable::a(:,:) end module program mifa use kk implicit none real t1,t2 call cpu_time(t1) call initial call mi call cpu_time(t2) write(*,'(F6.2,"s")') t2-t1 end subroutine initial
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2012201369 周璟慧 use kk implicit none integer i,j read(*,*)n allocate(x1(n)) allocate(a(n,n)) allocate(x2(n)) x2=0 x2(1)=1 do i=1,n do j=1,n a(i,j)=1/real(i+j-1) enddo enddo end subroutine mi use kk implicit none integer i,j,k real,external::maxx real p,q,e q=100 e=222 k=0 do while(e>0.0000001) x1=x2 x2=0 p=q k=1+k do i=1,n do j=1,n x2(i)=x2(i)+a(i,j)*x1(j) enddo enddo q=maxx(x2)/maxx(x1) e=abs(p-q) enddo write(*,*) q write(*,*) k end function maxx(g) use kk implicit none real*8 g(n),xx,maxx integer i xx=g(1) do i=1,n if(xx<g(i))then xx=g(i) endif enddo maxx=xx
Image of page 2
2012201369 周璟慧 end 3. 结果 & 分析 首先我们看看 10E2 数量级别的。 10 100 500 10E2 以内还是可以很快算出来的。然后我们来看看 10E3 1000 2000 3000 用时有点久,不过还在承受范围内, 10000 阶会怎样呢? 不如试一试! 10000
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2012201369 周璟慧 恩, 略久。。。 不过我有心理准备。。差不多在我这台老旧的电脑上跑了 10+ 分钟,但是迭代的层 数是我没有预料到的,只有 30+ 层,我曾以为会有 100+ 层。而我前期没有设置 e 时,手工输入的迭代层数是 100+ 1000+ 级别,现在想一想真是白等了好久。 后来想了想,可能是由于 a 矩阵(希尔伯特矩阵)的每个值都比较小,所以收敛 的也会更快,所以 50 层内就可以搞定 10000 阶。 幂法分析至此,我们再来看看幂法归一是否比幂法更加厉害。 二、幂法归一法 1. 原理
Image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern