A=[11 -1 -7 3;16 1 -16 8;12 -2 -8 5;12 -2 -12 9] A = 11 -1 -7 3 16 1 -16 8 12 -2 -8 5 12 -2 -12 9 aig(A) {Undefined function or variable 'aig'.} eig(A) ans = 1.0000 5.0000 3.0000 4.0000 AA=A; [Q,R]=qr(AA) Q = -0.4266 0.1075 -0.5934 -0.6741 -0.6205 -0.7572 0.1349 0.1532 -0.4653 0.4556 -0.3487 0.6741 -0.4653 0.4556 0.7128 -0.2604 R = -25.7876 1.6675 22.2200 -12.7581 0 -2.6869 2.2521 0.6425 0 0 -3.7683 3.9706 0 0 0 0.2298 AA=R*Q AA = 5.5624 0.2769 -1.3137 35.9379 0.3202 3.3532 -0.6896 0.9391 -0.0941 0.0922 4.1442 -3.5742 -0.1069 0.1047 0.1638 -0.0598 [Q,R]=qr(AA);AA=R*Q AA = 4.9228 1.3337 0.0013 -36.0835 0.2227 3.2713 -0.6283 1.2797 -0.0142 0.0252 4.0274 3.0589 0.0150 -0.0266 -0.0288 0.7785 [Q,R]=qr(AA);AA=R*Q AA = 4.8806 1.6040 0.2711 35.9951 0.1555 3.1707 -0.6445 -2.9522 -0.0028 0.0088 4.0078 -2.9550 -0.0029 0.0091 0.0080 0.9410 [Q,R]=qr(AA);AA=R*Q AA = 4.9137 1.6649 0.3378 -35.8808 0.1021 3.1011 -0.6605 4.1116 -0.0006 0.0031 4.0024 2.9296 0.0006 -0.0032 -0.0025 0.9827 [Q,R]=qr(AA);AA=R*Q AA = 4.9454 1.6663 0.3517 35.7864 0.0643 3.0591 -0.6703 -4.8608 -0.0001 0.0011 4.0008 -2.9228 -0.0001 0.0011 0.0008 0.9947 [Q,R]=qr(AA);AA=R*Q AA = 4.9667 1.6550 0.3520 -35.7196 0.0396 3.0347 -0.6759 5.3275 -0.0000 0.0004 4.0003 2.9208 0.0000 -0.0004 -0.0003 0.9983 [Q,R]=qr(AA);AA=R*Q AA = 4.9800 1.6441 0.3496 35.6757 0.0241 3.0205 -0.6791 -5.6129 -0.0000 0.0001 4.0001 -2.9203 -0.0000 0.0001 0.0001 0.9995 [Q,R]=qr(AA);AA=R*Q AA = 4.9880 1.6361 0.3472 -35.6480 0.0146 3.0122 -0.6809 5.7860 -0.0000 0.0000 4.0000 2.9201 0.0000 -0.0000 -0.0000 0.9998 [Q,R]=qr(AA);AA=R*Q AA = 4.9928 1.6308 0.3456 35.6309 0.0088 3.0073 -0.6820 -5.8905 -0.0000 0.0000 4.0000 -2.9200 -0.0000 0.0000 0.0000 0.9999 [Q,R]=qr(AA);AA=R*Q AA = 4.9957 1.6274 0.3445 -35.6204 0.0053 3.0043 -0.6826 5.9533 -0.0000 0.0000 4.0000 2.9200 0.0000 -0.0000 -0.0000 1.0000 for k=1:10,[Q,R]=qr(AA);AA=R*Q; end AA AA = 5.0000 1.6222 0.3427 -35.6046 0.0000 3.0000 -0.6835 6.0474 -0.0000 0.0000 4.0000 2.9200 0.0000 -0.0000 -0.0000 1.0000 format long AA AA = 4.999973884405315 1.622246406261175 0.342729256470315 -35.604584950043872 0.000032196408125 3.000026115866608 -0.683501225164721 6.047396012551348 -0.000000000000004 0.000000000078482 4.000000000053639 2.919985580510833 0.000000000000004 -0.000000000080943 -0.000000000055327 0.999999999674431 for k=1:10,[Q,R]=qr(AA);AA=R*Q; end AA AA = 4.999999842090051 1.622214405990196 0.342718320603335 -35.604488180591453 0.000000194684422 3.000000157913622 -0.683506709245732 6.047965723468737 0.000000000000000 -0.000000000005371 3.999999999996323 2.919985580386222 0.000000000000000 -0.000000000000001 -0.000000000000001 1.000000000000000 A=[ 0 0 1 0;-4 2 4 -2;-2 0 3 0;-2 0 2 1] A = 0 0 1 0 -4 2 4 -2 -2 0 3 0 -2 0 2 1 AA=A; eig(A) ans = 2 1 2 1 [Q,R]=qr(AA);AA=R*Q AA = 3.000000000000001 1.414213562373093 1.333333333333329 -6.599663291074446 -0.000000000000000 2.000000000000000 0.471404520791032 0.666666666666666 -0.333333333333333 -0.471404520791031 0.666666666666667 0.942809041582063 0.235702260395516 0.333333333333333 0.235702260395516 0.333333333333333 [Q,R]=qr(AA);AA=R*Q AA = 2.345454545454547 0.475516248386254 1.002476272879280 7.072002767285650 0.016684780645132 2.022966507177033 0.714160313683960 -0.422095272791278 -0.065952386373637 -0.090783090722537 0.904306220095694 -0.312839637096221 -0.057495957457607 -0.079142863648365 -0.083423903225659 0.727272727272727 [Q,R]=qr(AA);AA=R*Q AA = 2.148514851485151 0.201004616534245 0.790638501399932 -7.156124720272928 0.007657318725114 2.010363653187748 0.765344798275272 0.401561133605759 -0.022886903987893 -0.030975847288933 0.963928512870962 0.130594227467573 0.021522179609843 0.029128786893682 0.033920578563006 0.877192982456139 for k=1:10,[Q,R]=qr(AA);AA=R*Q; end AA AA = 2.000126968671726 0.000169293858642 0.600173840308053 -7.199970041804360 0.000006511363308 2.000008681935507 0.799971350006035 0.399996531344357 -0.000016280758034 -0.000021707971832 0.999972866640052 0.000108523135440 0.000016279874686 0.000021706794019 0.000027131887769 0.999891482752718 for k=1:10,[Q,R]=qr(AA);AA=R*Q; end AA AA = 2.000000123977681 0.000000165303569 0.600000169753912 -7.199999970754004 0.000000006357830 2.000000008477103 0.799999972025559 0.399999996609134 -0.000000015894576 -0.000000021192769 0.999999973509040 0.000000105963831 0.000000015894576 0.000000021192768 0.000000026490959 0.999999894036176 for k=1:50,[Q,R]=qr(AA);AA=R*Q; end AA AA = 2.000000000000004 -0.000000000000001 0.599999999999581 -7.200000000000061 -0.000000000000000 1.999999999999998 0.800000000000027 0.399999999999910 -0.000000000000000 -0.000000000000000 0.999999999999999 0.000000000000003 0.000000000000000 0.000000000000000 0.000000000000001 0.999999999999999 for k=1:100,[Q,R]=qr(AA);AA=R*Q; end AA AA = 2.000000000000004 -0.000000000000001 0.599999999999004 -7.200000000000150 -0.000000000000000 1.999999999999998 0.800000000000060 0.399999999999782 -0.000000000000000 -0.000000000000000 0.999999999999999 0.000000000000003 0.000000000000000 0.000000000000000 0.000000000000001 0.999999999999999 [Q,R]=qr(AA);AA=R*Q AA = 2.000000000000004 -0.000000000000001 0.599999999998998 7.200000000000151 -0.000000000000000 1.999999999999998 0.800000000000060 -0.399999999999781 -0.000000000000000 -0.000000000000000 0.999999999999999 -0.000000000000003 -0.000000000000000 -0.000000000000000 -0.000000000000001 0.999999999999999 v=rand(4,1) v = 0.814723686393179 0.905791937075619 0.126986816293506 0.913375856139019 T=eye(4)-2/(v'*v)*v*v' T = 0.431362571508266 -0.632198629362863 -0.088630609218159 -0.637491835275646 -0.632198629362863 0.297135420669742 -0.098537568685790 -0.708749449645378 -0.088630609218159 -0.098537568685790 0.986185600003120 -0.099362593633606 -0.637491835275646 -0.708749449645378 -0.099362593633606 0.285316407818872 T-T' ans = 1.0e-16 * 0 0 0 0 0 0 0 0 0 0 0 0.138777878078145 0 0 -0.138777878078145 0 T*T' ans = 1.000000000000000 0 0 0 0 1.000000000000000 0 -0.000000000000000 0 0 1.000000000000000 0 0 -0.000000000000000 0 1.000000000000000 D=[2 2 -2 -2]; A=T*diag(D)*T A = 0.342995100266025 -1.842221728594137 0.096253553428866 0.692321252989858 -1.842221728594137 -0.048141739260533 0.107012590976358 0.769707594485808 0.096253553428866 0.107012590976358 -1.929739850668445 0.505358949230120 0.692321252989858 0.769707594485808 0.505358949230120 1.634886489662953 eig(A) ans = 2.000000000000000 -2.000000000000000 -2.000000000000000 2.000000000000000 AA=A; [Q,R]=qr(AA);AA=R*Q AA = 0.342995100266025 1.842221728594137 -0.096253553428866 -0.692321252989858 1.842221728594137 -0.048141739260534 0.107012590976358 0.769707594485808 -0.096253553428866 0.107012590976358 -1.929739850668444 0.505358949230121 -0.692321252989858 0.769707594485808 0.505358949230120 1.634886489662953 [Q,R]=qr(AA);AA=R*Q AA = 0.342995100266025 -1.842221728594137 0.096253553428866 0.692321252989857 -1.842221728594137 -0.048141739260534 0.107012590976358 0.769707594485808 0.096253553428866 0.107012590976358 -1.929739850668445 0.505358949230120 0.692321252989858 0.769707594485807 0.505358949230120 1.634886489662953 [Q,R]=qr(AA);AA=R*Q AA = 0.342995100266026 1.842221728594137 -0.096253553428866 -0.692321252989857 1.842221728594137 -0.048141739260534 0.107012590976358 0.769707594485808 -0.096253553428866 0.107012590976358 -1.929739850668444 0.505358949230121 -0.692321252989858 0.769707594485807 0.505358949230120 1.634886489662953 [Q,R]=qr(AA);AA=R*Q AA = 0.342995100266026 -1.842221728594136 0.096253553428865 0.692321252989857 -1.842221728594138 -0.048141739260534 0.107012590976358 0.769707594485807 0.096253553428866 0.107012590976358 -1.929739850668445 0.505358949230120 0.692321252989858 0.769707594485807 0.505358949230121 1.634886489662954 A A = 0.342995100266025 -1.842221728594137 0.096253553428866 0.692321252989858 -1.842221728594137 -0.048141739260533 0.107012590976358 0.769707594485808 0.096253553428866 0.107012590976358 -1.929739850668445 0.505358949230120 0.692321252989858 0.769707594485808 0.505358949230120 1.634886489662953 A-AA ans = 1.0e-14 * -0.061062266354384 -0.044408920985006 0.018041124150159 0.144328993201270 0.111022302462516 0.096450625264310 0.001387778780781 0.022204460492503 -0.001387778780781 -0.005551115123126 0 0.011102230246252 0.022204460492503 0.055511151231258 -0.033306690738755 -0.088817841970013 AA=A; [Q,R]=qr(AA);AA=R*Q AA = 0.342995100266025 1.842221728594137 -0.096253553428866 -0.692321252989858 1.842221728594137 -0.048141739260534 0.107012590976358 0.769707594485808 -0.096253553428866 0.107012590976358 -1.929739850668444 0.505358949230121 -0.692321252989858 0.769707594485808 0.505358949230120 1.634886489662953 A-AA ans = -0.000000000000000 -3.684443457188274 0.192507106857731 1.384642505979716 -3.684443457188274 0.000000000000000 -0.000000000000000 0 0.192507106857731 -0.000000000000000 -0.000000000000000 -0.000000000000000 1.384642505979716 0 0 0 [Q,R]=qr(AA);AA1=R*Q AA1 = 0.342995100266025 -1.842221728594137 0.096253553428866 0.692321252989857 -1.842221728594137 -0.048141739260534 0.107012590976358 0.769707594485808 0.096253553428866 0.107012590976358 -1.929739850668445 0.505358949230120 0.692321252989858 0.769707594485807 0.505358949230120 1.634886489662953 AA1-AA ans = 0.000000000000000 -3.684443457188274 0.192507106857731 1.384642505979715 -3.684443457188274 -0.000000000000000 -0.000000000000000 0 0.192507106857731 -0.000000000000000 -0.000000000000000 -0.000000000000000 1.384642505979716 -0.000000000000000 0 0.000000000000000 AA1-A ans = 1.0e-15 * 0.499600361081320 0 -0.083266726846887 -0.555111512312578 -0.444089209850063 -0.638378239159465 0 0 0.013877787807814 0.027755575615629 0 -0.111022302462516 -0.111022302462516 -0.333066907387547 0 0.222044604925031 A0=A; [Q,R]=qr(A0);A1=R*Q A1 = 0.342995100266025 1.842221728594137 -0.096253553428866 -0.692321252989858 1.842221728594137 -0.048141739260534 0.107012590976358 0.769707594485808 -0.096253553428866 0.107012590976358 -1.929739850668444 0.505358949230121 -0.692321252989858 0.769707594485808 0.505358949230120 1.634886489662953 [Q,R]=qr(A1);A2=R*Q A2 = 0.342995100266025 -1.842221728594137 0.096253553428866 0.692321252989857 -1.842221728594137 -0.048141739260534 0.107012590976358 0.769707594485808 0.096253553428866 0.107012590976358 -1.929739850668445 0.505358949230120 0.692321252989858 0.769707594485807 0.505358949230120 1.634886489662953 A2-A ans = 1.0e-15 * 0.499600361081320 0 -0.083266726846887 -0.555111512312578 -0.444089209850063 -0.638378239159465 0 0 0.013877787807814 0.027755575615629 0 -0.111022302462516 -0.111022302462516 -0.333066907387547 0 0.222044604925031 [Q,R]=qr(A2);A3=R*Q A3 = 0.342995100266026 1.842221728594137 -0.096253553428866 -0.692321252989857 1.842221728594137 -0.048141739260534 0.107012590976358 0.769707594485808 -0.096253553428866 0.107012590976358 -1.929739850668444 0.505358949230121 -0.692321252989858 0.769707594485807 0.505358949230120 1.634886489662953 [Q,R]=qr(A3);A4=R*Q A4 = 0.342995100266026 -1.842221728594136 0.096253553428865 0.692321252989857 -1.842221728594138 -0.048141739260534 0.107012590976358 0.769707594485807 0.096253553428866 0.107012590976358 -1.929739850668445 0.505358949230120 0.692321252989858 0.769707594485807 0.505358949230121 1.634886489662954 A1-A3 ans = 1.0e-15 * -0.333066907387547 -0.222044604925031 0 -0.333066907387547 0 0.291433543964104 0.041633363423443 -0.111022302462516 0.027755575615629 -0.055511151231258 0 -0.111022302462516 -0.222044604925031 0.222044604925031 0 -0.222044604925031 A2-A4 ans = 1.0e-15 * -0.111022302462516 -0.444089209850063 0.097144514654701 0.888178419700125 0.666133814775094 0.326128013483640 0.013877787807814 0.222044604925031 0 -0.027755575615629 0 0 0.111022302462516 0.222044604925031 -0.333066907387547 -0.666133814775094 B=[2 1 0 0; 0 2 0 0; 0 0 -2 1; 0 0 0 -2] B = 2 1 0 0 0 2 0 0 0 0 -2 1 0 0 0 -2 v=[1 -1 1 -1]'; T=eye(4)-2/(v'*v)*v*v' T = 0.500000000000000 0.500000000000000 -0.500000000000000 0.500000000000000 0.500000000000000 0.500000000000000 0.500000000000000 -0.500000000000000 -0.500000000000000 0.500000000000000 0.500000000000000 0.500000000000000 0.500000000000000 -0.500000000000000 0.500000000000000 0.500000000000000 T'*T ans = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 A=T*B*T A = 0 2.500000000000000 0 -0.500000000000000 2.500000000000000 0 0.500000000000000 0 0 -0.500000000000000 0 -1.500000000000000 0.500000000000000 0 -1.500000000000000 0 A0=A; [Q,R]=qr(A0);A1=R*Q A1 = 0 -2.461538461538462 -0.000000000000000 0.692307692307692 -2.461538461538461 -0.000000000000001 0.692307692307692 0.000000000000000 0 -0.307692307692308 0.000000000000000 -1.538461538461539 -0.307692307692308 -0.000000000000000 -1.538461538461538 0.000000000000000 [Q,R]=qr(A1);A2=R*Q A2 = -0.000000000000000 2.399999999999999 -0.000000000000000 -0.800000000000000 2.400000000000001 -0.000000000000000 0.800000000000000 0.000000000000000 -0.000000000000000 -0.200000000000000 0.000000000000001 -1.600000000000000 0.200000000000000 0.000000000000000 -1.600000000000000 -0.000000000000000 [Q,R]=qr(A2);A3=R*Q A3 = -0.000000000000001 -2.344827586206898 0.000000000000000 0.862068965517241 -2.344827586206897 -0.000000000000000 0.862068965517242 0.000000000000001 0.000000000000000 -0.137931034482759 0.000000000000001 -1.655172413793104 -0.137931034482759 -0.000000000000000 -1.655172413793103 -0.000000000000002 [Q,R]=qr(A3);A4=R*Q A4 = -0.000000000000004 2.300000000000001 -0.000000000000001 -0.900000000000000 2.300000000000002 0.000000000000002 0.900000000000000 0.000000000000000 -0.000000000000000 -0.100000000000000 0.000000000000001 -1.699999999999999 0.100000000000000 0.000000000000000 -1.700000000000000 -0.000000000000002 AA=A4; for k=1:10,[Q,R]=qr(AA);AA=R*Q; end AA AA = -0.000000000000022 2.123076923076924 -0.000000000000006 -0.984615384615386 2.123076923076926 0.000000000000019 0.984615384615385 -0.000000000000005 0.000000000000000 -0.015384615384615 -0.000000000000004 -1.876923076923075 0.015384615384615 0.000000000000000 -1.876923076923075 0.000000000000004 for k=1:100,[Q,R]=qr(AA);AA=R*Q; end AA AA = -0.000000000000503 2.017236255572066 0.000000000000126 -0.999702823179795 2.017236255572073 0.000000000000499 0.999702823179794 0.000000000000116 -0.000000000000000 -0.000297176820208 0.000000000000983 -1.982763744427936 0.000297176820208 0.000000000000000 -1.982763744427930 -0.000000000000958 for k=1:1000,[Q,R]=qr(AA);AA=R*Q; end AA AA = -0.000000000204995 2.001792108939868 -0.000000000025966 -0.999996788335281 2.001792108939860 0.000000000204568 0.999996788335286 -0.000000000025854 -0.000000000000000 -0.000003211664766 0.000000000100959 -1.998207891060268 0.000003211664766 0.000000000000000 -1.998207891060245 -0.000000000100766 [Q,R]=qr(AA);AA1=R*Q; AA1-AA ans = -0.000000000000427 -4.003582613495267 0.000000000051993 1.999993582418494 -4.003582613495267 0.000000000000426 0.000000005747922 -0.000000000000060 0.000000000000000 0.000000005747926 0.000000000000193 -0.000001604384439 -0.000006417581606 0.000000000000000 -0.000001604384484 -0.000000000000193 AA1 AA1 = -0.000000000205422 -2.001790504555399 0.000000000026027 0.999996794083212 -2.001790504555406 0.000000000204994 0.999996794083208 -0.000000000025914 0.000000000000000 -0.000003205916840 0.000000000101152 -1.998209495444707 -0.000003205916840 0.000000000000000 -1.998209495444729 -0.000000000100959 [Q,R]=qr(AA1);AA2=R*Q; AA-AA2 ans = 1.0e-05 * 0.000000085441864 0.320589885394185 0.000000011678837 0.001148043604626 0.320589885260958 -0.000000085286402 -0.001148043582422 0.000000011622332 0.000000000000004 -0.001148043581438 -0.000000038707593 0.320589885327571 0.001148043581438 -0.000000000000019 0.320589885349776 0.000000038663164 B=[2 1 0 0; 0 2 1 0; 0 0 2 1; 0 0 0 2] B = 2 1 0 0 0 2 1 0 0 0 2 1 0 0 0 2 T T = 0.500000000000000 0.500000000000000 -0.500000000000000 0.500000000000000 0.500000000000000 0.500000000000000 0.500000000000000 -0.500000000000000 -0.500000000000000 0.500000000000000 0.500000000000000 0.500000000000000 0.500000000000000 -0.500000000000000 0.500000000000000 0.500000000000000 A=T*B*T A = 1.750000000000000 0.750000000000000 0.250000000000000 -0.250000000000000 0.250000000000000 2.250000000000000 0.750000000000000 0.250000000000000 -0.250000000000000 -0.250000000000000 2.250000000000000 0.750000000000000 0.750000000000000 -0.250000000000000 0.250000000000000 1.750000000000000 format rat A A = 7/4 3/4 1/4 -1/4 1/4 9/4 3/4 1/4 -1/4 -1/4 9/4 3/4 3/4 -1/4 1/4 7/4 format short eig(A) ans = 1.9999 + 0.0001i 1.9999 - 0.0001i 2.0001 + 0.0001i 2.0001 - 0.0001i A0=A; [Q,R]=qr(A0);A1=R*Q A1 = 2.0000 0.6975 0.3997 0.2951 0.1162 2.1757 0.6930 -0.1984 0.0850 -0.4104 2.4416 -0.5784 -0.6158 0.4295 -0.2296 1.3827 [Q,R]=qr(A1);A2=R*Q A2 = 2.1061 0.5279 0.5761 -0.3685 0.0399 2.1987 0.6029 0.2757 0.3004 -0.6663 2.4696 0.3433 0.3930 -0.3644 0.0505 1.2257 [Q,R]=qr(A2);A3=R*Q A3 = 2.2265 0.2321 0.7175 0.4158 0.0020 2.2617 0.5658 -0.3690 0.4067 -0.8161 2.2659 -0.3044 -0.2348 0.2397 0.0791 1.2458 [Q,R]=qr(A3);A4=R*Q A4 = 2.4000 -0.1333 0.6948 -0.4237 -0.0222 2.3160 0.6436 0.3894 0.4250 -0.7765 1.9725 0.4262 0.1374 -0.1349 -0.1293 1.3115 AA=A4; for k=1:10,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.4921 -0.8621 -0.0910 -0.0744 0.0937 1.9397 0.9880 0.0854 0.0222 -0.0673 1.8918 0.9393 0.0008 0.0011 -0.0339 1.6764 for k=1:1000,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.0059 -1.0000 -0.0000 -0.0000 0.0000 2.0000 1.0000 0.0000 0.0000 -0.0000 2.0000 1.0000 0.0000 0.0000 -0.0000 1.9941 format long for k=1:1000,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.002985061471737 -0.999995544672363 -0.000005916898326 -0.000002958468038 0.000002973167936 1.999994091932923 0.999999999956407 0.000005916736551 0.000000002964191 -0.000002958441781 1.999994074467240 0.999995579926441 0.000000000000000 0.000000002911677 -0.000002943789534 1.997026772128152 for k=1:10000,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.000499306783784 -0.999999875346716 0.000001217809977 -0.000000082585321 0.000000083346887 2.000001217850957 0.999999999999408 0.000001551233132 0.000000000013838 -0.000000082587216 1.999998448725249 0.999999875512155 0.000000000000000 0.000000000013797 -0.000000083208703 1.999501026639562 for k=1:100000,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.000131859292370 -0.999999990103974 0.000049179480092 0.000000002418798 0.000000009900526 2.000049179478893 0.999999997583592 0.000049262593067 0.000000000000000 -0.000000000003911 1.999950737405944 0.999999990109348 0.000000000000000 0.000000000000000 -0.000000009894194 1.999868223820754 for k=1:100000,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 1.999962439414623 -0.999999975413905 0.000218597922689 0.000000047865040 0.000000024597662 2.000218597922550 0.999999952144420 0.000218963824593 0.000000000000000 0.000000000000001 1.999781036171339 0.999999975318557 0.000000000000000 0.000000000000000 -0.000000024692056 2.000037926487263 for k=1:100000,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.000184084946466 -0.999999983068495 -0.000003047606589 0.000000000008224 0.000000016948017 1.999996952389669 1.000000000005963 -0.000002698366702 0.000000000000000 -0.000000000000000 2.000002698363699 0.999999983132172 0.000000000000000 0.000000000000000 -0.000000016883315 1.999816264291490 for k=1:100000,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.000030942073658 -0.999999988277685 0.000150095267228 0.000000022576496 0.000000011742740 2.000150095262667 0.999999977440619 0.000150414438766 0.000000000000000 0.000000000000000 1.999849585559110 0.999999988237980 0.000000000000000 0.000000000000000 -0.000000011781404 1.999969377096184 for k=1:1000000,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.000398800644507 -0.999999896833919 -0.000217763320457 0.000000045488414 0.000000103231168 1.999782236682015 0.999999954526649 -0.000208889225547 0.000000000000000 -0.000000000000000 2.000208889209198 0.999999902225445 0.000000000000000 0.000000000000000 -0.000000097839000 1.999610073436894 eig(A) ans = 1.999935266269532 + 0.000064766520240i 1.999935266269532 - 0.000064766520240i 2.000064733730467 + 0.000064700921460i 2.000064733730467 - 0.000064700921460i eig([1 -1;1 1]) ans = 1.000000000000000 + 1.000000000000000i 1.000000000000000 - 1.000000000000000i abs(ans) ans = 1.414213562373095 1.414213562373095 B=[1 -1;1 1] B = 1 -1 1 1 Z=zeros(2); A=[B Z;Z B] A = 1 -1 0 0 1 1 0 0 0 0 1 -1 0 0 1 1 T T = 0.500000000000000 0.500000000000000 -0.500000000000000 0.500000000000000 0.500000000000000 0.500000000000000 0.500000000000000 -0.500000000000000 -0.500000000000000 0.500000000000000 0.500000000000000 0.500000000000000 0.500000000000000 -0.500000000000000 0.500000000000000 0.500000000000000 A=T*A*T A = 1 0 0 1 0 1 -1 0 0 1 1 0 -1 0 0 1 A0=A; [Q,R]=qr(A0);A1=R*Q A1 = 1.000000000000000 0 0 -1.000000000000000 0 1.000000000000000 1.000000000000000 0 0 -1.000000000000000 1.000000000000000 0 1.000000000000000 0 0 1.000000000000000 [Q,R]=qr(A1);A2=R*Q A2 = 1.000000000000000 0 0 1.000000000000000 0 1.000000000000000 -1.000000000000000 0 0 1.000000000000000 1.000000000000000 0 -1.000000000000000 0 0 1.000000000000000 A-A2 ans = 1.0e-15 * 0.222044604925031 0 0 0.444089209850063 0 0.222044604925031 -0.444089209850063 0 0 0.222044604925031 0 0 -0.222044604925031 0 0 0 [Q,R]=qr(A2);A3=R*Q A3 = 1.000000000000000 0 0 -1.000000000000000 0 1.000000000000000 1.000000000000000 0 0 -1.000000000000000 1.000000000000000 0 1.000000000000000 0 0 1.000000000000000 A3-A1 ans = 1.0e-15 * 0.333066907387547 0 0 0 0 0.333066907387547 0 0 0 0.111022302462516 -0.222044604925031 0 -0.111022302462516 0 0 -0.222044604925031 A A = 1 0 0 1 0 1 -1 0 0 1 1 0 -1 0 0 1 A=[B Z;Z B] A = 1 -1 0 0 1 1 0 0 0 0 1 -1 0 0 1 1 A0=A; [Q,R]=qr(A0);A1=R*Q A1 = 1.000000000000000 1.000000000000000 0 0 -1.000000000000000 1.000000000000000 0 0 0 0 1.000000000000000 1.000000000000000 0 0 -1.000000000000000 1.000000000000000 [Q,R]=qr(A1);A2=R*Q A2 = 1.000000000000000 -1.000000000000000 0 0 1.000000000000000 1.000000000000000 0 0 0 0 1.000000000000000 -1.000000000000000 0 0 1.000000000000000 1.000000000000000 C=[2 1;0 2] C = 2 1 0 2 B B = 1 -1 1 1 A=[sqrt(2)*B Z;Z C] A = 1.414213562373095 -1.414213562373095 0 0 1.414213562373095 1.414213562373095 0 0 0 0 2.000000000000000 1.000000000000000 0 0 0 2.000000000000000 eig(A) ans = 1.414213562373095 + 1.414213562373095i 1.414213562373095 - 1.414213562373095i 2.000000000000000 + 0.000000000000000i 2.000000000000000 + 0.000000000000000i abs(ans) ans = 2 2 2 2 A=T*A*T A = 1.457106781186547 -0.042893218813452 -0.957106781186547 0.457106781186548 -0.042893218813452 1.457106781186547 -0.457106781186548 0.957106781186547 0.957106781186548 0.457106781186547 1.957106781186547 0.542893218813452 -0.457106781186547 -0.957106781186548 0.542893218813452 1.957106781186547 A0=A; [Q,R]=qr(A0);A1=R*Q A1 = 1.485669884537290 -0.090385892503050 -0.785321767235886 -0.793362192229597 -0.090385892503050 1.528543677835805 -0.420851370143498 -0.785321767235885 1.077224320482197 0.051620600912729 2.020851370143498 -0.479589296831466 0.562592961460366 1.077224320482197 -0.479589296831466 1.793362192229597 [Q,R]=qr(A1);A2=R*Q A2 = 1.609475708248730 -0.276142374915397 -0.666666666666667 0.942809041582063 -0.276142374915396 1.804737854124365 -0.471404520791032 0.666666666666666 1.138071187457698 -0.195262145875635 1.804737854124366 0.276142374915397 -0.609475708248730 -1.138071187457699 0.276142374915396 1.609475708248730 [Q,R]=qr(A2);A3=R*Q A3 = 1.793362192229597 -0.479589296831467 -0.785321767235885 -0.793362192229597 -0.479589296831466 2.020851370143498 -0.420851370143499 -0.785321767235885 1.077224320482198 0.051620600912729 1.528543677835807 -0.090385892503050 0.562592961460366 1.077224320482197 -0.090385892503050 1.485669884537288 [Q,R]=qr(A3);A4=R*Q A4 = 1.957106781186548 -0.542893218813453 -0.957106781186547 0.457106781186548 -0.542893218813452 1.957106781186548 -0.457106781186548 0.957106781186548 0.957106781186548 0.457106781186548 1.457106781186548 0.042893218813452 -0.457106781186547 -0.957106781186546 0.042893218813452 1.457106781186547 AA=A4; for k=1:10,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.123805823711442 -0.164976849702940 -0.526547565388497 -0.850553150647534 -0.164976849702939 1.452569900823816 -1.291793740047656 0.526547565388497 0.317897957386770 1.340303788557705 1.435937884191800 0.093439841245203 -0.046882746788363 -0.317897957386770 0.093439841245204 1.816113516019132 for k=1:100,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.017466845213369 -0.015232017586103 -0.060911497714111 -0.998143221686926 -0.015232017586103 1.414598167590080 -1.412675559960563 0.060911497714111 0.035693885156943 1.413312299335007 1.414575419644324 0.014331101284219 -0.000582487137542 -0.035693885156941 0.014331101284219 1.981786692298413 for k=1:1000,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.001794753904083 -0.001494539471277 -0.006140613987303 -0.999981146257432 -0.001494539471277 1.414217363802177 -1.414197943442274 0.006140613987300 0.003597101440062 1.414204412982063 1.414217340530386 0.001485390115967 -0.000005914579282 -0.003597101440053 0.001485390115966 1.998197666509552 for k=1:10000,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.000179947631706 -0.000149150754750 -0.000614509220802 -0.999999811189176 -0.000149150754749 1.414213600337681 -1.414213405957050 0.000614509220822 0.000359971180390 1.414213470746702 1.414213600314370 0.000149059128411 -0.000000059231555 -0.000359971180460 0.000149059128411 1.999819976462493 for k=1:100000,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 2.000017999484457 -0.000014912023665 -0.000061455339619 -0.999999998115965 -0.000014912023664 1.414213562751566 -1.414213560809827 0.000061455340248 0.000035999703594 1.414213561457805 1.414213562751547 0.000014911108158 -0.000000000592401 -0.000035999705740 0.000014911108157 1.999981999757921 B1=A(2:3,2:3) B1 = 1.457106781186547 -0.457106781186548 0.457106781186547 1.957106781186547 B1=AA(2:3,2:3) B1 = 1.414213562751566 -1.414213560809827 1.414213561457805 1.414213562751547 eig(B1) ans = 1.414213562751557 + 1.414213561133816i 1.414213562751557 - 1.414213561133816i B=[2 1 0 0; 0 2 0 0; 0 0 -2 1; 0 0 0 -2]; A=T*B*T A = 0 2.500000000000000 0 -0.500000000000000 2.500000000000000 0 0.500000000000000 0 0 -0.500000000000000 0 -1.500000000000000 0.500000000000000 0 -1.500000000000000 0 AA=A; for k=1:10,[Q,R]=qr(AA);AA=R*Q; end,AA AA = -0.000000000000013 2.162162162162163 -0.000000000000004 -0.972972972972974 2.162162162162165 0.000000000000011 0.972972972972973 -0.000000000000002 0.000000000000000 -0.027027027027027 -0.000000000000001 -1.837837837837837 0.027027027027027 0.000000000000000 -1.837837837837837 0.000000000000001 v=[1 -2 2 -1]'; T=eye(4)-2/(v'*v)*v*v' T = 0.800000000000000 0.400000000000000 -0.400000000000000 0.200000000000000 0.400000000000000 0.200000000000000 0.800000000000000 -0.400000000000000 -0.400000000000000 0.800000000000000 0.200000000000000 0.400000000000000 0.200000000000000 -0.400000000000000 0.400000000000000 0.800000000000000 A=T*B*T A = 1.440000000000000 1.920000000000000 0.480000000000000 -0.640000000000000 1.920000000000000 -1.440000000000000 0.640000000000000 0.480000000000000 -0.120000000000000 -0.160000000000000 0.960000000000000 -1.280000000000000 0.160000000000000 -0.120000000000000 -1.280000000000000 -0.960000000000000 eig(A) ans = 2.000000000000001 + 0.000000022351742i 2.000000000000001 - 0.000000022351742i -2.000000003374225 + 0.000000000000000i -1.999999996625776 + 0.000000000000000i AA=A; for k=1:10,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 1.284000000000008 1.711999999999993 0.588000000000001 -0.783999999999998 1.711999999999996 -1.284000000000006 0.783999999999998 0.588000000000001 -0.012000000000000 -0.016000000000000 1.116000000000001 -1.487999999999999 0.016000000000000 -0.012000000000000 -1.488000000000000 -1.116000000000001 for k=1:100,[Q,R]=qr(AA);AA=R*Q; end,AA AA = 1.210523076923538 1.614030769230424 0.599815384615427 -0.799753846153818 1.614030769230433 -1.210523076923526 0.799753846153817 0.599815384615427 -0.000184615384615 -0.000246153846154 1.189476923076635 -1.585969230769442 0.000246153846154 -0.000184615384615 -1.585969230769440 -1.189476923076646 B B = 2 1 0 0 0 2 0 0 0 0 -2 1 0 0 0 -2 A0=A; mi=A0(end,end) mi = -0.960000000000000 A A = 1.440000000000000 1.920000000000000 0.480000000000000 -0.640000000000000 1.920000000000000 -1.440000000000000 0.640000000000000 0.480000000000000 -0.120000000000000 -0.160000000000000 0.960000000000000 -1.280000000000000 0.160000000000000 -0.120000000000000 -1.280000000000000 -0.960000000000000 format short A A = 1.4400 1.9200 0.4800 -0.6400 1.9200 -1.4400 0.6400 0.4800 -0.1200 -0.1600 0.9600 -1.2800 0.1600 -0.1200 -1.2800 -0.9600 I=eye(4); [Q,R]=qr(A0-mi*I);A1=R*Q+mi*I A1 = 2.1537 -0.9625 0.7912 -0.3045 -0.9625 -2.0952 -0.3008 -0.8434 -0.1466 0.0465 1.5717 -0.4671 0.0428 0.0944 -0.4671 -1.6301 mi=A1(end,end); [Q,R]=qr(A1-mi*I);A2=R*Q+mi*I A2 = 2.3277 0.1656 0.8713 -0.0433 0.1656 -2.1651 0.0405 0.9688 -0.1276 -0.0050 1.6660 -0.0304 0.0022 -0.0302 -0.0304 -1.8286 mi=A2(end,end); [Q,R]=qr(A2-mi*I);A3=R*Q+mi*I A3 = 2.3103 -0.0134 0.8920 -0.0032 -0.0134 -2.0863 -0.0029 -0.9925 -0.1080 0.0003 1.6897 -0.0008 0.0000 0.0075 -0.0008 -1.9137 mi=A3(end,end); [Q,R]=qr(A3-mi*I);A4=R*Q+mi*I A4 = 2.2899 0.0005 0.9074 -0.0001 0.0005 -2.0432 0.0001 0.9981 -0.0926 -0.0000 1.7101 -0.0000 0.0000 -0.0019 -0.0000 -1.9568 AA=A4; for k=1:10,mi=AA(end,end);[Q,R]=qr(AA-mi*I);AA=R*Q+mi*I; end,AA AA = 2.1720 0.9695 0.0000 0.0000 -0.0305 1.8280 0.0000 -0.0000 -0.0000 0.0000 -2.0000 -1.0000 0.0000 -0.0000 0.0000 -2.0000 format long for k=1:10,mi=AA(end,end);[Q,R]=qr(AA-mi*I);AA=R*Q+mi*I; end,AA AA = 2.121089090235764 0.985115895663991 0.000000000000000 0.000000000000000 -0.014884104336008 1.878910909764241 -0.000000000000000 -0.000000000000000 -0.000000000000000 0.000000000000000 -2.000000041265537 -0.999999999999998 0.000000000000000 -0.000000000000000 0.000000000000002 -1.999999958734463 for k=1:100,mi=AA(end,end);[Q,R]=qr(AA-mi*I);AA=R*Q+mi*I; end,AA AA = 2.030151684530623 -0.999090047907155 -0.000000000000000 0.000000000000000 0.000909952092844 1.969848315469383 -0.000000000000000 0.000000000000000 0 0 -2.000000000546822 1.000000000000000 0 0 0 -1.999999999453178 for k=1:100,mi=AA(end,end);[Q,R]=qr(AA-mi*I);AA=R*Q+mi*I; end,AA AA = 2.017196116494145 -0.999704206083480 -0.000000000000000 0.000000000000000 0.000295793916520 1.982803883505867 -0.000000000000000 0.000000000000000 0 0 -2.000000000546822 1.000000000000000 0 0 0 -1.999999999453178 for k=1:1000,mi=AA(end,end);[Q,R]=qr(AA-mi*I);AA=R*Q+mi*I; end,AA AA = 2.003245291716563 -0.999989467970803 -0.000000000000000 0.000000000000000 0.000010532029248 1.996754708283431 -0.000000000000000 0.000000000000000 0 0 -2.000000000546822 1.000000000000000 0 0 0 -1.999999999453178 diary off