## Description

1. Consider the function

f(x) = sin(2πx) + cos(3πx), x ∈ [−1, 1]. (1)

Evaluate the function values at n evenly spaced points. You get to

choose n. For d from 0 to n − 1, compute the least-squares coefficients

of a polynomial of degree d with the same training data using both the

QR method and the normal equations.

2. For each trained polynomial compute testing error on a set of testing

data, which you will generate. Plot the error ed versus d on a semilogy scale. Make sure to include both (i) the error computed using the

QR decomposition and (ii) the error computed using the normal equations. Interpret the error behavior. (HINT: It’s related to the condition

number of the matrix in the least-squares problem.)

1