LAB 8: MARKET WEEKLY REPORTS AND CUBIC SPLINE INTERPOLATION
Mathematics:
Interpolation problems are problems of finding a curve that passes through specified points in the plane. Fitting a curve through points in the plane encounters commonly in analyzing experimental data, in ascertaining the relations among variables and in design work. This project exploits ideas of piecewise cubic spline interpolation for a presentation of market weekly data in the form of a smooth "wellbehaved" curve. For the week of February 1115, 2002, the market indices were registered at the closing bells as follow:
Toronto Stock
Exchange 300:
Day of Week 
Monday 
Tuesday 
Wednesday 
Thursday 
Friday 
Index Value 
7607.40 
7544.60 
7561.20 
7526.40 
7515.30 
Nasdaq Index:
Day of Week 
Monday 
Tuesday 
Wednesday 
Thursday 
Friday 
Index Value 
1848.20 
1836.50 
1860.20 
1843.40 
1805.20 
With the use of cubic splines, the data can be represented by a smooth curve as seen in the weekend news reports:


Suppose a set of (n+1) data points is given in the (x,y) plane:
(x_{1},y_{1});
(x_{2},y_{2}); …; (x_{n},y_{n}); (x_{n+1},y_{n+1})
In our case, n = 4. Also the
points are equally spaced in the xdirection, such that the distance between
the xcoordinates (step size) is:
h = x_{2 }x_{1}
= x_{3 }x_{2 }= … = x_{n+1 }x_{n}
Let
y = S(x) denote a smooth interpolating curves that connects the
given data points. The cubic spline interpolant y = S(x) consists
of cubic polynomials y = S_{j}(x) that connect two
consecutive data points: (x_{j},y_{j}) and
(x_{j+1},y_{j+1}):
y = S_{j}(x) = a_{j} + b_{j} (x  x_{j }) +c_{j} (x – x_{j})^{2} + d_{j} (x – x_{j})^{3}, x_{j} < x < x_{j+1}
Coefficients
(a_{j},b_{j},c_{j},d_{j}) are
found from the conditions that piecewise cubic spline interpolants y = S_{j}(x)
form a continuous curve with continuous first and second derivatives at
all points. Both the slopes and the curvatures of the interpolants y = S_{j}(x)
are matched continuously, so that the resulting interpolating curve y
= S(x) shows up as a smooth curve in viewer's eyes. Eyes of a viewer
cannot distinguish any sudden changes in third and higher derivatives of the
curve y = S(x).
Denote
m_{j} = S_{j}''(x_{j}) for j =
1,2,…,n,n+1. The coefficients (a_{j},b_{j},c_{j},d_{j})
of the cubic spline interpolants y = S_{j}(x) are
found from the values of m_{j} as:
a_{j} = y_{j}
, b_{j} = _{}  _{}h, c_{j}
= _{}, and d_{j} = _{}
The
values of m_{j }are found from a system of (n1) equations:
m_{j1} + 4 m_{j}
+ m_{j+1 }= _{}( y_{j1 }– 2 y_{j} + y_{j+1 }), j = 2,…,n
The
linear system is underdetermined, since two values of m_{j }are
still unknown and two more equations have to be added to the system of (n1)
equations. There are several ways to specify the two additional conditions
required to obtain a unique cubic spline through the points: (i) natural
spline, (ii) parabolic runout spline, and (iii) cubic runout spline.
Objectives:
·
understand
the algorithm for setting cubic spline interpolants with different endpoint
conditions
·
exploit
the cubic spline interpolation and achieve the best visualization of the market
weekly reports
The
natural cubic spline interpolation is prescribed by the endpoint conditions:
m_{1} = 0; m_{n+1} = 0
The
natural spline conditions are equivalent to the conditions that the second
derivative of the cubic spline y = S(x) is zero at the end
points. Thus, the natural spline approaches to the end points x = x_{1}
and x = x_{n+1 }as a straight line. The natural
spline tends to flatten the interpolating curve at the end points, which may be
undesirable:


The
linear system for values of m_{j} (j = 2,…,n) for natural
spline interpolation is set in the matrix form: A m = b, where
A = _{}, m = _{}, b = _{}_{}
Steps
in writing the MATLAB script:
Exploiting
the MATLAB script:
Compute the values of the cubic spline interpolant
in middle of Wednesday.
Answer: In the middle of Wednesday: TSE 300 = 7551.66; NASDAQ = 1848.57
The
parabolic runout spline interpolation is prescribed by the endpoint
conditions:
m_{1} = m_{2}; m_{n+1} = m_{n}
The
parabolic runout spline conditions are equivalent to the conditions that the
spline y = S(x) reduces to a parabolic curve on the first and
last intervals. Thus, the parabolic runout spline approaches to the end points x
= x_{1} and x = x_{n+1 }as a parabolic
curve. The parabolic runout spline is neither flat nor curved at the end
points, i.e. it may be a reasonable compromise for a better visualization of
the interpolating curve:


The
linear system for values of m_{j} (j = 2,…,n) for
parabolic runout spline interpolation is set in the matrix form: A
m = b, where
A = _{}, m = _{}, b = _{}_{}
Steps
in writing the MATLAB script:
Exploiting
the MATLAB script:
Compute the values of the cubic spline interpolant
in middle of Wednesday.
Answer: In the middle of Wednesday: TSE 300 = 7552.95; NASDAQ = 1849.30
The
cubic runout spline interpolation is prescribed by the endpoint conditions:
m_{1} = 2*m_{2 }m_{3}; m_{n+1} = 2*m_{n }m_{n1}
The
cubic runout spline conditions are equivalent to the conditions that the spline
y = S(x) reduces to a single cubic curve on the first two and
last two intervals. Thus, the values of m_{1} and m_{n+1}
are extrapolated from inside conditions that the first two cubic spline
interpolants y = S_{1}(x),y = S_{2}(x) and the
last two cubic spline interpolants y = S_{n1}(x),y = S_{n}(x)
coincide identically. The cubic runout spline produces a curve with pronounced
curvature at the end points, which may be undesirable. The linear system for
values of m_{j} (j = 2,…,n) for cubic runout spline
interpolation is set in the matrix form: A m = b, where
A = _{}, m = _{}, b = _{}_{}
Steps
in writing the MATLAB script:
Exploiting
the MATLAB script: