Lab 10 summary M. M. Sussman {@(#) Thu Feb 16 19:34:00 2017 } $Id: summary.txt,v 1.11 2017/02/17 00:34:37 mike Exp $ EXERCISE 1 1. meshplot: fill in xNode=j*h, yNode=k*h 2. plot of mesh 3. copy tests.m, tests(75)=76, tests(80)='none' 4. fill in below 75+1 test yielding 'none' 5. fill in left 75-10 test yielding 'none' 6. fill in right 75+10 test yielding 'none' EXERCISE 2 1. poissonmatrix.m 2. norm(A-A','fro')=0 3. v'*A*v>0, random v 4. det(A)=7.6579e+260 5. norm(L*E-A*E)=roundoff, L=48.219 E(10)=-.1523 6. min(min(inv(A)))=2.0830e-6>0 7. norm(gallery('poisson',10)/h^2-A,'fro')=0 EXERCISE 3 1-2, anothermatrix.m 3. norm(A-A','fro') 4. v'*A*v > 0 5. spy plot all red 6. N=12;x=((1:N^2).^2)'; sum(A*x)= 129339420; N=13, sum=226538260 (N=15, sum=617237640; N=20, sum=4633162020) EXERCISE 4 1. cgm.m 2. norm(y-xExact)=2.1216e-12, norm(x-xExact)=4.2730e-08 3. norm(x-xExact)/norm(xExact)=2.4466e-16 4. norm(x-xExact)/norm(xExact)=4.2565e-11 (after 100 iterations) (N=31) EXERCISE 5 1. cg.m with plot and still has parm m 2. semilog plot: decline to around 1e-28, roughly 108 its to 1.e-12 3. add tolerance to call, etc. 4. took me 101 iterations to get to 1e-10, true rel error=4.2565e-11 took me 111 iterations to get to 1e-12, true rel error=2.3981e-13 5. anothermatrix took 162 steps to get to 1e-10, true error=1.9168e-10 EXERCISE 6 1,2 anotherdiags.m 3. test as specified: 4 tests get 0 each 4. poissondiags.m + TESTS EXERCISE 7 1,2. multdiags.m 3. test with x=ones(9,1). norm(multdiags(Adiags,x)-A*x)=0 4. x=(10:18)'. norm=0 5. N=12, random x, rel norm=roundoff EXERCISE 8 1. cgdiags.m 2. solve problem twice, get k=9, same ans. 3. same ans twice, k=66. rel err in norm 2.157e-12 4. n=672 (vectorized on oz: 28.52 sec, loops on oz: 66.57 or 77) 5. 2.5001e-4, tol=1.e-6, much worse EXERCISE 9 1. Adiag has 3*250000 entries=6e6 bytes=6MB 2. A has (2.5e5)^2 entries=5e11 bytes=500GB cost more than $2000 at $4/GB, more than the cost of my computer 3. C=1(min)/(1e4)^3=1e-12 (min) 4. T=C*(500^2)^3=15625 min = 10.85 days, compared with .5 min or 1 min EXERCISE 10 1. Matlab sparse representation of A implies A(2,1)=2, A(3,2)=2, A(5,1)=0 2. Nonzero entries column 4: (2,4) 5 (3,4) 4 (4,4) 3 (5,4) 2 (6,4) 1 Nonzero entries in row 4: (4,2) 1 (4,3) 2 (4,4) 3 (4,5) 4 (4,6) 5 2. representation of B would be (1,1) 1 (4,1) 5 (3,2) 4 (2,3) 3 (4,3) 6 (1,4) 2 EXERCISE 11 (Extra credit 8 points) 1. precg.m, with convergence criterion based on r, not rho. test poissonmatrix(100), U=eye, k=16 both agree. 2. r^0=b, \gamma_1=\rho_0=b'*A^{-1}*b, \alpha_1=1, k=2 at cnvgce 3. k=2, error=roundoff, (alpha=1) 4. N=50: k(cg)=230, k(precg)=37, err(cg)=1.9609e-11, err(precg)=1.0329e-11 (resid(cg)=9.2463e-11, resid(precg)=7.7504e-11)