NUMERICAL COMPUTATION Homework 7

$24.99 $18.99

Turn in your own writeup that includes your code. List any resources you used including collaborating with others. Submit a PDF on Canvas by Friday, Oct. 22 at 5pm. Consider the parameterized family of functions, f (x) = 1 ; x 2 [ 5; 5]: 1 + exp( x) The parameter controls how smooth f…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Turn in your own writeup that includes your code. List any resources you used including collaborating with others. Submit a PDF on Canvas by Friday, Oct. 22 at 5pm.

Consider the parameterized family of functions,

f (x) =

1

; x 2 [ 5; 5]:

1 + exp( x)

The parameter controls how smooth f is near x = 0, as shown:

To start this homework, let = 1.

1. Generate training data: Create a vector with n = 7 evenly spaced points in the interval [ 5; 5]. (Matlab/Numpy: (np.)linspace.) For each point xi in this vector, compute yi = f (xi). You should now have 7 pairs (xi; yi). Make a nice table with the seven input/output pairs.

  1. Train the model: Construct the Vandermonde system and solve for the coe cients of the unique degree-6 interpolating polynomial p6(x). Make a nice table of the 7 coe cients. And make a plot showing both f and pp over the domain [ 5; 5]. Does this look like a good approximation? Explain your assessment.

  1. Generate testing data: Create a new vector with 101 evenly spaced points in [ 5; 5]. For each point x0i, compute yi0 = f (x0i). Report the mean ((np.)mean) and standard deviation ((np.)std) from the set of points y10 ; : : : ; y1010 .

  1. Compute the testing error: Compute and report the the absolute testing error:

error = error =1;n=7

= maximum

j yi0

p6(xi0 ) j

jyi0 j

i

If you’re wondering how to compute p6(x0i), look up (np.)polyval and use the coe cients you computed in Step 2. You’re evaluating the polynomial model’s prediction of f (x0i).

  1. Repeat steps 1-4 with = 10. How does the error change? What does that tell you about the quality of the polynomial approximation for the two functions?

  1. EXTRA CREDIT (15pts): Repeat steps 1-4 with both = 1 and = 10 for n = 8; 9; : : : ; 15. Plot error versus n on a semilog scale. Describe the convergence (that is, at what rate the error goes to zero) as n increases.

2

Placeholder
NUMERICAL COMPUTATION Homework 7
$24.99 $18.99