ENG 4350/5340: Project 2

Assigned: June 9,2015

Due: June 23, 2015

**Rules**

*• *Use C or C++ with BLAS/LAPACK for completion of this assignment.

*• *Produce a LATEX-generated PDF of your report.

*• *Ask plenty of questions to ensure you have a good understanding of the project.

*• *The code (and reports) should look vastly different for different groups. Very similar code will incur a

hefty penalty.

Consider the function *f*(*t*) = *−**t *3 + 2*t *2 + *t *+ 2 on the closed interval *t **∈ *[*−*2*, *2].

**Part 1**

1. Sample *f*(*t*) to produce *f*(*t **k*) where *k **∈ *[1*, *10] *⊂ Z*. The *t **k *should be randomly chosen points on the

interval [*−*2*, *2]. Produce a table with columns *t **k *and *f*(*t **k*). Ensure that the *t **k**s *are not sorted.

2. Solve the normal equations using QR decomposition and calculate the error, *E*. Write your approximated

function, *f*ˆ1(*t*).

3. Solve the normal equations using the SVD and calculate the error, *E*. Write your approximated function,

ˆ*f*2(*t*).

4. Plot *f*(*t*), *f*ˆ1(*t*) and *f*ˆ2(*t*) on the same plot.

**Part 2**

In this part we will see how additive random noise affects our solution.

1. Create a new dataset by doing the following:

*• *Sample *f*(*t*) to produce *f*(*t **k*) where *k **∈ *[1*, *1000] *⊂ Z*. The *t **k *should be randomly chosen points

on the interval [*−*2*, *2]. Use a different random seed than used in the previous part.

*• *Add columns *y *1(*t **k*) = *f*(*t **k*) + *n *1(*t **k*) and *y *2(*t **k*) = *f*(*t **k*) + *n *2(*t **k*) where *n *1(*t*) *∼ N*(0*, *1) and

*n *2(*t*) *∼ N*(0*, *5) to the dataset.

2. Solve the normal equations for this new dataset. NOTE: This dataset should be solved simultaneously

with 3 right hand sides.

3. Include the error in your report.