|
SPLINE INTERPOLATION AN INTERACTIVE EBOOK
|
|
|
On non Internet Explorer
browsers, the equations may not show up. As an alternative or if you
prefer, you can see the pdf version of the ebook instead |
|
Title |
An interactive e-book for illustrating the Spline Method for interpolation. |
|
Creator |
Autar K Kaw |
|
Subject and Keywords |
Spline Method, Interpolation, Mathcad, Maple, Mathematica, Matlab, Simulations. |
|
Description |
This is an interactive ebook for illustrating spline method for interpolation. It includes links to simulations in Mathcad, Maple, Mathematica and Matlab for the algorithm, multiple choice quizzes, problem set, and a PowerPoint presentation. |
|
Publisher |
Holistic Numerical Methods Institute, |
|
Contributors |
Autar Kaw, Michael Keteltas |
|
Format |
Text/HTML |
|
Last Revised |
June 14, 2004 |
|
Identifier |
http://numericalmethods.eng.usf.edu/ebooks/spline_05inp_ebook.pdf |
|
Language |
English |
|
Rights |
|
|
Table of Contents
Spline Method of Interpolation Quadratic spline interpolation
Examples Example 1: Linear spline application problem Example 2: Quadratic spline application problem Simulation [MAPLE] [MATHCAD] [MATHEMATICA] [MATLAB]
Problem Sets |
|
Background This is an example of how an instructor of a Numerical Methods course can develop an E-book on a single topic by using resources that are only available at the Holistic Numerical Methods Institute (HNMI) Website. Although one of the primary advantages of a web-based resource is that one can use documents outside of its own domain, we are particularly using this example as a way to illustrate the holistic nature of the resources available at HNMI. You are welcome to modify and edit this e-book to suit your purpose. Using the textbook document written in MS Word 2000 as a foundation, it was made interactive within MS Word 2000 by putting bookmarks and hyperlinks to background information, PowerPoint presentations, Mathcad simulations, historical anecdotes, multiple choice tests, problem sets, etc. Then the MS Word 2000 file was saved as a webpage and that is what you are about to read here. |
|
What is interpolation? Many a times,
a function
So what kind
of function a) evaluate b) differentiate, and c) integrate
Figure 1: Interpolation of discrete data
Polynomial interpolation involves finding a polynomial of order ‘n’ that
passes through ‘n+1’ data points. Several methods to obtain such a
polynomial include direct method,
on an interval of [-1, 1]. For example, take six equidistantly spaced points in [-1, 1] and find y at these points as given in Table 1. Table 1: Six equidistantly spaced points in [-1, 1]
Figure 2: 5th order polynomial vs. exact function Now through these six points, one can pass a fifth order polynomial
through the six data points. On plotting the fifth order polynomial and the original function, one can see that the two do not match well. One may consider choosing more points in the interval [-1, 1] to get a better match, but it diverges even more (see Figure 3), where 21 equidistant points were chosen in the interval [-1, 1] to draw a 20 th order polynomial. In fact, Runge found that as the order of the polynomial becomes infinite, the polynomial diverges in the interval of –1 < x < 0.726 and 0.726 < x < 1.
Figure 3: Higher order polynomial interpolation is a bad idea
So what is the answer to using information from more data points, but at the same time keeping the function true to the data behavior? The answer is in spline interpolation. The most common spline interpolations used are linear, quadratic, and cubic splines.
Figure 4: Linear splines
. . .
Note the terms of
in the above function are simply
slopes between
Example 1 The upward velocity of a rocket is given as a function of time as Table 2: Velocity as a function of time
Figure 5: Velocity vs. time data for the rocket example Determine the value of the velocity at t=16 seconds using a first order polynomial. Solution
Since we need to evaluate the velocity at t = 16 s, we choose the two data
points closest to t = 16 s and that bracket t = 16. Those two points
are
At
Linear splines are no different from linear interpolation. It still uses data only from the two consecutive data points. Also at the interior points of the data, the slope changes abruptly. This means that the first derivative is not continuous at these points. So how do we improve on this? We can do so by using quadratic splines.
Quadratic Splines:
In these splines, a quadratic polynomial approximates the data between two
consecutive data points. Given
. . .
So how does one find the coefficients of these quadratic splines? There are 3n such coefficients
To find ‘3n’ unknowns, one needs to set up ‘3n’ equations and then simultaneously solve them. These ‘3n’ equations are found by the following. 1) Each quadratic spline goes through two consecutive data points
. . .
. . .
This condition gives 2n equations as there are ‘n’ quadratic splines going through two consecutive data points.
2) The first derivatives of two quadratic splines are continuous at the interior points. For example, the derivative of the first spline
is
The derivative of the second spline
is
and the two are
equal at
Similarly at the other interior points,
. . .
. . .
Since there are (n-1) interior
points, we have (n-1) such equations. So far, the total number of
equations is We can assume that the first spline is linear, that is
This gives us ‘3n’ equations and ‘3n’ unknowns. These can be solved by a number of techniques used to solve simultaneous linear equations.
Example 2 The upward velocity of a rocket is given as a function of time as Table 3: Velocity as a function of time
Figure 6: Velocity vs. time data for the rocket example Determine the value of the velocity at t=16 using quadratic splines. a) Determine the value of the velocity at t=16 seconds using quadratic splines. b) Using the quadratic splines as velocity functions, find the distance covered by the rocket from t=11s to t=16s. c) Using the quadratic splines as velocity functions, find the acceleration of the rocket at t=16s. Solution: a) Since there are six data points, five quadratic splines pass through them.
Setting up the equations
At t = 10
At t = 15
At t = 20
At t = 22.5
3.
Assuming the first spline
Solving the above 15 equations gives the 15 unknowns as
Therefore, the splines are given by
At t = 16
b) The distance covered by the rocket between 11 s and 16 s can be calculated as But since the splines are valid over different ranges, we need to break the integral accordingly as
c) What is the acceleration at t = 16?
Simulations [MAPLE] [MATHCAD] [MATHEMATICA] [MATLAB] Problem Set 1. The following x‑y data is given
The data is fit by quadratic spline interpolants given by f(x)= -0.75 x + 5.5, 1≤ x ≤2, =2 x2 ‑ 8.75 x + 13.5, 2≤ x ≤3, =c x2 + g x + h, 3≤ x ≤5, =j x2 + k x + l, 5≤ x ≤6, where c, g, h, j, k, l are constants. a) Find the value of c, g, h, j, k, l. b) Compare the values of the function at x=2.3 using linear spline interpolation and quadratic spline interpolation. Answer: (a) c=1.86029, g=-7.9117, h=12.242, j=19.308, k=-182.39, l=444.26 (b)Linear Spline = 5.625; Quadratic Spline = 3.955
*2. Given (x1,y1), (x2,y2), ........, (xn,yn), that is n data points. For conducting quadratic spline interpolation the x- data needs to be A) equally spaced B) in ascending or descending order C) in integers D) positive Answer: B
*3. In cubic spline interpolation, for the splines (A) The first derivatives are continuous at the interior data points (B) The second derivatives are continuous at the interior data points (C) The first and the second derivatives are continuous at the interior data points (D) The third derivatives are continuous Answer: C
*4. The following incomplete y vs. x data is given
The data is fit by quadratic spline interpolants given by f(x) = 1.4583 x + 2.7916, 1£x£2.2, = -1.3055 x2 +7.2027 x -3.5272, 2.2£x£3.7, = c x2 + g x + h, 3.7 £x£5.1, = j x2 + k x + l, 5.1£x£6, where c, g, h, j, k, l are constants. What is the value of g? Show all your steps clearly. Answer: 4.2482
*5. The following incomplete y vs. x data is given
The data is fit by quadratic spline interpolants given by f(x) =1.4583 x + 2.7916, 1£x£2.2, =-1.3055 x2 +7.2027 x -3.5272, 2.2£x£3.7, = c x2 + g x + h, 3.7 £x£5.1, = j x2 + k x + l, 5.1£x£6, where c, g, h, j, k, l are
constants. What is the value of Answer: 0.23111
*6. The following incomplete y vs x data is given
The data is fit by quadratic spline interpolants given by f(x) =1.4583 x + 2.7916, 1£x£2.2, =-1.3055 x2 +7.2027 x -3.5272, 2.2£x£3.7, = c x2 + g x + h, 3.7 £x£5.1, = j x2 + k x + l, 5.1£x£6, where c, g, h, j, k, l are
constants. What is the value of Answer: 5.6965
|