Matlab diary from CS 290H, Wednesday, April 09, 2014 This is /Users/gilbert/Documents/CS290hSpring2014/Matlab/startup.m Starting diary file diary-09-Apr-2014.txt > help grid5 GRID5 : Generate 5-point finite difference mesh. [A,xy] = GRID5(k) returns a k^2-by-k^2 symmetric positive definite matrix A with the structure of the k-by-k 5-point grid, and an array xy of coordinates for the grid points. > k = 40; > [A,xy ] = grid5(k); > whos Name Size Bytes Class Attributes A 1600x1600 138248 double sparse xy 1600x2 25600 double > L = laplacian(A); > spy(L) > gplotg(L,xy) > nnz(L) ans = 7840 > n = k^2 n = 1600 > v = [ones(n/2,1) ; -ones(n/2,1)]; > size(v) ans = 1600 1 v' * L * v / (v'*v) ans = 0.1000 > ans * sqrt(n) ans = 4 > x = (k-1 : -2 : -(k-1)) x = Columns 1 through 8 39 37 35 33 31 29 27 25 Columns 9 through 16 23 21 19 17 15 13 11 9 Columns 17 through 24 7 5 3 1 -1 -3 -5 -7 Columns 25 through 32 -9 -11 -13 -15 -17 -19 -21 -23 Columns 33 through 40 -25 -27 -29 -31 -33 -35 -37 -39 > size(x) ans = 1 40 > x=x' x = 39 37 35 ... -37 -39 > y = ones(1,k) y = Columns 1 through 8 1 1 1 1 1 1 1 1 Columns 9 through 16 1 1 1 1 1 1 1 1 Columns 17 through 24 1 1 1 1 1 1 1 1 Columns 25 through 32 1 1 1 1 1 1 1 1 Columns 33 through 40 1 1 1 1 1 1 1 1 > V = x * y V = Columns 1 through 8 39 39 39 39 39 39 39 39 37 37 37 37 37 37 37 37 35 35 35 35 35 35 35 35 33 33 33 33 33 33 33 33 31 31 31 31 31 31 31 31 29 29 29 29 29 29 29 29 27 27 27 27 27 27 27 27 25 25 25 25 25 25 25 25 23 23 23 23 23 23 23 23 21 21 21 21 21 21 21 21 19 19 19 19 19 19 19 19 17 17 17 17 17 17 17 17 15 15 15 15 15 15 15 15 13 13 13 13 13 13 13 13 11 11 11 11 11 11 11 11 9 9 9 9 9 9 9 9 7 7 7 7 7 7 7 7 5 5 5 5 5 5 5 5 3 3 3 3 3 3 3 3 1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1 -3 -3 -3 -3 -3 -3 -3 -3 -5 -5 -5 -5 -5 -5 -5 -5 -7 -7 -7 -7 -7 -7 -7 -7 -9 -9 -9 -9 -9 -9 -9 -9 -11 -11 -11 -11 -11 -11 -11 -11 -13 -13 -13 -13 -13 -13 -13 -13 -15 -15 -15 -15 -15 -15 -15 -15 -17 -17 -17 -17 -17 -17 -17 -17 -19 -19 -19 -19 -19 -19 -19 -19 -21 -21 -21 -21 -21 -21 -21 -21 -23 -23 -23 -23 -23 -23 -23 -23 -25 -25 -25 -25 -25 -25 -25 -25 -27 -27 -27 -27 -27 -27 -27 -27 -29 -29 -29 -29 -29 -29 -29 -29 -31 -31 -31 -31 -31 -31 -31 -31 -33 -33 -33 -33 -33 -33 -33 -33 -35 -35 -35 -35 -35 -35 -35 -35 -37 -37 -37 -37 -37 -37 -37 -37 -39 -39 -39 -39 -39 -39 -39 -39 Columns 9 through 16 ... Columns 33 through 40 ... > v = V(:) v = 39 37 35 ... -37 -39 > size(v) ans = 1600 1 > v' * L * v / (v'*v) ans = 0.0073 > x = [ones(n/2,1) ; -ones(n/2,1)]; > x'*L*x / (x'*x) ans = 0.1000 > v' * L * v / (v'*v) ans = 0.0073 > ans * n ans = 11.7073 > [a,b] = fiedler(L); > b b = 0.0062 > diary off