Numerical Analysis Assignment 6 — Piecewise Interpolation and Splines  
Question #1
Consider the following set of data points:
$x$$y$
0.10.03
0.30.06
0.80.07
1.10.1
Write a function f in C that returns $y$ given $x$ in the range $x_1\le x \le x_4$ using piecewise linear interpolation:
09.26.16
Question #2
Consider the following data points:
$x$$y$
13
37
86
109
127
1412
Do the following:
(a)  Using a cubic spline, find the value (by hand) of $y$ at $x=6$. Derive proper boundary conditions and do basic verifications to ensure that your answer is correct.
(b)  Using a Lagrange polynomial, find the value (by hand) of $y$ at $x=6$. Compare to the result obtained in (a) and discuss.
09.28.16
Question #3
Consider 9 nodes arranged as follows:
Q6.png
with the following values and $x$-$y$ coordinates:
Node$x$$y$$\phi$
10?100
2??120
31?150
401160
5?1170
611190
702200
8?2230
912270
using a multidimensional piecewise-linear interpolation, it is found that: $$ \phi_{x=0.2,y=1.6}=190 $$ and $$ \phi_{x=0.8,y=0.8}=170 $$ Knowing that $$ x_2=x_5=x_8 $$ $$ y_1=y_2=y_3 $$ find (in no particular order):
(a)  The $y$ coordinate of nodes 1, 2, and 3.
(b)  The $x$ coordinate of nodes 2, 5, and 8.
Question #4
Consider the following data points:
$x$$f(x)$
12
24
43
It is given that at $x=1$, $f^{\prime\prime\prime}=0$. Using a cubic spline, find the value of $f(x)$ at $x=3$. Specifically, do the following:
(a)  Derive a boundary condition function of $b$s at the left boundary.
(b)  Derive a boundary condition function of $b$s at the right boundary.
(c)  Write down the equation for the center node function of $b$s.
(d)  Solve the $b$ equations in (a), (b), and (c) and evaluate $f$ at $x=3$.
(e)  Perform basic verifications to ensure that your answer is correct.
11.19.18
Answers
3.  -0.9, 0.733.
4.  $\frac{13}{3}$.
Reminder
Equations for inner nodes within cubic splines: $$ f_i(x)=a_i(x-x_i)^3 + b_i(x-x_i)^2 + c_i(x-x_i)+d_i $$ $$ d_i=y_i $$ $$ a_i=(b_{i+1}-b_i)/(3\Delta x_i) ~~\textrm{for}~1\le i \le N-1 $$ $$ c_i = \frac{\Delta y_i}{\Delta x_i} - b_i \Delta x_i - \left( \frac{b_{i+1}-b_i}{3}\right)\Delta x_i ~~\textrm{for}~1\le i \le N-1 $$ $$ \Delta x_{i-1} b_{i-1} + 2 \left(\Delta x_i + \Delta x_{i-1} \right) b_i + \Delta x_i b_{i+1} = 3 \left(\frac{\Delta y_i}{\Delta x_i} - \frac{\Delta y_{i-1}}{\Delta x_{i-1}}\right)~~\textrm{for}~2\le i \le N-1 $$
Due on Monday 26 November at 16:30. Do Questions #1, #3, and #4 only.
PDF 1✕1 2✕1 2✕2
$\pi$