0% found this document useful (0 votes)
30 views31 pages

MathEng5-M - Part 6-2

Uploaded by

Leonard Abarra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views31 pages

MathEng5-M - Part 6-2

Uploaded by

Leonard Abarra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

MathEng5-M - Numerical Solutions to CE Problems

12/6/2021
Part 6
INTERPOLATION
2
Lagrange Interpolating Polynomials

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
❑ General form of the equations
𝑥−𝑥𝑗
𝑓𝑛 𝑥 = σ𝑛𝑖=0 𝐿𝑖 𝑥 𝑓 𝑥𝑖 where: 𝐿𝑖 𝑥 = ς𝑛𝑗=0 𝑥 −𝑥
𝑖 𝑗
𝑗≠1

where  designates the “product of.” For example, the linear version (n = 1) is
𝑥−𝑥1 𝑥−𝑥0
𝑓1 𝑥 = 𝑥 𝑓 𝑥0 + 𝑥 𝑓 𝑥1
𝑜 −𝑥1 1 −𝑥0

And the second order version is


𝑥−𝑥1 𝑥−𝑥2 𝑥−𝑥0 𝑥−𝑥2 𝑥−𝑥0 𝑥−𝑥1
𝑓2 𝑥 = 𝑓 𝑥0 + 𝑓 𝑥1 + 𝑓 𝑥2
𝑥𝑜 −𝑥1 𝑥0 −𝑥2 𝑥1 −𝑥0 𝑥1 −𝑥2 𝑥2 −𝑥0 𝑥2 −𝑥1

❑ Lagrange estimated error of the estimate


𝑅𝑛 = 𝑓 𝑥, 𝑥𝑛 , 𝑥𝑛−1 , … , 𝑥0 ς𝑛𝑖=0 𝑥 − 𝑥𝑖
3
Lagrange Interpolating Polynomials

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
Coefficients of an Interpolating Polynomial
a) Conventional form of polynomial
𝑓 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + ⋯ + 𝑎𝑛 𝑥 𝑛
b) Example: for a parabola, three data points are required 𝑥0 , 𝑓 𝑥0 , 𝑥1 , 𝑓 𝑥1 ,
𝑥2 , 𝑓 𝑥2
𝑓 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2
c) Substituting the data points to the above equations will yield
𝑓 𝑥0 = 𝑎0 + 𝑎1 𝑥0 + 𝑎2 𝑥0 2
𝑓 𝑥1 = 𝑎0 + 𝑎1 𝑥1 + 𝑎2 𝑥1 2
𝑓 𝑥2 = 𝑎0 + 𝑎1 𝑥2 + 𝑎2 𝑥2 2
4
Inverse Interpolation

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
❑ Example:
1
𝑓 𝑥 =𝑥
❑ An alternative strategy is to fit an nth-order interpolating polynomial, 𝑓𝑛 𝑥 , to the
original data (that is, with 𝑓 𝑥 versus 𝑥). I most cases, because the x’s are evenly
spaced, this polynomial will not be ill-conditioned. The answer to the problem
then amounts to finding the value of x that makes this polynomial equal to the
given 𝑓 𝑥 . Thus, the interpolation problem reduces to a roots problem.
❑ Interpolation with equally spaced data – relevant to the derivation of numerical
integration formulas
❑ Extrapolation – is the process of estimating a value of 𝑓 𝑥 that lies outside the
range of known base points, 𝑥0 , 𝑥1 , … , 𝑥𝑛 .
5
Example 5

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
Use a Lagrange interpolating polynomial of the first and second order to
evaluate ln 2 based on the data given below.

𝑥0 = 1 𝑓 𝑥0 = 0

𝑥1 = 4 𝑓 𝑥1 = 1.386294361

𝑥2 = 6 𝑓 𝑥2 = 1.791759469
6
Solution:

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
a) The first-order polynomial can be used to obtain the estimate at 𝑥 = 2
𝑥−𝑥1 𝑥−𝑥0
𝑓1 𝑥 = 𝑥 𝑓 𝑥0 + 𝑥 𝑓 𝑥1
𝑜 −𝑥1 1 −𝑥0
2−4 2−1
𝑓1 𝑥 = 0 + 1.386294361
1−4 4−1
𝒇𝟏 𝒙 = 𝟎. 𝟒𝟔𝟐𝟎𝟗𝟖𝟏𝟐𝟎𝟒 Answer
b) In similar fashion, the second-order polynomial is developed as
𝑥−𝑥1 𝑥−𝑥2 𝑥−𝑥0 𝑥−𝑥2 𝑥−𝑥0 𝑥−𝑥1
𝑓2 𝑥 = 𝑓 𝑥0 + 𝑓 𝑥1 + 𝑓 𝑥2
𝑥𝑜 −𝑥1 𝑥0 −𝑥2 𝑥1 −𝑥0 𝑥1 −𝑥2 𝑥2 −𝑥0 𝑥2 −𝑥1
2−4 2−6 2−1 2−6 2−1 2−4
𝑓2 𝑥 = 0 + 1.386294361 + 1.791759469
1−4 1−6 4−1 4−6 6−1 6−4
𝒇𝟐 𝒙 = 𝟎. 𝟓𝟔𝟓𝟖𝟒𝟒𝟑𝟒𝟔𝟗 Answer
❖ Solve the same problem using Newton’s interpolating polynomial and
compare the results.
7
SPLine Interpolation

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
In the interpolation of nth-order polynomials, 𝑛 + 1 data
points are used. 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.
8
Linear SPLines

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
The simplest connection between two points is a straight line. The first-order splines
for a group of ordered data points can be defined as a set of linear functions,

𝑓 𝑥 = 𝑓 𝑥0 + 𝑚0 𝑥 − 𝑥0 𝑥0 ≤ 𝑥 ≤ 𝑥1
𝑓 𝑥 = 𝑓 𝑥1 + 𝑚1 𝑥 − 𝑥1 𝑥1 ≤ 𝑥 ≤ 𝑥2
⋮ ⋮
⋮ ⋮
⋮ ⋮
𝑓 𝑥 = 𝑓 𝑥𝑛−1 + 𝑚𝑛−1 𝑥 − 𝑥𝑛−1 𝑥𝑛−1 ≤ 𝑥 ≤ 𝑥𝑛
9
Linear SPLines

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
where mi is the slope of the straight line connecting the points:
𝑓 𝑥𝑖+1 − 𝑓 𝑥𝑖
𝑚𝑖 =
𝑥𝑖+1 − 𝑥𝑖
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 is used to determine the function value within the interval.
The method is obviously identical to linear interpolation.
10
Example 6

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
Fit the data in the table with first-order splines. Evaluate the function at 𝑥 = 5.

𝑥 3.0 4.5 7.0 9.0


𝑓 𝑥 2.5 1.0 2.5 0.5

Solution:
The data can be used to determine the slopes between points. For example, for
the interval 𝑥 = 4.5 to 𝑥 = 7., the slope can be computed as
2.5−1
𝑚 = 7−4.5 = 0.60

The slopes for the other intervals can be computed, and the resulting first-order
splines are plotted in the figure below. The value at 𝑥 = 5 is 1.3
11

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
𝒙 𝒇(𝒙) First-Order Spline
𝒎 3
2.5
3 2.5 2

f(x)
1.5
4.5 1 -1 1
0.5
7 2.5 0.6 0
0 2 4 6 8 10
9 0.5 -1 x
12
Quadratic Splines

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
To ensure that the 𝑚𝑡ℎ derivatives are continuous at the knots, a spline of at least
𝑚 + 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.

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
𝑓1 𝑥 = 𝑎1 𝑥 2 + 𝑏1 𝑥 + 𝑐1
13
Quadratic Splines

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
The figure above will help clarify the
notation. For 𝑛 + 1 data points (𝑖 =
0,1,1, … , 𝑛) , there are n intervals and,
consequently, 3n unknown constants
the 𝑎′ 𝑠, 𝑏′ 𝑠 and 𝑐′𝑠 to evaluate.
Therefore, 3n equations or conditions
are required to evaluate the unknowns.
14
Quadratic Splines

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
1. The function values of adjacent 2. The first and last functions must
polynomials must be equal at the pass through the end points. This
interior knots. This condition can be adds two additional equations:
represented as
𝑎1 𝑥02 + 𝑏1 𝑥0 + 𝑐1 = 𝑓 𝑥0
2
𝑎𝑖−1 𝑥𝑖−1 + 𝑏𝑖−1 𝑥𝑖−1 + 𝑐𝑖−1 = 𝑓 𝑥𝑖−1
𝑎𝑛 𝑥𝑛2 + 𝑏𝑛 𝑥𝑛 + 𝑐𝑛 = 𝑓 𝑥𝑛
𝑎𝑖 𝑥𝑖2 + 𝑏𝑖 𝑥𝑖 + 𝑐𝑖 = 𝑓 𝑥𝑖−1
for a total of 2𝑛 − 2 + 2 = 2𝑛
for 𝑖 = 2 to 𝑛. Because only interior knots conditions.
are used. The two equations above
each provide 𝑛 − 1 conditions for a total
of 2𝑛 − 2 conditions.
15
Quadratic Splines

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
3. The first derivative s at the interior knots must be equal. The first derivative of
the polynomial equation is:
𝑓′ 𝑥 = 2𝑎𝑥 + 𝑏
Therefore, the condition can be represented generally as
2𝑎𝑖−1 𝑥𝑖−1 + 𝑏𝑖−1 = 2𝑎𝑖 𝑥𝑖 + 𝑏𝑖
for 𝑖 = 2 𝑡𝑜 𝑛. This provides another 𝑛 − 1 conditions for a total of 2𝑛 + 𝑛 − 1 =
3𝑛 − 1. Because we have 3𝑛 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 complete the constants.
Although there are number of different choices that can be made, we select
the following:
16
Quadratic Splines

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
4. Assume that the second derivative is zero at the first point. Because
the second derivative of the polynomial equation is 2𝑎, this condition
can be expressed mathematically as
𝑎1 = 0
The visual interpretation of this condition is that the first two points will
be connected by a straight line.
17
Example 7

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
Fit quadratic splines to the same data 2
𝑎𝑖−1 𝑥𝑖−1 + 𝑏𝑖−1 𝑥𝑖−1 + 𝑐𝑖−1 = 𝑓 𝑥𝑖−1
used in Example 6. Use the results to
estimate the value at 𝑥 = 5. 𝑎𝑖 𝑥𝑖2 + 𝑏𝑖 𝑥𝑖 + 𝑐𝑖 = 𝑓 𝑥𝑖−1
𝑥 3.0 4.5 7.0 9.0 20.25𝑎1 + 4.5𝑏1 + 𝑐1 = 1.0
𝑓 𝑥 2.5 1.0 2.5 0.5 20.25𝑎2 + 4.5𝑏2 + 𝑐2 = 1.0
Solution: 49𝑎2 + 7𝑏2 + 𝑐2 = 2.5
For the present problem, we have four
49𝑎3 + 7𝑏3 + 𝑐3 = 2.5
data points and 𝑛 = 3 intervals.
Therefore, 3 3 = 9 unknowns must be
determined. Using the equations below
will yield 2 3 − 2 = 4 conditions.
18
Passing the first and last functions through the initial and final values
adds 2 more

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
𝑎1 𝑥02 + 𝑏1 𝑥0 + 𝑐1 = 𝑓 𝑥0
𝑎𝑛 𝑥𝑛2 + 𝑏𝑛 𝑥𝑛 + 𝑐𝑛 = 𝑓 𝑥𝑛
9𝑎1 + 3𝑏1 + 𝑐1 = 2.5
81𝑎3 + 9𝑏3 + 𝑐3 = 0.5
Continuity of derivatives creates an additional 3 − 1 = 2 conditions.
2𝑎𝑖−1 𝑥𝑖−1 + 𝑏𝑖−1 = 2𝑎𝑖 𝑥𝑖−1 + 𝑏𝑖
9𝑎1 + 3𝑏1 = 9𝑎2 + 3𝑏2
14𝑎2 + 𝑏2 = 14𝑎3 + 𝑏3
Finally, the last condition specifies that 𝑎1 = 0. Because this equation specifies 𝑎1 19
exactly, the problem reduces to solving eight simultaneous equations. These

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
conditions can be expressed in matrix form as

4.5 1 0 0 0 0 0 0 𝑏1 1

0 0 20.25 4.5 1 0 0 0 𝑐1 1

0 0 49 7 1 0 0 0 𝑎2 2.5

0 0 0 0 0 49 7 1 𝑏2 2.5
=
3 1 0 0 0 0 0 0 𝑐2 2.5

0 0 0 0 0 81 9 1 𝑎3 0.5

1 0 -9 -1 0 0 0 0 𝑏3 0

0 0 14 1 0 -14 -1 0 𝑐3 0
These equations can be solve using techniques in Chapter 3, with the results: 20
−1
𝐴 𝑥 = 𝐵 𝐴 𝐵 = 𝑥

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
𝑎1 = 0 𝑎2 = 0.64 𝑎3 = −1.6 𝑏1 = −1 𝑏2 = −6.76
𝑏3 = 24.6 𝑐1 = 5.5 𝑐2 = 18.46 𝑐3 = −91.3

0.67 0.00 0.00 0.00 -0.67 0.00 0.00 0.00 1 𝑏1

-2.00 0.00 0.00 0.00 3.00 0.00 0.00 0.00 1 𝑐1

-0.27 -0.16 0.16 0.00 0.27 0.00 0.40 0.00 2.5 𝑎2

3.07 1.44 -1.44 0.00 -3.07 0.00 -4.60 0.00 2.5 𝑏2


=
-8.40 -2.24 3.24 0.00 8.40 0.00 12.60 0.00 2.5 𝑐2

0.33 0.40 -0.40 -0.25 -0.33 0.25 -0.50 0.50 0.5 𝑎3

-5.33 -6.40 6.40 3.50 5.33 -3.50 8.00 -8.00 0 𝑏3

21.00 25.20 -25.20 -11.25 -21.00 12.25 -31.50 31.50 0 𝑐3


21

Which can be substituted into the original quadratic equations to develop the

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
following relationships for each interval:

𝑓1 𝑥 = −𝑥 + 5.5 3.0 ≤ 𝑥 ≤ 4.5

𝑓2 𝑥 = 0.64𝑥 2 − 6.76𝑥 + 18.46 4.5≤ 𝑥 ≤ 7.0

𝑓3 𝑥 = −1.6𝑥 2 + 24.6𝑥 − 91.3 7.0≤ 𝑥 ≤ 9.0

When we use 𝑓2 , the prediction for 𝑥 = 5 is, therefore,


2
𝑓2 5 = 0.64 5 − 6.76 5 + 18.46 = 0.66

The total spline is depicted in the figure below. 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.
MathEng5-M - Numerical Solutions to CE Problems
22

12/6/2021
10
8
Quadratic Spline

6
x
4
2
0
2.5

1.5

0.5

0
3

1
f(x)
23
Cubic Splines

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
The objective in cubic splines is to derive a third-order polynomial for each
interval between knots, as in 𝑓𝑖 𝑥 = 𝑎𝑖 𝑥 3 + 𝑏𝑖 𝑥 2 + 𝑐𝑖 𝑥 + 𝑑𝑖
Thus, for 𝑛 + 1 data points 𝑖 = 0,1,2, … , 𝑛 , there are 𝑛 intervals and, consequently
4𝑛 unknown constants to evaluate. Just as for quadratic splines, 4𝑛 conditions are
required to evaluate the unknowns. These are:
1. The function values must be equal at the interior knots 2𝑛 − 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 𝑛 − 1 conditions .
4. The second derivatives at the interior knots must be equal 𝑛 − 1 conditions .
5. The second derivatives at the end knots are zero 2 conditions .
24
Cubic Splines

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
The visual interpretation of condition 5 is that the function becomes a straight line
at 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. 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 4𝑛 equations required to
solve for the 4𝑛 coefficients. Whereas it is certainly possible to develop cubic
splines in this fashion, an alternative solution that requires only 𝑛 − 1 equations was
derived as shown below. The derivation is somewhat less straightforward than
that for quadratic splines, the gain in efficiency is well worth the effort.
Derivation of Cubic SPLines (Cheney and Kincaid, 1985) 25

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
❑ The first step in the derivation is based on the observation that because each
pair of knots is connected by a cubic, the second derivative within each
interval is a straight line. The second derivative can be represented by a first-
order Lagrange interpolating polynomial.
𝑓𝑖 𝑥 = 𝑎𝑖 𝑥 3 + 𝑏𝑖 𝑥 2 + 𝑐𝑖 𝑥 + 𝑑𝑖 eq. B18.35
𝑥−𝑥𝑖 𝑥−𝑥𝑖−1
𝑓𝑖" 𝑥 = 𝑓𝑖" 𝑥𝑖−1 + 𝑓𝑖" 𝑥𝑖 eq. B18.3.1
𝑥𝑖−1 −𝑥𝑖 𝑥𝑖 −𝑥𝑖−1

❑ Integrate eq. 18.3.1 twice invoking the function equality condition 𝑓 𝑥 =


𝑓 𝑥𝑖−1 at 𝑥𝑖−1 and 𝑓 𝑥 = 𝑓 𝑥𝑖 at 𝑥𝑖 .
𝑓𝑖" 𝑥𝑖−1 3 𝑓𝑖" 𝑥𝑖 3 𝑓 𝑥𝑖−1
𝑓𝑖 𝑥 = 𝑥𝑖 − 𝑥 + 𝑥 − 𝑥𝑖−1 +ቂ −
6 𝑥𝑖 −𝑥𝑖−1 6 𝑥𝑖 −𝑥𝑖−1 𝑥𝑖 −𝑥𝑖−1
𝑓" 𝑥𝑖−1 𝑥𝑖 −𝑥𝑖−1 𝑓 𝑥𝑖 𝑓" 𝑥𝑖 𝑥𝑖 −𝑥𝑖−1
ቃ 𝑥𝑖 − 𝑥 + − 𝑥 − 𝑥𝑖−1 eq. B18.3.2
6 𝑥𝑖 −𝑥𝑖−1 6
Derivation of Cubic SPLines (Cheney and Kincaid, 1985) 26

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
❑ The second derivative can be evaluated by invoking the condition that the
first derivatives at the knots must be continuous:
𝑓𝑖′ 𝑥𝑖 = 𝑓𝑖+1

𝑥𝑖 eq. B18.3.3
❑ Differentiating eq. 18.3.2 both for 𝑖 − 1 𝑡ℎ and 𝑖 𝑡ℎ intervals:
6
xi − xi−1 f" xi−1 +2 xi+1 − xi−1 f" xi + xi+1 − xi f" 𝑥𝑖+1 = x ሾ𝑓 xi+1 −
i+1 −xi
6
𝑓 xi ሿ + x −x 𝑓 xi−1 − 𝑓 xi eq. B18.3.3
i i−1

❑ If eq. B18.3.4 is written for all interior knots, 𝑛 − 1 simultaneous equations result
with 𝑛 = 1 unknown second derivative. However, because this is a natural
cubic spline, the second derivatives at the end knots are zero and the
problems reduces to 𝑛 − 1 equations with 𝑛 − 1 unknowns.
Derivation of Cubic SPLines (Cheney and Kincaid, 1985) 27

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
❑ The derivation results in the following cubic equation for each interval
𝑓𝑖" 𝑥𝑖−1 3 𝑓𝑖" 𝑥𝑖 3 𝑓 𝑥𝑖−1 𝑓" 𝑥𝑖−1 𝑥𝑖 −𝑥𝑖−1
𝑓𝑖 𝑥 = 6 𝑥𝑖 −𝑥𝑖−1
𝑥𝑖 − 𝑥 + 6 𝑥 −𝑥 𝑥 − 𝑥𝑖−1 + 𝑥𝑖 −𝑥𝑖−1
− 6
𝑥𝑖 − 𝑥 +
𝑖 𝑖−1
𝑓 𝑥𝑖 𝑓" 𝑥𝑖 𝑥𝑖 −𝑥𝑖−1
𝑥𝑖 −𝑥𝑖−1
− 6
𝑥 − 𝑥𝑖−1 eq. 18.36

❑ This equation contains only two unknowns – the second derivatives at the end of
each interval. These unknowns ca be evaluated using the following equation:
6
xi − xi−1 f" xi−1 +2 xi+1 − xi−1 f" xi + xi+1 − xi f" 𝑥𝑖+1 = x 𝑓 xi+1 − 𝑓 xi +
i+1 −xi
6
xi −xi−1
𝑓 xi−1 − 𝑓 xi eq. 18.37

If this equation is written for all the interior knots, 𝑛 − 1 simultaneous equations
result with 𝑛 − 1 unknowns.
28
Example 8

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
Fit cubic splines to the same data used in
Example 6 and 7. Utilize the results to 𝐱 𝐟(𝐱)
estimate the value at 𝑥 = 5.
3 2.5
Solution:
4.5 1
The first solution is to employ Equation
18.37 to generate the set of simultaneous 7 2.5
equations that will be utilized to
determine the second derivatives at the
knots. For the first interior knot, the
following data is used:
29
These values can be substituted into Equation 18.37 to yield
6 6

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
4.5 − 3 𝑓 3 +2 7−3 f 4.5 + 7 − 4.5 𝑓" 7 = 2.5 − 1 + 2.5 − 1
7−4.5 4.5−3
Because of the natural spline condition, 𝑓" 3 = 0, and the equations reduces to
8𝑓" 4.5 +2.5f" 7 = −9.6
In a similar fashion, Equation 18.37 can be applied to the second interior point to
give
2.5𝑓" 4.5 +9f" 7 = −9.6
These two equations can be solved simultaneously for
𝑓" 4.5 = 1.67909 𝑓" 7 = −1.53308
These values can then be substituted into Equation 18.36, along with the values for
the 𝑥′𝑠 and the 𝑓 𝑥 ′𝑠, to yield
1.67909 3 2.5 1 1.67909 4.5−3
𝑓1 𝑥 = 6 𝑥−3 + 4.5−3 4.5 − 𝑥 + − 𝑥−3
4.5−3 4.5−3 6
30
Or

12/6/2021
MathEng5-M - Numerical Solutions to CE Problems
𝑓1 𝑥 = 0.186566 𝑥 − 3 3 + 1.666667 4.5 − 𝑥 + 0.246894 𝑥 − 3
This equation is the cubic spline for the first interval. Similar substitutions can be
made to develop the equations for the second and the third intervals:
𝑓2 𝑥 = 0.111939 7 − 𝑥 3 − 0.102205 𝑥 − 4.5 3 − 0.29962 7 − 𝑥 + 1.638783 𝑥 − 4.5
And: 𝑓3 𝑥 = −0.127757 9 − 𝑥 3
+ 1.761027 9 − 𝑥 + 0.25 𝑥 − 7
The three equations can then be employed to compute values within each
interval. For example, the value at 𝑥 = 5, which falls within the second interval, is
calculated as
3 3
𝑓2 5 = 0.111939 7 − 5 − 0.102205 5 − 4.5 − 0.29962 7 − 5 + 1.638783 5 − 4.5
𝒇𝟐 𝟓 = 𝟏. 𝟏𝟎𝟐𝟖𝟖𝟔
MathEng5-M - Numerical Solutions to CE Problems
31

12/6/2021

You might also like