MAT 581 HW (chp 6 and 8)

# MAT 581 HW (chp 6 and 8) - H/W chap 6 8 P 6.2.4 M-Files...

This preview shows pages 1–4. Sign up to view the full content.

P 6.2.4 M-Files function x = TriCorner1(d,e,f,alpha,beta,b) n = length(b); e_1 = zeros(n,1); e_1(1) = 1; e_n = zeros(n,1); e_n(n) = 1; [l,u] = TriDiLU(d,e,f); y = LBiDiSol(l,b); z = UBiDiSol(u,f,y); t = LBiDiSol(l,alpha*e_n); y1 = UBiDiSol(u,f,t); t = LBiDiSol(l,beta*e_1); y2 = UBiDiSol(u,f,t); Y = [y1 y2]; delta = 1/((1+Y(1,1))*(1+Y(n,2))-(Y(1,2))*(Y(n,1))); V(1,1) = 1+Y(n,2); V(1,2) = -Y(1,2); V(2,1) = -Y(n,1); V(2,2) = 1+Y(1,1); V = delta*V; s=[z(1); z(n)]; x=z-Y*V*s; W = diag(e(2:n),-1) + diag(d) + diag(f(1:n-1),1); T = W+alpha*e_n*e_1'+beta*e_1*e_n'; disp ( 'W=' );disp (W); disp ( 'T=' ); disp (T); function x = LBiDiSol(l,b) % x = LBiDiSol(l,b) % % Solves the n-by-n unit lower bidiagonal system Lx = b % where l and b are n-by-1 and L = I + diag(l(2:n),-1). n = length(b); x = zeros(n,1); x(1) = b(1); for i=2:n x(i) = b(i) - l(i)*x(i-1); end function x = UBiDiSol(u,f,b)

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

View Full Document
% x = UBiDiSol(u,f,b) % % Solves the n-by-n nonsingular upper bidiagonal system Ux = b % where u, f, and b are n-by-1 and U = diag(u) + diag(f(1:n-1),1). n = length(b); x = zeros(n,1); x(n) = b(n)/u(n); for i=n-1:-1:1 x(i) = (b(i) - f(i)*x(i+1))/u(i); end Script d=[4 5 0 4 2 6]; e=[8 7 4 7 4 2]; f=[2 4 7 6 2 4]; b=[1 3 56 2 9 3]'; alpha = 4; beta = 8; x = TriCorner1(d,e,f,alpha,beta,b); Output W= 4 2 0 0 0 0 7 5 4 0 0 0 0 4 0 7 0 0 0 0 7 4 6 0 0 0 0 4 2 2 0 0 0 0 2 6 T= 4 2 0 0 0 8 7 5 4 0 0 0 0 4 0 7 0 0 0 0 7 4 6 0 0 0 0 4 2 2 4 0 0 0 2 6 P 6.3.5
M-Files function x = ProdSolve(A,B,C,f) [LA,UA,pivA] = GEpiv(A); yA = LTriSolM(LA,f(pivA)); xA = UTriSol(UA,yA); [LB,UB,pivB] = GEpiv(B); yB = LTriSolM(LB,xA(pivB));

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This document was uploaded on 02/18/2011.

### Page1 / 10

MAT 581 HW (chp 6 and 8) - H/W chap 6 8 P 6.2.4 M-Files...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online