# CSCI3656 Numerical Computing :: Project Seven solved

\$25.00

Category:

## Description

Rate this product

Consider the parameterized family of functions,
fθ(x) = 1
1 + exp(−θx)
, x ∈ [−5, 5].
The parameter θ controls how smooth fθ is near x = 0, as shown:
-5 0 5
x
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
fθ(x)
θ=1
θ=2
θ=10
To start this homework, let θ = 1.
1. Generate training data: Create a vector with n = 7 evenly spaced
points in the interval [−5, 5]. 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.
2. Train the model: Construct the Vandermonde system and solve for
the coefficients of the unique degree-6 interpolating polynomial p6(x).
Make a nice table of the 7 coefficients. And make a plot showing both
fθ(x) and p6(x) over the domain [−5, 5]. Does this look like a good
3. Generate testing data: Create a new vector with 101 evenly spaced
points in [−5, 5]. For each point x

i
, compute y

i = fθ(x

i
).
1
4. Compute the testing error: Compute and report the the absolute
testing error:
error = errorθ=1,n=7 = maximum
i
| y

i − p6(x

i
)|
|y

i
|
If you’re wondering how to compute p6(x

i
), look up (np.polyval and
use the coefficients you computed in Step 2. You’re evaluating the
polynomial model’s prediction of fθ(x

i
).
5. 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?
2