Docsity

6 Problems on Numerical Methods - Assignment 8 | CS 257, Assignments of Computer Science

Toggle sidebar
bg1
CS 257: Numerical Methods
Spring 2006
Homework, Set 8 Due Thursday April 6, 2006
(-) Start EACH PROBLEM on a SEPARATE piece of paper (This is important since we may
assign each problem to a different grader).
(-) Put your NETID and HW NUMBER on top of EACH PAGE clearly,
e.g. “netid: zamani hw2”.
(-) Write descriptive solutions. Comment your code!
(-) Include your curves/graphs (and other supporting materials) in your write-up.
(-) Don’t use handwritten code (unless you want to lose points), copy-paste your code into
your write-up or attach a proper print of code to your papers.
(-) Please write everything in a “portrait” style (not landscape).
(-) Please number problems according to numbers presented in the homework write-up that
appears on the course page, NOT according to the numbers in the textbook.
(-) Please type your homework or hand-write it legibly (but yet attach a print of your codes
to your handwritten stuff).
(-) Show that your code works (even if the problem doesn’t explicitly asks to test your code!)
(1) Determine the parameters a,b,c,dand eso that Sis a natural cubic spline:
S(x) = a+b(x−1) + c(x−1)2+d(x−1)3x∈[0,1]
(x−1)3+ex2−1x∈[1,2]
(2) Determine whether fis a cubic spline with knots -1, 0, 1 and 2:
f(x) =
1 + 2(x+1)+(x+ 1)3−1≤x≤0
3+5x+ 3x20≤x≤1
11 + (x−1) + 3(x−1)2+ (x−1)31≤x≤2
(3) Suppose S(x) is an mth-degree interpolating spline function over the interval [a, b] with n+ 1 knots
a=t0< t1<· · · < tn=b.
a. How many conditions are needed to define S(x) uniquely over [a, b] ?
b. How many conditions are defined by the interpolation conditions at the knots?
c. How many conditions are defined by the continuity of the derivatives?
d. How many additional conditions are needed so that the total equals the number in part a?
(4) Determine whether this function is a natural cubic spline:
S(x) = x3+ 3x2+ 7x−5−1≤x≤0
−x3+ 3x2+ 7x−5 0 ≤x≤1
(5) Implement two functions nat spline coef and spline eval, corresponding to Listing 1 and Listing
2 here http://www.cs.uiuc.edu/class/sp06/cs257/lectures/lecture22 handout.pdf. Respect the order
of input parameters as specified in the listings.
pf2

Partial preview of the text

Download 6 Problems on Numerical Methods - Assignment 8 | CS 257 and more Assignments Computer Science in PDF only on Docsity!

CS 257: Numerical Methods Spring 2006 Homework, Set 8 Due Thursday April 6, 2006

(-) Start EACH PROBLEM on a SEPARATE piece of paper (This is important since we may assign each problem to a different grader). (-) Put your NETID and HW NUMBER on top of EACH PAGE clearly, e.g. “netid: zamani hw2”. (-) Write descriptive solutions. Comment your code! (-) Include your curves/graphs (and other supporting materials) in your write-up. (-) Don’t use handwritten code (unless you want to lose points), copy-paste your code into your write-up or attach a proper print of code to your papers. (-) Please write everything in a “portrait” style (not landscape). (-) Please number problems according to numbers presented in the homework write-up that appears on the course page, NOT according to the numbers in the textbook. (-) Please type your homework or hand-write it legibly (but yet attach a print of your codes to your handwritten stuff). (-) Show that your code works (even if the problem doesn’t explicitly asks to test your code!)

(1) Determine the parameters a, b, c, d and e so that S is a natural cubic spline:

S(x) =

a + b(x − 1) + c(x − 1)^2 + d(x − 1)^3 x ∈ [0, 1] (x − 1)^3 + ex^2 − 1 x ∈ [1, 2]

(2) Determine whether f is a cubic spline with knots -1, 0, 1 and 2:

f (x) =

1 + 2(x + 1) + (x + 1)^3 − 1 ≤ x ≤ 0 3 + 5x + 3x^2 0 ≤ x ≤ 1 11 + (x − 1) + 3(x − 1)^2 + (x − 1)^3 1 ≤ x ≤ 2

(3) Suppose S(x) is an mth-degree interpolating spline function over the interval [a, b] with n + 1 knots a = t 0 < t 1 < · · · < tn = b.

a. How many conditions are needed to define S(x) uniquely over [a, b]? b. How many conditions are defined by the interpolation conditions at the knots? c. How many conditions are defined by the continuity of the derivatives? d. How many additional conditions are needed so that the total equals the number in part a?

(4) Determine whether this function is a natural cubic spline:

S(x) =

x^3 + 3x^2 + 7x − 5 − 1 ≤ x ≤ 0 −x^3 + 3x^2 + 7x − 5 0 ≤ x ≤ 1

(5) Implement two functions nat spline coef and spline eval, corresponding to Listing 1 and Listing 2 here http://www.cs.uiuc.edu/class/sp06/cs257/lectures/lecture22 handout.pdf. Respect the order of input parameters as specified in the listings.

(6) Let S(x) be the cubic spline function that interpolates f (x) = (x^2 + 1)−^1 at 41 equally spaced knots in the interval [− 5 , 5]. Let P (x) be the Newton interpolating polynomial that interpolates f (x) = (x^2 + 1)−^1 at the same 41 equally spaced knots in the interval [− 5 , 5]. Hand in 4 plots:

  1. S(x) using your code from number (5) above
  2. P (x) using your code from HW
  3. an error plot for part 1: error(x) = S(x) − f (x)
  4. an error plot for part 2: error(x) = P (x) − f (x)

On the plots, make sure to plot the knots as well as the curve.