0% found this document useful (0 votes)
37 views

9 10 Curve Fitting and Interpolation Part 2

1. The document discusses different methods of interpolation, including higher-order polynomials and spline interpolation. 2. Spline interpolation involves using lower-order polynomials between data points, rather than a single high-order polynomial. This reduces issues with overshooting and round-off error. 3. Cubic splines, which ensure continuous first and second derivatives at knots, are commonly used as they provide a superior approximation when data has abrupt changes compared to higher-order polynomials which can oscillate wildly.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

9 10 Curve Fitting and Interpolation Part 2

1. The document discusses different methods of interpolation, including higher-order polynomials and spline interpolation. 2. Spline interpolation involves using lower-order polynomials between data points, rather than a single high-order polynomial. This reduces issues with overshooting and round-off error. 3. Cubic splines, which ensure continuous first and second derivatives at knots, are commonly used as they provide a superior approximation when data has abrupt changes compared to higher-order polynomials which can oscillate wildly.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Curve Fitting and

Interpolation
Cubic & Quadratic Spline Interpolation

PREPARED BY: ENGR. OWEN FRANCIS A. MAONGAT


MATH 130 INSTRUCTOR
SPLINE INTERPOLATION

In the previous sections, nth-order polynomials were used to


interpolate between n 1 l data points. For example, for eight points,
we can derive a perfect seventh-order polynomial. This curve would
capture all the meanderings (at least up to and including seventh
derivatives) suggested by the points. However, there are cases where
these functions can lead to erroneous results because of round-off
error and overshoot. An alternative approach is to apply lower-order
polynomials to subsets of data points. Such connecting polynomials
are called spline functions.
For example, third-order curves employed to connect each pair of
data points are called cubic splines. These functions can be
constructed so that the connections between adjacent cubic equations
are visually smooth. On the surface, it would seem that the third-
order approximation of the splines would be inferior to the seventh-
order expression. You might wonder why a spline would ever be
preferable.
Figure 18.14 illustrates a situation where a spline performs better
than a higher order polynomial. This is the case where a function is
generally smooth but undergoes an abrupt change somewhere along
the region of interest. The step increase depicted in Fig. 18.14 is an
extreme example of such a change and serves to illustrate the point.

FIGURE 18.14
A visual representation of a situation where the splines are superior to higher-order
interpolating polynomials. The function to be fi t undergoes an abrupt increase at x 5 0. Parts
(a) through (c) indicate that the abrupt change induces oscillations in interpolating
polynomials. In contrast, because it is limited to third-order curves with smooth transitions, a
linear spline (d) provides a much more acceptable approximation.
where mi is the slope of the straight line connecting the points:

(18.27)

These equations can be used to evaluate the function at any point between
x0 and xn by first locating the interval within which the point lies. Then
the appropriate equation
Figure 18.14a through c illustrates how higher-order polynomials
tend to swing through wild oscillations in the vicinity of an abrupt
change. In contrast, the spline also connects the points, but because it
is limited to lower-order changes, the oscillations are kept to a
minimum. As such, the spline usually provides a superior
approximation of the behavior of functions that have local, abrupt
changes.

FIGURE 18.14
The concept of the spline originated from the drafting technique of
using a thin, flexible strip (called a spline) to draw smooth curves
through a set of points. The process is depicted in Fig. 18.15 for a
series of five pins (data points). In this technique, the drafter places
paper over a wooden board and hammers nails or pins into the paper
(and board) at the location of the data points. A smooth cubic curve
results from interweaving the strip between the pins. Hence, the
name “cubic spline” has been adopted for polynomials of this type.
In this section, simple linear functions will first be used to introduce
some basic concepts and problems associated with spline
interpolation. Then we derive an algorithm for fitting quadratic
splines to data. Finally, we present material on the cubic spline,
which is the most common and useful version in engineering
practice.
Example No. 1
First-Order Splines
Problem Statement. Fit the data in Table 18.1 with first-order splines. Evaluate
the function at x = 5.
Solution. These data can be used to determine the slopes between points. For
example, for the interval x = 4.5 to x = 7 the slope can be computed using Eq.
(18.27):

The slopes for the other intervals can be computed, and the resulting first-order
splines are plotted in Fig. 18.16a. The value at x 5 5 is 1.3.
 Visual inspection of Fig. 18.16a indicates that the primary
disadvantage of first order splines is that they are not smooth. In
essence, at the data points where two splines meet (called a knot), the
slope changes abruptly. In formal terms, the first derivative of the
function is discontinuous at these points. This deficiency is overcome
by using higher order polynomial splines that ensure smoothness at
the knots by equating derivatives at these points, as discussed in the
next section.
QUADRATIC SPLINE

To ensure that the mth derivatives are continuous at the knots, a


spline of at least m +1 order must be used. Third-order polynomials
or cubic splines that ensure continuous first and second derivatives
are most frequently used in practice. Although third and higher
derivatives could be discontinuous when using cubic splines, they
usually cannot be detected visually and consequently are ignored.
Because the derivation of cubic
splines is somewhat involved, we
have chosen to include them in a
subsequent section. We have decided
to first illustrate the concept of spline
interpolation using second-order
polynomials. These “quadratic
splines” have continuous first
derivatives at the knots. Although
quadratic splines do not ensure equal
second derivatives at the knots, they
serve nicely to demonstrate the
general procedure for developing
higher-order splines.
The objective in quadratic splines is to derive a second-order
polynomial for each interval between data points. The polynomial for
each interval can be represented generally as

Figure 18.17 has been included to help clarify the notation. For n + 1 data
points (i =0, 1, 2, . . . , n), there are n intervals and, consequently, 3n
unknown constants (the a’s, b’s, and c’s) to evaluate. Therefore, 3n
equations or conditions are required to evaluate the unknowns. These are:
1. The function values of adjacent polynomials must be equal at the
interior knots. This
condition can be represented as

2. The first and last functions must pass through the end points.
This adds two additional
equations:
FIGURE 18.17

Notation used to
derive quadratic
splines. Notice that
there are n intervals
and n + 1 data points.
The example shown
is for n = 3
3. The first derivatives at the interior knots must be equal. The
first derivative of Eq. (18.28) is

Therefore, the condition can be represented generally as

for i = 2 to n. This provides another n - 1 conditions for a total of 2n + n - 1


= 3n - 1. Because we have 3n unknowns, we are one condition short. Unless
we have some additional information regarding the functions or their
derivatives, we must make an arbitrary choice to successfully compute the
constants. Although there are a number of different choices that can be made,
we select the following:
4. Assume that the second derivative is zero at the fi rst point.
Because the second derivative of Eq. (18.28) is 2ai, this condition
can be expressed mathematically as

The visual interpretation of this condition is that the first two points
will be connected by a straight line.
Example No. 2
Quadratic Splines
Problem Statement. Fit quadratic splines to the same data used in Example No.
1 (Table 18.1) Use the results to estimate the value at x = 5.
Solution. For the present problem, we have four data points and n = 3 intervals.
Therefore, 3(3) = 9 unknowns must be determined. Equations (18.29) and
(18.30) yield 2(3) - 2 = 4 conditions:

Passing the first and last functions through the initial and final values adds 2
more [Eq. (18.31)]:
and [Eq. (18.32)]

Continuity of derivatives creates an additional 3 - l = 2 [Eq. (18.33)]:

Finally, Eq. (18.34) specifies that a1 = 0. Because this equation specifies a1


exactly, the problem reduces to solving eight simultaneous equations. These
conditions can be expressed in matrix form as
These equations can be solved using Gauss Elimination Method

which can be substituted into the original quadratic equations to develop the
following relationships for each interval:
When we use f 2, the prediction for x = 5 is, therefore,

The total spline fit is depicted in Fig. 18.16b. Notice that there are two
shortcomings that detract from the fit: (1) the straight line connecting the
first two points and (2) the spline for the last interval seems to swing too
high. The cubic splines in the next section do not exhibit these
shortcomings and, as a consequence, are better methods for spline
interpolation.
CUBIC SPLINE
The objective in cubic splines is to derive a third-order polynomial
for each interval between knots, as in

Thus, for n + 1 data points (i = 0, 1, 2, . . . , n), there are n intervals


and, consequently, 4n unknown constants to evaluate. Just as for
quadratic splines, 4n conditions are required to evaluate the
unknowns. These are:
1. The function values must be equal at the interior knots (2n - 2 conditions).
2. The first and last functions must pass through the end points (2 conditions).

3. The first derivatives at the interior knots must be equal (n - 1 conditions).


4. The second derivatives at the interior knots must be equal (n - 1
conditions).
The visual interpretation of condition 5 is that the function becomes a straight line at
5. The second derivatives at the end knots are zero (2 conditions).
the end knots. Specification of such an end condition leads to what is termed a
“natural” spline. It is given this name because the drafting spline naturally behaves
in this fashion (Fig. 18.15). If the value of the second derivative at the end knots is
nonzero (that is, there is some curvature), this information can be used alternatively
to supply the two final conditions.
The above five types of conditions provide the total of 4n equations required to
solve for the 4n coefficients.
Example No. 3
Cubic Splines
Problem Statement. Fit cubic splines to the same data used in Example No. 1 &
2 (Table 18.1) Use the results to estimate the value at x = 5.
Solution. The first step is to employ Eq. (18.37) to generate the set of
simultaneous equations that will be utilized to determine the second
derivatives at the knots. For example, for the first interior knot, the
following data are used:

These values can be substituted into Eq. (18.37) to yield


Because of the natural spline condition, f ‘’ (3) = 0, and the equation
reduces to

In a similar fashion, Eq. (18.37) can be applied to the second interior


point to give

These two equations can be solved simultaneously for


These values can then be substituted into Eq. (18.36), along with
values for the x’s and the f(x)’s, to yield
This equation is the cubic spline for the first interval. Similar
substitutions can be made to develop the equations for the second
and third intervals:

The three equations can then be employed to compute values within each
interval. For example, the value at x = 5, which falls within the second interval,
is calculated as

You might also like