CS 131 Problem Set 1 1. The null space of a square matrix A is the solution to the linear system Ax=0. This is usually written as a linear combination of vectors in A that forms a basis of the null space. Using Gauss-Jordan reduction, identify a basis for the null space of a given square matrix. For example, after performing Gauss-Jordan reduction on some matrix, the RREF of the augmented system is: " 1 0 1 0 !1 0 % $ ' 0 ' $ 0 1 !1 0 1 $ 0 0 0 1 !1 0 ' $ 0 0 0 0 0 0 ' $ ' 0 '& $# 0 0 0 0 0 There are two free variables s1 and s2 and the solution of the system is given by " !s + s % " !1 % " 1 % $ 1 2 ' $ ' $ ' $ s1 ! s2 ' 1 ' !1 ' $ $ $ ' x =$ s1 ' = s1 $$ 1 '' + s2 $$ 0 '' 0 1 $ ' s2 $ ' $ ' $ ' 0 '& 1 '& $ $ # # s $# '& 2 Hence, a possible basis vectors for the null space of the given matrix is
" !1 % " 1 % $ ' $ ' $ 1 ' $ !1 ' $ 1 ' and $ 0 ' $ 0 ' $ 1 ' $ ' $ ' $# 0 '& $# 1 '& Write a program that solves the nullspace of a matrix as an input and create a test case to check that your program works properly. 2. (a) An nxn Hilbert matrix has entries hij=1/(i+j-1). For n=2, 3, … , generate the Hilbert matrix of order n and the vector b=Hx where x is a vector of ones (actual solution). Use Gaussian elimination with full pivoting to solve the resulting linear system Hx=b, obtaining the approximate solution to x and the error of approximation to be ||xactual-xapprox||/||xactual||. How large can you take n before the error gets 100%. For each n, compute the condition number of H using the cond() function of Scilab. Plot and characterize the condition number of H as a function of n. As n varies, how does the number of correct digits in the components of the approximate solution of x relate to the condition number of the matrix? (b) Solve the above system using modified Gauss-Seidel iteration and a vector of zeros as starting guess solution. Plot the number of iterations vs n for which the solution converged to the actual solution. Does the method exhibit sensitivity to the conditioning of the problem? 3. Fit a polynomial of degree m−1, f (x) = a0 + a1 x + a2 x 2 +... + am!1 x m!1 to n data points (xi,yi), n>m. We choose xi =(i−1)/(n−1), i=1, ... , n, so that the data points are equally spaced on the
interval [0, 1]. We will generate the corresponding values yi by first choosing actual values for the aj to be (a) 1 for all j = 0, ... , m-1, (b) (-1)j for all j = 0, ... , m-1, (c) a0=am-1=1, aj 0 for all j=1, ... , m-2. Then we evaluate the resulting polynomial to obtain yi= f(xi), for i = 1, ... , n. We could now see whether we can recover the actual values of aj that we used to generate the yi, but to make it more interesting, we first randomly perturb the yi values to simulate the data error typical of least squares problems. Specifically, we take yi = yi + (2rand() − 1) ∗ε, for all i=1, ... , n, where ε is a small positive number that determines the maximum perturbation. Take n=21, m=12, and ε = 10−6. Having generated the data set (xi , yi ) as just outlined, compare two methods for computing the least squares solution to this polynomial data fitting problem. First, form the system of normal equations for this problem and solve it using LU factorization. Next, solve the same using QR factorization. Compare the two resulting solu- tion vectors x. For which method is the solution more sensitive to the perturbation we in- troduced into the data? Which method comes closer to recovering the x that we used to generate the data for the three cases? Since this involves random number generation, perform three realizations for each case. 4. Refer to Heath (First Ed) Chapter 7 Computer Problem 7.7 on page 261. Analyze the population data as follows: (a) (b) (c) (d) (f)
Since the independent variable is ordinal (e.g. year), how should it be represented? Perform interpolation using monomial basis. Perform interpolation using cubic spline. Extrapolate population on 1990 using the results from (b) and (c). Compare with actual. Perform interpolation using Newton s basis as in (b) and (c). How do you modify this interpolant if an additional data (population on 1990) is included.