23
APMA1170 - Homework 3 Homework 3 Problem 5.1 (a) Show that an elementary lower triangular matirx of type k defined by (5.1) has the form M k = I + me T k , where m = (0, 0, ..., 0,m k+1,k , ..., m n,k ) T . Solution: (me T k ) i,j = m i,k (e T k ) j = m i,k e k,j = m i,k if j=k, i=k+1,...,n; 0 else. So, M k = I + me T k . (b) Show that the inverse of M k in (a) is given by M -1 k = I - me T k . Solution: M k · M -1 k =(I + me T k )(I - me T k )= I + me T k - me T k + me T k me T k = I , since the last term is a zero matrix(because e T k m is zero). (c) Show that the elementary matrix M defined by (5.2) is such that Ma, where a =(a 11 ,a 21 , ..., a n1 ) T , is a multiple of e 1 . Solution: Ma = 1 0 0 ··· 0 - a 2,1 a 1,1 1 0 ··· 0 - a 3,1 a 1,1 0 1 ··· 0 . . . . . . . . . . . . . . . - a n,1 a 1,1 0 0 ··· 1 a 1,1 a 2,1 a 3,1 . . . a n,1 = a 1,1 0 0 . . . 0 = a 1,1 e 1 Problem 5.4 Assuming that LU factorization of A exists, prove that (a) (LDU factorizatioin) A can be written in the form A = LDU 1 , where D is diagonal and L and U 1 are unit lower and upper triangular matrices, respectively. Solution: A = LU , here L is unit a lower triangular matric, U is a upper triangular matric. Let D =

APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

Homework 3

Problem 5.1

(a) Show that an elementary lower triangular matirx of type k defined by (5.1) has the formMk = I + meT

k , where m = (0, 0, ..., 0,mk+1,k, ...,mn,k)T .Solution:(meT

k )i,j = mi,k(eTk )j = mi,kek,j

={

mi,k if j=k, i=k+1,...,n;0 else.

So, Mk = I + meTk .

(b) Show that the inverse of Mk in (a) is given by M−1k = I − meT

k .Solution:Mk · M−1

k = (I + meTk )(I − meT

k ) = I + meTk − meT

k + meTk meT

k = I, since the last term is a zeromatrix(because eT

k m is zero).

(c) Show that the elementary matrix M defined by (5.2) is such that Ma, where a = (a11, a21, ..., an1)T ,is a multiple of e1.Solution:

Ma =

1 0 0 · · · 0

−a2,1

a1,11 0 · · · 0

−a3,1

a1,10 1 · · · 0

......

.... . .

...−an,1

a1,10 0 · · · 1

a1,1

a2,1

a3,1...

an,1

=

a1,1

00...0

= a1,1e1

Problem 5.4

Assuming that LU factorization of A exists, prove that

(a) (LDU factorizatioin) A can be written in the form A = LDU1, where D is diagonal and Land U1 are unit lower and upper triangular matrices, respectively.Solution:A = LU , here L is unit a lower triangular matric, U is a upper triangular matric. Let D =

Page 2: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

diag{u1,1, u2,2, ..., un,n}, and

U1 =

1 u12

u11

u13u11

· · · u1nu11

0 1 u23u22

· · · u2nu22

0 0 0 · · · u3nu33

......

.... . .

...0 0 0 · · · 1

Then A = LDU1, and D is diagonal and L and U1 are unit lower and upper triangular matrices,respectively.

(b) (LDLT factorization) If A is symmetric, then A = LDLT .Solution:From (a), we have A = LDU , and D is diagonal and L and U are unit lower and upper triangularmatrices, respectively. Since A is symmetric, LDU = A = AT = UT DLT , and D is diagonal andUT and LT are unit lower and upper triangular matrices. Then we have DULT−1 = L−1UT D.And DULT−1 is a upper triangular matrix and L−1UT D is a lower triangular matrix, so they mustbe diagonal, that is ULT−1 = I. So U = LT . Thus, A = LDLT .

(c) Using (b), prove that if a is symmetric and positive definite, then A = HHT , where H is alower triangular matrix with positive diagonal entries. (This is known as the Cholesky decomposi-tion.)Solutions:From (b), we have A = LDLT . For any vector y, there is a x s.t. y = LT x. So, yT Dy =xT LDLT x = xT Ax > 0 for any y. Hence, D has positive diagonal entries. Let H = LD

12 , then

A = HHT . And H is a lower triangular matrix with positive diagonal entries.

Problem 5.12

given 0 1 0 00 0 1 00 0 0 12 3 4 5

find a permutation matrix P, a unit lower triangular matrix L, and an upper triangular matrix Usuch that PA = LU.

Solution:

Page 3: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

Let

P =

0 0 0 11 0 0 00 1 0 00 0 1 0

, U =

2 3 4 50 1 0 00 0 1 00 0 0 1

and L = I, then PA = U = LU.

Problem M5.1

Based on Algorithm 5.1, write a MATLAB program, called lugewp, to compute L and U such thatA = LU and the associated growth factor gf: [L,U gf] = lugewp(A).Test data:(i) A= (

10−15 11 1

)(ii) A= (

1 10.00001 1

)(iii) A= 10 1 1

1 10 11 1 20

(v) A = 20 Hilbert matrix.Print in each case(i) |||L||U |||F

||A||F , (ii) ||A−LU ||F||L||F ||U ||F , (iii) ||A−LU ||F

||A||F , and (iv) the growth factor.Write your observations.

gf f1 f2 f31 1E+15 1.15E+15 0 02 1 1 0 03 1 1 0 05 1 1 4.88E-20 5.43E-17

For the first 3 matrixes, f2 and f3 are 0, because A - LU=0 and the rounding error is ignorablehere. But, they can’t not be ignorable for 20*20 Hilbert matrix. For the first matrix, growth factorand (i) are huge. And we can see pivoting is useful, compare this with the result from M5.2.

Problem M5.2

Based on algorithm 5.2, write a MATLAB program, called lugepp, to compute (i) P,L and Usuch that PA = LU, using partial pivoting, and (ii) the associated growth factor gf: [L, u, P, gf] =

Page 4: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

lugepp(A). Print ||L||F ||U ||F||A||F , ||PA−LU ||F

||A||F , and the growth factor for each of the matrices A of ProblemM5.1. Explain why these results are different.Solution:

gf f4 f51 1 1.414214 02 1 1.414209 03 1 1.722266 05 1 5.545161 0.353207

Using Partial pivoting, growth factor become 1 for the first matrix, so we can see LU withpivoting is stabler. While, for the 20*20 Hilbert Matrix, f4 and f5 are not ignorable. Observe theL and U we get from lugepp, we can find many very small entries, thus causing big rounding errorswhen you multiply these numbers or add them together.

Codes and details for these two problems:

function [ a ] = fnorm( A )%FNORM F norm of matrix A[m,n]=size(A); for i=1:m

for j=1:na= 1 ;%%%%%need to be revised.

endend

end

function [L,U,g] = lugewp( A )%Based on Algorithm 5.1, lugewp is to compute L and U such that%A = LU and the associated growth factor gf: [L,U gf] = lugewp(A).%Input: A%Outputs: gf, U (upper parts of B and diagonal entries of B)% L(negative of lower parts of B with diangonal entries to be ones)n= size(A);B=A;L=eye(n);U=zeros(n);g=0;a=0;

for i=1:nfor j=1:n

b=abs(A(i,j));

Page 5: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

if b>aa=b;

endend

enda1=a;b1=0;for k=1:n

for i=k+1:nB(i,k)=-B(i,k)/B(k,k);L(i,k)=-B(i,k);for j=k+1:n

B(i,j)=B(i,j)+B(i,k)*B(k,j);end

endfor i=k+1:n

for j=k+1:nb1=abs(B(i,j));

if b1>a1a1=b1;

endend

endend

for k=1:nfor j=k:n

U(k,j)=B(k,j);end

end

g=a1/a;

end

function [L, U, g, P, s, r] = lugepp( A )%Based on algorithm 5.2, lugepp is to compute (i) P,L and U

Page 6: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

%such that PA = LU, using partial pivoting, and (ii) the associated%growth factor gf: [L, u, P, gf] = lugepp(A).%Input: A%Outputs: P, gf, U (upper parts of B and diagonal entries of B)% L(negative of lower parts of B with diangonal entries to be ones)n= size(A); B=A; L=eye(n); U=zeros(n);s=0; %Indicatorg=1; a=0; P=eye(n);for i=1:n

for j=1:nb=abs(A(i,j));if b>a

a=b;end

endenda1=a; b1=0;

for k=1:n-1r(k)=k;a=abs(B(k,k));for i=k+1:n

if abs(B(i,k))>ar(k)=i;a=abs(B(i,k));

endendif a==0

s=1;break;

endif r(k)~=k,

for j=k:ntemp=B(k,j);B(k,j)=B(r(k),j);B(r(k),j)=temp;

endfor j=1:n

temp=P(k,j);P(k,j)=P(r(k),j);P(r(k),j)=temp;

end

Page 7: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

end

for i=k+1:nB(i,k)=-B(i,k)/B(k,k);L(i,k)=-B(i,k);for j=k+1:n

B(i,j)=B(i,j)+B(i,k)*B(k,j);end

endfor i=k+1:n

for j=k+1:nb1=abs(B(i,j));if b1>a1

a1=b1;end

endend

end

for i=1:nfor j=i:n

U(i,j)=B(i,j);end

endend

>> f1=@(A,L,U) fnorm(abs(L)*abs(U))/fnorm(A)>> f2=@(A,L,U) fnorm(A-L*U)/fnorm(L)/fnorm(U)>> f3=@(A,L,U) fnorm(A-L*U)/fnorm(A)>> f4=@(A,L,U) fnorm(L)*fnorm(U)/fnorm(A)>> f5=@(P,A,L,U) fnorm(P*A-L*U)/fnorm(A)

>> A=[10^(-15) 1;1 1];>> [L,U,g]=lugewp(A)

L =

1.0e+015 *

0.000000000000001 0

Page 8: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

1.000000000000000 0.000000000000001

U =

1.0e+015 *

0.000000000000000 0.0000000000000010 -0.999999999999999

g =

9.999999999999989e+014

>> f1(A,L,U)

ans =

1.154700538379251e+015

>> f2(A,L,U)

ans =

0

>> f3(A,L,U)

ans =

0

>> [L,U,g,P,s]=lugepp(A)

L =

1.000000000000000 00.000000000000001 1.000000000000000

U =

Page 9: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

1.000000000000000 1.0000000000000000 0.999999999999999

g =

1

P =

0 11 0

s =

0

>> f4(A,L,U)

ans =

1.414213562373095

>> f5(P,A,L,U)

ans =

0

>> A=[1 1;0.00001 1];>> [L,U,g]=lugewp(A)

L =

1.000000000000000 00.000010000000000 1.000000000000000

U =

Page 10: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

1.000000000000000 1.0000000000000000 0.999990000000000

g =

1

>> f1(A,L,U)

ans =

1

>> f2(A,L,U)

ans =

0

>> f3(A,L,U)

ans =

0

>> [L,U,g,P,s]=lugepp(A)

L =

1.000000000000000 00.000010000000000 1.000000000000000

U =

1.000000000000000 1.0000000000000000 0.999990000000000

g =

Page 11: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

1

P =

1 00 1

s =

0

>> f4(A,L,U)

ans =

1.414208848355386

>> f5(P,A,L,U)

ans =

0

>> A=[10 1 1;1 10 1;1 1 20];>> [L,U,g]=lugewp(A)

L =

1.000000000000000 0 00.100000000000000 1.000000000000000 00.100000000000000 0.090909090909091 1.000000000000000

U =

10.000000000000000 1.000000000000000 1.0000000000000000 9.900000000000000 0.9000000000000000 0 19.818181818181817

Page 12: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

g =

1

>> f1(A,L,U)

ans =

1

>> f2(A,L,U)

ans =

0

>> f3(A,L,U)

ans =

0

>> [L,U,g,P,s]=lugepp(A)

L =

1.000000000000000 0 00.100000000000000 1.000000000000000 00.100000000000000 0.090909090909091 1.000000000000000

U =

10.000000000000000 1.000000000000000 1.0000000000000000 9.900000000000000 0.9000000000000000 0 19.818181818181817

g =

1

Page 13: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

P =

1 0 00 1 00 0 1

s =

0

>> f4(A,L,U)

ans =

1.722266438352776

>> f5(P,A,L,U)

ans =

0>> A=hilb(20);>> [L,U,g]=lugewp(A)

L =

Cols 1 through 7

Page 14: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

1 0 0 0 0 0 00.5 1 0 0 0 0 0

0.333333 1 1 0 0 0 00.25 0.9 1.5 1 0 0 00.2 0.8 1.714286 2 1 0 0

0.166667 0.714286 1.785714 2.777778 2.5 1 00.142857 0.642857 1.785714 3.333333 4.090909 3 1

0.125 0.583333 1.75 3.712121 5.568182 5.653846 3.50.111111 0.533333 1.69697 3.959596 6.853147 8.615385 7.466667

0.1 0.490909 1.636364 4.111888 7.93007 11.63077 12.60.090909 0.454545 1.573427 4.195804 8.811189 14.53846 18.529410.083333 0.423077 1.510989 4.230769 9.519231 17.24661 24.911760.076923 0.395604 1.450549 4.230769 10.07919 19.71041 31.467490.071429 0.371429 1.392857 4.205882 10.51471 21.91486 37.985760.066667 0.35 1.338235 4.163399 10.84675 23.86285 44.31672

0.0625 0.330882 1.286765 4.108617 11.09327 25.56734 50.359910.058824 0.313725 1.23839 4.045408 11.26935 27.04644 56.052770.055556 0.298246 1.192982 3.976608 11.38756 28.32037 61.360790.052632 0.284211 1.150376 3.904306 11.45829 29.40961 66.26966

0.05 0.271429 1.11039 3.83004 11.49012 30.33391 70.77913

Cols 8 through 14

Page 15: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

0 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 01 0 0 0 0 0 04 1 0 0 0 0 0

9.529412 4.499994 1 0 0 0 017.64706 11.84208 4.999832 1 0 0 028.09597 23.88153 14.40404 5.496147 1 0 040.4582 40.93975 31.42665 17.19895 5.920382 1 0

54.26537 62.89834 57.72893 40.36014 19.84121 6.12563 169.06501 89.33386 94.29004 79.09181 49.5831 20.88549 2.48444984.4545 119.6436 141.4344 136.8714 102.8804 53.21578 1.797772

100.0942 153.1437 198.94 216.2677 187.5455 112.7978 -6.32653115.7089 189.1391 266.1736 318.8569 310.7399 210.2243 -30.3041131.0828 226.9669 342.2223 445.2685 478.4763 356.175 -80.9837146.0522 266.0228 426.0069 595.3048 695.3453 560.6547 -171.019

Cols 15 through 200 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 01 0 0 0 0 0

5.349 1 0 0 0 016.92031 2.515918 1 0 0 041.16255 2.856003 5.071572 1 0 084.69329 -3.08983 15.92618 1.434957 1 0154.8687 -24.2039 39.15069 -1.05384 4.624467 1

Page 16: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

U =

Cols 1 through 71 0.5 0.333333 0.25 0.2 0.166667 0.1428570 0.083333 0.083333 0.075 0.066667 0.059524 0.0535710 0 0.005556 0.008333 0.009524 0.009921 0.0099210 0 0 0.000357 0.000714 0.000992 0.001190 0 0 0 2.27E-05 5.67E-05 9.28E-050 0 0 0 0 1.43E-06 4.29E-060 0 0 0 0 0 9.01E-080 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 0

Cols 8 through 14

Page 17: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

0.125 0.111111 0.1 0.090909 0.083333 0.076923 0.071428570.048611 0.044444 0.040909 0.037879 0.035256 0.032967 0.030952380.009722 0.009428 0.009091 0.008741 0.008394 0.008059 0.00773810.001326 0.001414 0.001469 0.001499 0.001511 0.001511 0.00150210.000126 0.000155 0.00018 0.0002 0.000216 0.000229 0.000238438.09E-06 1.23E-05 1.67E-05 2.08E-05 2.47E-05 2.82E-05 3.14E-053.15E-07 6.73E-07 1.14E-06 1.67E-06 2.24E-06 2.84E-06 3.42E-065.66E-09 2.26E-08 5.39E-08 9.99E-08 1.59E-07 2.29E-07 3.07E-07

0 3.55E-10 1.60E-09 4.21E-09 8.48E-09 1.45E-08 2.23E-080 0 2.23E-11 1.11E-10 3.21E-10 7.00E-10 1.29E-090 0 0 1.40E-12 7.69E-12 2.41E-11 5.65E-110 0 0 0 9.38E-14 5.55E-13 1.86E-120 0 0 0 0 1.23E-14 7.51E-140 0 0 0 0 0 -2.25E-150 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 0

Cols 15 through 20

Page 18: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

0.066666667 0.0625 0.05882353 0.0555556 0.0526316 0.050.029166667 0.02757353 0.02614379 0.0248538 0.0236842 0.0226190.007434641 0.00714869 0.00687994 0.0066277 0.006391 0.00616880.001486928 0.00146736 0.00144479 0.0014202 0.0013944 0.00136790.000245958 0.00025155 0.00025554 0.0002582 0.0002598 0.0002605

3.42E-05 3.66E-05 3.87E-05 4.05E-05 4.21E-05 4.34E-053.99E-06 4.54E-06 5.05E-06 5.53E-06 5.97E-06 6.38E-063.91E-07 4.78E-07 5.67E-07 6.55E-07 7.42E-07 8.27E-073.17E-08 4.25E-08 5.44E-08 6.72E-08 8.06E-08 9.45E-082.10E-09 3.15E-09 4.43E-09 5.93E-09 7.62E-09 9.49E-091.11E-10 1.92E-10 3.03E-10 4.46E-10 6.23E-10 8.33E-104.65E-12 9.65E-12 1.76E-11 2.92E-11 4.49E-11 6.52E-112.57E-13 6.55E-13 1.39E-12 2.59E-12 4.39E-12 6.92E-12

-6.61E-15 -8.32E-15 2.75E-15 4.34E-14 1.37E-13 3.09E-131.87E-14 1.03E-13 3.31E-13 8.12E-13 1.68E-12 3.09E-12

0 -4.03E-16 -7.71E-16 -7.48E-17 4.52E-15 1.77E-140 0 4.49E-15 2.24E-14 6.99E-14 1.71E-130 0 0 -2.33E-16 -3.12E-16 4.66E-160 0 0 0 3.40E-15 1.61E-140 0 0 0 0 -2.03E-16

g =

1

>> f1(A,L,U)

ans =

1.000000000001935

>> f2(A,L,U)

ans =

4.877053421422423e-020

>> f3(A,L,U)

ans =

5.425855937264502e-017

Page 19: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

>> [L,U,g,P,s]=lugepp(A)

L =

Cols 1 through 71 0 0 0 0 0 0

0.5 1 0 0 0 0 00.333333 1 1 0 0 0 0

0.25 0.9 0.514286 1 0 0 00.2 0.8 0.783673 -0.28571 1 0 0

0.166667 0.714286 0.918367 -0.19841 -0.2901 1 00.142857 0.642857 0.979592 -0.09524 -0.15824 0.328283 1

0.125 0.583333 -0.85714 -0.28571 -0.26109 0.888889 0.436260.111111 0.533333 0.997403 0.080808 0.15905 -0.23932 0.313212

0.1 0.490909 0.981818 0.146853 0.30674 -0.39161 0.600620.090909 0.454545 0.959041 0.1998 0.4382 -0.47203 0.8176510.083333 0.423077 0.932496 0.241758 0.552314 -0.49774 0.950.076923 0.395604 0.904239 0.274725 0.649781 -0.48391 -0.247870.071429 0.371429 0.87551 0.30042 0.732087 -0.44272 0.9777860.066667 0.35 0.847059 0.320261 0.800975 -0.38347 0.896212

0.0625 0.330882 0.819328 0.335397 0.858188 -0.31304 0.7681820.058824 0.313725 0.79257 0.346749 0.905341 -0.23642 0.605390.055556 0.298246 0.766917 0.355054 0.94388 -0.15718 0.4178520.052632 0.284211 0.742427 0.360902 0.975069 -0.0778 0.213837

0.05 0.271429 0.719109 0.364766 -0.34813 0.707071 -0.28919Cols 8 through 14

Page 20: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

0 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 01 0 0 0 0 0 0

0.219373 1 0 0 0 0 00.296946 -0.67339 1 0 0 0 00.254525 -0.63794 -0.61554 1 0 0 00.14008 -0.38119 -0.29191 0.498844 1 0 0

-0.29762 0.404947 0.814005 -0.30009 0.496545 1 0-0.13045 0.40338 0.169221 -0.35349 -0.55823 -0.31506 1-0.22826 0.74267 0.199051 -0.44904 -0.85349 -0.3734 0.67344912-0.28071 0.954861 0.122842 -0.29608 -0.65024 -0.20433 0.65961631-0.28268 -0.43895 -0.62745 0.6208 -0.30625 -0.42915 0.71979081-0.23413 0.857669 -0.10216 0.27439 0.748229 0.084492 0.06224459-0.13825 0.522518 -0.12004 0.337207 0.430183 0.407843 -0.277176-0.43625 0.423983 -0.79792 0.918329 0.414337 0.460894 -0.5131829

Cols 15 through 200 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 00 0 0 0 0 01 0 0 0 0 0

0.549020061 1 0 0 0 00.253333569 -0.2854436 1 0 0 0-0.63016521 0.02462497 0.34118923 1 0 00.730115853 0.05310586 0.61845437 -0.574734 1 0-0.42293802 0.17135687 -0.3174175 -0.662566 0.6290418 1

Page 21: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

U =

Cols 1 through 71 0.5 0.333333 0.25 0.2 0.166667 0.142857140 0.083333 0.088889 0.083333 0.07619 0.069444 0.063492060 0 0.006481 0.011048 0.013889 0.01558 0.016534390 0 0 0.001136 0.002381 0.003434 0.00425170 0 0 0 0.00013 0.000361 0.000644210 0 0 0 0 7.85E-06 2.55E-050 0 0 0 0 0 -5.19E-070 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 0

Cols 8 through 14

Page 22: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

0.125 0.11111111 0.1 0.09090909 0.0833333 0.07692308 0.071428570.0583333 0.05387205 0.05 0.04662005 0.0436508 0.04102564 0.038690480.0170139 0.01718575 0.017156863 0.01699689 0.0167519 0.01645299 0.016121030.0048611 0.00530303 0.005614973 0.00582751 0.0059644 0.00604396 0.006079930.0009457 0.00124352 0.001525518 0.00178557 0.0020212 0.00223219 0.002419365.14E-05 8.33E-05 0.000118543 0.0001554 0.0001924 0.00022855 0.0002632

-1.99E-06 -4.60E-06 -8.34E-06 -1.31E-05 -1.86E-05 -2.48E-05 -3.14E-053.74E-08 1.59E-07 3.98E-07 7.72E-07 1.28E-06 1.92E-06 2.67E-06

0 -2.12E-09 -1.02E-08 -2.87E-08 -6.12E-08 -1.11E-07 -1.78E-070 0 1.27E-10 6.68E-10 2.02E-09 4.58E-09 8.75E-090 0 0 -7.11E-12 -4.08E-11 -1.33E-10 -3.24E-100 0 0 0 -2.06E-13 -1.30E-12 -4.60E-120 0 0 0 0 1.42E-14 9.44E-140 0 0 0 0 0 -1.24E-150 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 00 0 0 0 0 0 0

Cols 15 through 200.066666667 0.0625 0.05882353 0.0555556 0.0526316 0.050.036601307 0.03472222 0.03302374 0.0314815 0.0300752 0.02878790.01577045 0.01541113 0.01504988 0.0146914 0.0143387 0.0139941

0.006082888 0.00606085 0.00601995 0.0059649 0.0058994 0.00582610.002584283 0.00272875 0.00285463 0.0029638 0.0030579 0.00313870.000295939 0.00032654 0.00035492 0.0003811 0.000405 0.0004268

-3.82E-05 -4.51E-05 -5.21E-05 -5.90E-05 -6.57E-05 -7.23E-053.51E-06 4.42E-06 5.38E-06 6.39E-06 7.41E-06 8.44E-06

-2.65E-07 -3.69E-07 -4.91E-07 -6.28E-07 -7.78E-07 -9.40E-071.48E-08 2.30E-08 3.33E-08 4.58E-08 6.05E-08 7.72E-08

-6.56E-10 -1.17E-09 -1.91E-09 -2.89E-09 -4.14E-09 -5.66E-09-1.21E-11 -2.61E-11 -4.96E-11 -8.52E-11 -1.36E-10 -2.03E-103.52E-13 9.67E-13 2.19E-12 4.32E-12 7.69E-12 1.27E-11

-8.05E-15 -2.97E-14 -8.20E-14 -1.88E-13 -3.75E-13 -6.80E-133.50E-16 2.13E-15 7.64E-15 2.06E-14 4.64E-14 9.17E-14

0 4.00E-16 2.23E-15 7.46E-15 1.92E-14 4.18E-140 0 3.03E-16 1.54E-15 4.75E-15 1.14E-140 0 0 6.94E-17 4.25E-16 1.43E-150 0 0 0 1.12E-16 4.91E-160 0 0 0 0 5.63E-17

Page 23: APMA1170 - Homework 3 Homework 3 - Brown University · 2011-06-15 · APMA1170 - Homework 3 diag{u 1,1,u 2,2,...,u n,n}, and U 1 = 1 u 12 u 11 u 13 u 11 ··· u 1n u 11 0 1 u 23

APMA1170 - Homework 3

g =

1

P =

1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 00 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 10 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 00 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 00 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 00 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 00 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0

s =

0

>> f4(A,L,U)

ans =

5.545160574236721

>> f5(P,A,L,U)

ans =

0.353206508053793