Homework 6, Math 307, Fall 2011 PROBLEM 1(a). Consider a model y=a+bx+cx^3 that you are fitting to the data (x,y)=(0,y_0),(1,y_1),(2,y_2). In general, given y_0,y_1,y_2, will there be a unique solution a,b,c? You may calculate this by hand or use a computer. PROBLEM 1(b). Same a PROBLEM 1(a), except for the data (x,y)=(-1,y_(-1)),(0,y_0),(1,y_1). PROBLEM 2(a). The following program finds the least squares fit y(x) = alpha + beta x + gamma x^2 (i.e., fitting with a quadratic function in x) to y(x)=sin(x) for the values x=-.2,-.1,0,.1,.2: (The program below works in Matlab; in Octave you have to replace "clearvars A b" with "clear") clearvars A b for i=1:5 x = (i-3)*.1; A(i,1)=1; A(i,2)=x; A(i,3)=x^2; b(i,1)=sin(x); end A b inv(A' * A) * A' * b Explain how this program creates A,b and finds the vector whose components are alpha, beta, and gamma. How do you explain the fact that alpha=gamma=0 and beta is slightly less than 1, given what you know about the function sin(x)? PROBLEM 2(b) Guess the rough values of alpha, beta, and gamma that you will see when you replace "sin" with "cos". [As usual, there is no "correct" guess; hopefully you are not entirely off, but hopefully you will still learn something.] Now perform the calculation and explain the results. PROBLEM 2(c) Do the same as in 2(b), except replace cos(x) with 10 * x^4. PROBLEM 2(d) Do the same as in 2(b), except replace cos(x) with abs(x) (the absolute value of x).