Lab Exercises (lab06)


Exercise 1.

Create 3x3 matrix A and a 3d vector b. (I used A = np.array([[1,2,3],[3,4,2],[5,1,1]]) and b = np.array([5,1,1]). Use direct inversion and SVD to solve for x in Ax=b. Create a singular matrix and repeat.

Exercise 2.

Generate a m-order polynomial (m=2 is a line) y=Sum(i=0,i=m-1) a_i*x^i, and n random data points (try n = 5) using an array of equally spaced x values, and y values plus some gaussian error. Your job is to fit the (x,y) data to recover the coefficients a_i and their errors. I recommend SVD.