HW4 Sol

HW4 Sol - EE103, Winter 2009, HW 4 Solution, SEJ Applied...

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

View Full Document Right Arrow Icon
EE103, Winter 2009, HW 4 Solution, SEJ Page 1 / 8 Applied Numerical Computing Instructor: Prof. S. E. Jacobsen HW4 Solution P 1) The following are the codes for generating the matrix X , new X , and the polynomial coefficient vector a . x=(1:10)'; y=[-0.9924;0.3734;1.2225;-0.5341;-0.7670;-0.7907;-0.5769;0.2626;- 0.8987;-0.6639]; n=10; deg=7; X=vander(x); X=X(:,n-deg:n); x_new=(x-mean(x))/std(x); X_new=vander(x_new); X_new=X_new(:,n-deg:n); [Q,R]=gsmodified(X_new); a=R\(Q'*y); xd=linspace(1,10); domain=linspace(min(x_new),max(x_new)); pd=polyval(a,domain); plot(x,y, 'ro' ,xd,pd) (a) The condition numbers of X and T X X are cond(X) ans = 1.0943e+009 cond(X'*X) ans = 1.1976e+018. It shows that the matrix X is an ill-conditioned matrix. (b) The condition numbers of new X and T new new X X are cond(X_new) ans = 344.7194 cond(X_new'*X_new)
Background image of page 1

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

View Full DocumentRight Arrow Icon
EE103, Winter 2009, HW 4 Solution, SEJ Page 2 / 8 ans = 1.1883e+005. Clearly, by using the normalized vector new x , we can have a much better conditioned matrix new X . This is because the dynamic range of the matrix is much lower after the normalization. (c) Using the QR factorization, the least squares polynomial coefficient vector “ a ” for the data [ ] new x y is a = -0.2270 1.1477 1.4507 -4.7438 -2.1983 5.0009 0.3350 -1.1125. (d) Since the polynomial coefficient vector computed in part (c) is corresponding to the normalized data set [ ] new x y , we select linspace(min(x_new),max(x_new)) to be the “domain” for the polyval function. When plotting the polynomial, we rescaled (the last line of the code) it back to the range [1,10] x in order to compare with the original data points. The results are shown in the figure below. 0 2 4 6 8 10 -1.5 -1 -0.5 0 0.5 1 1.5 x y the original [x y] the 7 th degree fitting polynomial P 2) (a) Consider 1 n ax Ax ⎡⎤ ⎢⎥ = ⎣⎦ # . Then,
Background image of page 2
EE103, Winter 2009, HW 4 Solution, SEJ Page 3 / 8 { } 1 1, , 1, , 1, , max , , max , , max , , max{ }max , , .
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 8

HW4 Sol - EE103, Winter 2009, HW 4 Solution, SEJ Applied...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online