Starting from:
$30

$24

NUMERICAL COMPUTATION Homework 9:


1. Consider the function

f(x) = sin(2 x) + cos(3 x);  x 2 [  1; 1]:
(1)

Compute the coe cients of a least-squares- t degree-7 polynomial from n = 33 evenly spaced points. In other words, your training data are pairs (xi; yi) with i = 1; : : : ; 33 where the xi’s are evenly spaced points in [ 1; 1] (like, linspace) and yi = f(xi). Make a plot of both f(x) and the degree-7 polynomial approximation.

    2. Create testing data by (i) choosing 100 random points in the interval [ 1; 1] and (ii) evaluating the function at each of those points. This gives you a new set of data (x01; y10 ); : : : ; (x0100; y1000 ). For d from 1 to 31, compute the least-squares coe cients of a polynomial of degree d with the same training data as in the last problem using both the QR method and the normal equations. For each trained polynomial pd(x), compute the normalized testing error:

ed =
P
i=1
100
(y0 )2
!
1=2






(2)


100
(y0
p(x0 ))2





i=1
i






i
i


P

Plot the error ed versus d on a log scale (that is, use semilogy). 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.

BONUS (50 POINTS): Here some US COVID case counts from back in March.

Days since Feb 29
Case count


1
89
2
105
3
125
4
159
5
227
6
331
7
444
8
564
9
728
10
1000
11
1267
12
1645
13
2204
14
2826
15
3485
17
7038




1
Derive the linear least-squares system whose solution contains the coe cients of a log-linear model for case count over time. Plot the data on top of the model on a log scale. How well does the log-linear model (which represents exponential growth) appear to model the growth in the case count? What was the case doubling time over this roughly two week period?





























































2

More products