2071 Lab 8 summary $Id: summary.txt,v 1.15 2016/02/02 19:59:40 mike Exp $ M. M. Sussman EXERCISE 1 1. rayleigh.m 2. copy eigen_test.m, verify given e-vecs/e-vals A*[1;0;1] = [1; 0;1] A*[0;1;1] =[ 0;-1.5;-1.5]=-1.5*[0; 1;1] A*[1;-2;0]=[ 2;-4; 0]= 2*[1;-2;0] also can construct V,E and check norm(A*V-V*E,'fro')=0 3. x R(A,x) [ 3; 2; 1] 4.5 [ 1; 0; 1] 1 [ 0; 1; 1] -1.5 [ 1;-2; 0] 2 [ 1; 1; 1] 3 [ 0; 0; 1] -4 4. Up/down plot, starting at 4.5, approaching 2 EXERCISE 2 power_method.m Step Rayleigh q. x(1) 0 -4 0 1 0.20455 0.12309 2 2.19403 0.51832 3 0.84889 0.27964 4 2.60494 0.53477 10 2.15332 0.46719 15 1.96240 0.44244 20 2.00887 0.44835 25 1.99789 0.44694 plot(R) jumps up/down around 2, tiny wiggles by about 18 plot(X) up from 0 to .45, nearly converged at 18 EXERCISE 3 Matrix Rayleigh q. x(1) no. iterations 1 2.00000 0.44721 69 2 4.73205 0.21132 39 3 6.27492 0.55100 18 X starts .59, quick to .55, R starts 4.5, quick to 6.27 4 3.80194 0.23192 110 5 cycles see below 6 22.39230 0.28868 16 7 3.9962 -1.2191e-02 4653 X starts 0, Slow Z-shape to limit R starts 2.8 hits 4 before 1000 5 cycles: R -0.22222 0.40000 -3.41176 1.81538 2.34783 -0.15929 X 0.89443 0 0.43386 -0.55470 -0.21535 -0.33656 EXERCISE 4 1. inverse_power.m, include MAXITS, use backslash 2. smallest e-val=1.2679, x= [0.78868; -0.57735; 0.21132], 23 steps 3. norm(xHistory-xHp)=roundoff, norm(xp-x)=roundoff, r-1/rp=roundoff (0) EXERCISE 5 1,2. plot last 50 X: oscillates, R const 3. add sign code 4. yes, works, 40 its 5. Matrix eigenvalue x(1) no. iterations 1 1.00000 -0.70711 50 2 1.26795 0.78868 23 3 -1.27492 -0.33415 40 4 0.19806 -0.23192 16 5 failed 6 1.60770 0.28868 81 7 3.7933e-03 1.2191e-02 15 EXERCISE 6 1-5. power_several.m, incl comments about R,V,Vold matrices, fro norm 6. A=eigen_test(4), start from [0;0;0;0;0;1], compare with Ex. 3 roundoff diff, r = 3.8019, k = 110 7. 110 steps V = [ 0.23192 0.41791 R = [ 3.80194 0 0.41791 0.52112 0 3.24698] 0.52112 0.23192 0.52112 -0.23192 0.41791 -0.52112 0.23192 -0.41791 ] 8. norm(A*V-V*R,'fro')=2.9900e-08 9. 3.80194 3.24698 2.44504 1.55496 0.75302 0.19806, numSteps=106 EXERCISE 7 1. shifted_inverse.m A=eigen_test(2), r=1.2679, x= 0.78870 -0.57732 0.21130, k=23 same as with inverse_power 2. shift of 1.0, same, k=11 3. shift of 4.73, r=4.7321, x= 0.21132 0.57735 0.78868, k=4 4. shift of 2.5, r = 3.0000, x = 0.57736 0.57734 -0.57735, k = 22 5. 1.2679, 3.0000, 4.7321, agree with eig. EXERCISE 8 1. recover gs_factor.m 2. qr_method.m, returns vector of e-vals 3. eigen_test(2), r= 4.7321 3.0000 1.2679, k = 39, same values as before 4. Matrix largest & smallest Eigenvalues Number of steps 1 2 1. 69 2 4.7321 1.2679 39 3 6.27492 -2. (-1.2749) 37 4 3.8019 0.1981 95 6 22.3923 1.6077 62 7 3.9962 0.0037933 2083 5. error case 7, largest, 3.1835e-07, 15 times larger than tolerance smallest is roundoff (abs(max(ee)-max(e))/max(e)= 7.9663e-08) 6. #5: iterates cycle EXERCISE 9 1. qr_convergence.m 2. results agree: 2, -1.5, 1, k=74 3. eigen_test(8), e = -4.1496 3.3243 -2.1747, nsteps=50 4. norm(sort(e)-sort(ee))/norm(e)=3.0618e-9<1.0e-8 5. decrease tolerance to 1.e-9, err reduces to 3.3340e-10, 55 steps 6. eigen_test(7): takes 2374 its, rel err= 4.9688e-09 7. qr_method error: 2204 its, rel err=1.3081e-08, misses target (2083 its) 8. [0.01,1;-1,0.01] says eigenvalues =+0.01 in 2 steps. Explain why it fails: (A has 2 e-vals of equal magnitude) EXERCISE 10 (4 Extra) 1. myroots.m 2. test: pick 3 sets of 5 roots. Use poly to find coeffs, use myroots to find roots, compare