• No results found

Final Year Project Splines interpolation with MATLAB function pchip

N/A
N/A
Protected

Academic year: 2021

Share "Final Year Project Splines interpolation with MATLAB function pchip"

Copied!
23
0
0

Loading.... (view fulltext now)

Full text

(1)

1

Final Year Project

Splines interpolation with MATLAB function pchip

XU JIAYI 17250498

Financial Risk Management of Mathematics Department of Hong Kong Baptist University

Supervisor Dr. Mark Lau

Mathematics Department of Hong Kong Baptist University

22-1-2021

(2)

2

ACKNOWLEDGEMENT

All the work in this thesis were my original work and were carried out by myself under Dr. Mark Lau’s supervision. I want to express my deep gratitude to Dr. Mark Lau, my thesis supervisors, for his patient guidance, enthusiastic encouragement and useful critiques of this thesis work and his advice and assistance in keeping my progress on schedule. I would also like to thank all teachers in the Mathematics Department, from devoted teaching and enlightening lectures I have learnt a lot in the past few years.

Without their effort, I would not get the prerequisite knowledge of writing this thesis.

Finally, I wish to thank my parents for their support and encouragement throughout my study.

(3)

3

OUTLINE

1. Introduction

1.1 Background and meaning.

1.2 Research status and the work of this thesis.

2. Spline Interpolation

2.1 What is Interpolation?

2.2 What is Spline Interpolation?

3. Piecewise Cubic Hermite Interpolating Polynomial

3.1 MATLAB’s implementation of pchip algorithm.

3.1.1 Establishment of the interpolation function.

3.1.2 The derivative calculation at interior point.

3.1.3 The derivatives at the endpoints.

3.2 Merits and Shortcomings of the algorithm.

3.2.1 Two-point cubic Hermite interpolation.

3.2.2 The remainder of cubic Hermite interpolating polynomial.

3.2.3 Merits and Shortcomings of the algorithm and example.

4. Conclusion

(4)

4

ABSTRACT

Using functions to express the quantitative relationship between variables is widely used in various disciplines. Still, in practical problems, it is often through experiments, observations, and calculations that the function’s function value at some points is obtained. Finding an approximate expression of a function that meets the accuracy requirements and is easy to use through these discrete data is a frequently encountered problem.

The method we solve for this kind of problem is an interpolation, and the most commonly used and simplest interpolation method is a polynomial interpolation. Of course, the approximate expression obtained by the interpolation method must satisfy the interpolation condition, assuming that the value of the independent variable and the function value of n+1 points are given, the approximate function must pass through these n+1 points. From a geometric point of view, polynomial interpolation is to seek the approximation of n-th order algebraic curve 𝑦 = 𝑃𝑛(𝑥) through n+1 points as 𝑓(𝑥).

However, as the number of interpolation nodes increases, the approximation effect of high-order interpolation polynomials is not ideal. According to a large number of experiments, the Runge phenomenon occurs when high-order polynomial interpolation is performed. Therefore, to solve such problems, we can reduce the error by narrowing the interpolation interval.

Nevertheless, when interpolating with a linear function on each cell, it has good convergence but insufficient smoothness. Therefore, this thesis will introduce Piecewise Cubic Hermite Interpolating Polynomial and study how Piecewise Cubic Hermite Interpolating Polynomial is implemented in MATLAB. Furthermore, discuss its advantages and disadvantages.

Key Words: Piecewise interpolation, Piecewise cubic interpolation, Piecewise Cubic Hermite Interpolating Polynomial, Matlab Pchip.m, Discrete data first- order derivation.

(5)

5

1. Introduction

1.1 Background and meaning

In industrial production, scientific research and business analysis, discrete data obtained through experiments or collected are often needed to construct approximate functional relationships between variables. Interpolate the continuous function based on discrete data so that this continuous curve passes through all given discrete data points.

Interpolation is an essential method of approximating discrete functions. People can use it to estimate the approximate value of the function at other points through the function’s value at a finite number of points. People usually construct different interpolation functions according to the starting point of the problem and the various requirements.

Now the more widely used interpolation function methods are Lagrange interpolation polynomial and Newton interpolation polynomial. Some more complicated interpolation function constructions are relatively rare. This thesis will study a more complicated interpolation function called “Piecewise Cubic Hermite Interpolating Polynomial”.

1.2 Research status and the work of this thesis

The interpolation method has a long history. Since the interpolation method was put forward, it has been widely used. In terms of interpolation functions, people have been continuously looking for convenient and straightforward new forms. According to the different problems we need to solve, the function’s structure is continually improving, such as fractal interpolation, Akima interpolation, density interpolation, and so on. And some scholars have proposed the concept of Exponential interpolation.

The cubic spline interpolation function constructs a piecewise function according to a given function table and requires the built function to pass through a given point and have first and second derivatives.

For a function 𝑓(𝑥), we often know its function value at some points, and its derivative value at these points. The interpolation function 𝑃(𝑥) at this time naturally requires not only the function value of 𝑓(𝑥) at these points, but also the derivative value of 𝑃(𝑥) at these points. This is the Hermitian interpolation problem, also known as the interpolation problem with derivatives. From a geometric point of view, the polynomial curve sought for this kind of interpolation must not only pass through the known point group on the plane, but also "close" to the original curve at these points (or part of them), that is, they have the same slope. The Hermite interpolation polynomial has a higher smooth approximation requirement than the general polynomial interpolation.

Cubic Hermite interpolation is a spline where each piece is a third-degree polynomial specified in Hermite form, by its values and first derivatives at the corresponding

(6)

6

domain interval’s endpoints. This thesis is to study the Piecewise Cubic Hermite Interpolating Polynomial, and the thesis did the following work:

a) Understand and analyze Spline Interpolation.

b) Understand the algorithm of pchip in MATLAB.

c) Explain the implementation process of the algorithm.

d) Summarize the advantages and disadvantages of pchip and give corresponding examples.

(7)

7

2. Spline Interpolation

2.1 What is Interpolation?

𝑥 𝑥0 𝑥1 ⋯ ⋯ 𝑥𝑖 ⋯ ⋯ 𝑥𝑛

𝑦 = 𝑓(𝑥) 𝑦0 𝑦1 ⋯ ⋯ 𝑦𝑖 ⋯ ⋯ 𝑦𝑛

Table 1 Function table for a given 𝑦 = 𝑓(𝑥).

Given a continuous function 𝑦 = 𝑓(𝑥) function table, find a polynomial 𝑝𝑛(𝑥) of degree ≤ 𝑛 . 𝑝𝑛(𝑥) = 𝑎0+ 𝑎1𝑥 + ⋯ + 𝑎𝑛𝑥𝑛 (𝑎𝑖 are all real numbers ) and satisfy the following formula

𝑓(𝑥𝑖) = 𝑝𝑛(𝑥𝑖), (𝑖 = 0,1, ⋯ , 𝑛) (2.1) Definition 2.1:

(1) If the polynomial 𝑝𝑛(𝑥) that satisfies the interpolation condition (2.1) exists, call 𝑝𝑛(𝑥) the interpolation polynomial of 𝑓(𝑥), 𝑥𝑖(𝑖 = 0,1, ⋯ , 𝑛) is called the node, and 𝑓(𝑥) is called the interpolated function.

(2) The method of finding interpolation polynomials is called interpolation.

We are familiar with the commonly used interpolation methods including, Newton interpolation, Lagrange interpolation, Hermite interpolation, stepwise linear interpolation, cubic spline interpolation, and so on. The principle is to use a simple polynomial to approximate the original function and study some of the original function properties by examining the polynomial properties.

2.2 What is Spline Interpolation?

A so-called spline is originally a drawing tool in engineering design. It is a kind of elastic slender wooden strip used to describe the smooth contour curve in the manufacturing process of airplane or ship. When using, use Hot Briquetted Iron to fix it on some given value points, allow it to bend naturally in other places, and adjust it slightly to make the spline have a good shape (the joints of each segment are smooth), Then draw a curve along the spline, called a spline curve, which is made up of piecewise cubic curves. At the connection point, the function itself is continuous, but its first and second derivatives are also continuous. The mathematical model abstracted from this is called the spline model.

(8)

8 Image 2.1

The given interval [a, b] is divided into 𝑎 = 𝑥0 < 𝑥1 < ⋯ < 𝑥𝑛 = 𝑏, If the function 𝑆(𝑥) satisfies:

(1) In each cell [𝑥𝑖, 𝑥𝑖+1] (𝑖 = 0,1, ⋯ , 𝑛), 𝑆(𝑥) is a polynomial of degree m.

(2) 𝑆(𝑥) has a continuous derivative of order 𝑚 − 1 on [a, b].

Then call 𝑆(𝑥) the m-th order spline function about the above division.

Image 2.2

Obviously, according to this definition, the curve is a spline function. The graph drawn with "spline" is a cubic spline function curve, which is also the most used spline function. So, how many conditions are needed to determine a cubic spline function?

From the above definition (1), it can be seen that 𝑆(𝑥) is a cubic polynomial in each cell [𝑥𝑖, 𝑥𝑖+1], so 4 undetermined constants need to be determined. There are n cells in total, so 4𝑛 parameters should be determined. According to the condition (2) in the definition, 𝑆(𝑥) should have a second-order continuous derivative at 𝑛 − 1 interior points, which satisfies the requirement:

{

𝑆(𝑥𝑖− 0) = 𝑆(𝑥𝑖 + 0) 𝑆(𝑥𝑖− 0) = 𝑆(𝑥𝑖 + 0) 𝑆′′(𝑥𝑖− 0) = 𝑆′(𝑥𝑖 + 0)

𝑖 = 1,2, ⋯ , 𝑛 − 1 There are 3(𝑛 − 1) conditions. Therefore, to determine a cubic spline function, an

(9)

9

additional 4𝑛 − 3(𝑛 − 1) = 𝑛 + 3 conditions need to be added.

Use spline function for interpolation, that is, take the interpolation function as a spline function, which is called spline interpolation. For example, piecewise linear interpolation is a spline interpolation.

Given that the value 𝑦𝑗 = 𝑓(𝑥𝑗) of the function 𝑦 = 𝑓(𝑥) on n+1 nodes 𝑎 = 𝑥0 <

𝑥1 < ⋯ < 𝑥𝑛 = 𝑏 in the interval [a, b], find the interpolation function 𝑆(𝑥) to satisfy:

(1) 𝑆(𝑥𝑗) = 𝑦𝑗(𝑗 = 0,1, ⋯ 𝑛).

(2) 𝑆(𝑥) is a third-degree polynomial in each cell [ 𝑥𝑗, 𝑥𝑗+1 ] (𝑗 = 0,1, ⋯ , 𝑛 − 1) , denoted as 𝑆𝑗(𝑥).

(3) 𝑆(𝑥) is second-order continuously differentiable on [a,b].

𝑆(𝑥) is called the cubic spline interpolation function of 𝑓(𝑥), which passes through the above-given point and is a second-order continuous and derivable piecewise cubic polynomial function.

Image 2.3

By definition in (1), 𝑛 + 1 interpolation condition is added here, and two additional requirements are needed to determine 𝑆(𝑥) . Usually, according to the problem’s specific situation, conditions are given at the two endpoints of the interval, called boundary conditions. There are three commonly used boundary conditions as follows:

(1) Derivative value at given end points 𝑆(𝑎) = 𝑦0, 𝑆(𝑏) = 𝑦𝑛.

(10)

10

In particular, when 𝑦0 = 𝑦𝑛 = 0, the spline curve is horizontal at the endpoints.

(2) Given the second derivative 𝑆′′(𝑎) = 𝑦′′0, 𝑆′′(𝑏) = 𝑦′′𝑛 at the two endpoints.

In particular, when 𝑦′′0 = 𝑦′′𝑛 = 0 is called the natural boundary.

(3) If 𝑓(𝑥) is a periodic function with b-a as the period, then 𝑆(𝑥) should also have a periodic function with the same period and satisfy 𝑆(𝑎 + 0) = 𝑆(𝑏 − 0), 𝑆′′(𝑎 + 0) = 𝑆′′(𝑏 − 0) at the end point.

(11)

11

3. Piecewise Cubic Hermite Interpolating Polynomial

3.1 MATLAB’s implementation of pchip algorithm

In this section, according to the general expression of cubic interpolation, the coefficients of each cell’s subterms are obtained during the segmented cubic interpolation. The analysis found the coefficients of the cubic, quadratic, and first-order terms are all related to the first-order derivative value at the endpoints between the cells, so the first-order derivative value at the endpoints needs to be required. The MATLAB Pchip.m file gives the method. According to the code of Pchip.m and references, the formula for finding the first derivative value is concluded.

3.1.1 Establishment of the interpolation function

Assuming that the function 𝑦 = 𝐹(𝑥) is defined on the interval [a, b], and the value 𝑦0, 𝑦1, ⋯ , 𝑦𝑛 at the discrete point 𝑎 = 𝑥0 < 𝑥1 < ⋯ < 𝑥𝑛 is known, it is now required to find the piecewise interpolation function 𝑓(𝑥). The interpolation function 𝑓(𝑥) is a third-degree polynomial on each cell [𝑥𝑘, 𝑥𝑘+1], 𝑘 = 0, 1, 2, ⋯ , 𝑛 − 1. In the [𝑥𝑘, 𝑥𝑘+1] segment interval, 𝑓(𝑥) can be expressed as follows:

𝑓(𝑥) = 𝑎(𝑥 − 𝑥𝑘)3+ 𝑏(𝑥 − 𝑥𝑘)2+ 𝑐(𝑥 − 𝑥𝑘) + 𝑑 (3.1) Let 𝑓(𝑥) be the first derivative, then

𝑓(𝑥) = 3𝑎(𝑥 − 𝑥𝑘)2+ 2𝑏(𝑥 − 𝑥𝑘) + 𝑐 From the values at the endpoints 𝑥𝑘 and 𝑥𝑘+1, we can get:

{

𝑓(𝑥𝑘) = 𝑑 𝑓(𝑥𝑘) = 𝑐

𝑓(𝑥𝑘+1) = 𝑎(𝑥𝑘+1− 𝑥𝑘)3+ 𝑏(𝑥𝑘+1− 𝑥𝑘)2+ 𝑐(𝑥𝑘+1− 𝑥𝑘) + 𝑑 𝑓(𝑥𝑘+1) = 3𝑎(𝑥𝑘+1− 𝑥𝑘)2+ 2𝑏(𝑥𝑘+1− 𝑥𝑘) + 𝑐

Sort out the binary linear equations about a and b

{𝑎(𝑥𝑘+1− 𝑥𝑘)3+ 𝑏(𝑥𝑘+1− 𝑥𝑘)2 = 𝑓(𝑥𝑘+1) − 𝑓(𝑥𝑘) − 𝑓′(𝑥𝑘)(𝑥𝑘+1− 𝑥𝑘) 3𝑎(𝑥𝑘+1− 𝑥𝑘)2+ 2𝑏(𝑥𝑘+1− 𝑥𝑘) = 𝑓(𝑥𝑘+1) − 𝑓′(𝑥𝑘)

{𝑎(𝑥𝑘+1− 𝑥𝑘)2+ 𝑏(𝑥𝑘+1− 𝑥𝑘) =𝑓(𝑥𝑘+1) − 𝑓(𝑥𝑘)

𝑥𝑘+1− 𝑥𝑘 − 𝑓′(𝑥𝑘) 3𝑎(𝑥𝑘+1− 𝑥𝑘)2+ 2𝑏(𝑥𝑘+1− 𝑥𝑘) = 𝑓(𝑥𝑘+1) − 𝑓′(𝑥𝑘)

(12)

12 Where 𝑓(𝑥𝑘+1)−𝑓(𝑥𝑘)

𝑥𝑘+1−𝑥𝑘 is the difference quotient at 𝑥𝑘 , denoted as 𝛿𝑘 . 𝑓(𝑥𝑘) is the first derivative at 𝑥𝑘, denoted as 𝑑𝑘, the above formula can be expressed as:

{ 𝑎(𝑥𝑘+1− 𝑥𝑘)2 + 𝑏(𝑥𝑘+1− 𝑥𝑘) = 𝛿𝑘− 𝑑𝑘

3𝑎(𝑥𝑘+1− 𝑥𝑘)2+ 2𝑏(𝑥𝑘+1− 𝑥𝑘) = 𝑑𝑘+1− 𝛿𝑘+ 𝛿𝑘− 𝑑𝑘 Assume 𝜖1 = 𝛿𝑘−𝑑𝑘

𝑥𝑘+1−𝑥𝑘, 𝜖2 = 𝑑𝑘+1−𝛿𝑘

𝑥𝑘+1−𝑥𝑘 , then

{ 𝑎(𝑥𝑘+1− 𝑥𝑘) + 𝑏 = 𝜖1 3𝑎(𝑥𝑘+1− 𝑥𝑘) + 2𝑏 = 𝜖1 + 𝜖2

{𝑎 = 𝜖2 − 𝜖1 𝑥𝑘+1− 𝑥𝑘 𝑏 = −𝜖2+ 2𝜖1 Let 𝑥𝑘+1− 𝑥𝑘 = ℎ𝑘, and get

{

𝑎 =

𝑑𝑘+1− 𝛿𝑘

𝑥𝑘+1− 𝑥𝑘 𝛿𝑘− 𝑑𝑘 𝑥𝑘+1− 𝑥𝑘

𝑥𝑘+1− 𝑥𝑘 =𝑑𝑘+1+ 𝑑𝑘− 2𝛿𝑘 𝑘2

𝑏 = −𝑑𝑘+1− 𝛿𝑘

𝑥𝑘+1− 𝑥𝑘+ 2 𝛿𝑘− 𝑑𝑘

𝑥𝑘+1− 𝑥𝑘 = −𝑑𝑘+1− 2𝑑𝑘− 3𝛿𝑘 𝑘

𝑐 = 𝑓(𝑥𝑘) = 𝑑𝑘 𝑑 = 𝑓(𝑥𝑘) = 𝑦𝑘

(3.2)

Where ℎ𝑘, 𝛿𝑘, 𝑦𝑘 are all known, the critical problem is to find the first derivative 𝑑𝑘 at 𝑥𝑘 and the first derivative 𝑑𝑘+1 at 𝑥𝑘+1.

3.1.2 Derivative calculation at interior point

According to the description of the pchipslopes function in the pchip.m file, the first derivative at the inner point (points other than 𝑥0 𝑎𝑛𝑑 𝑥𝑛 here) has the following rules.

(1) If the signs of the difference quotient 𝛿𝑘−1 and 𝛿𝑘 near the k-th node are opposite, or one of them is 0, the first derivative 𝑑𝑘 at that point is 0.

(13)

13 Image 3.1

Image 3.2

(2) If the signs of the difference quotient 𝛿𝑘−1 and 𝛿𝑘 near the k-th node are the same, then the first derivative 𝑑𝑘 at this point is equal to the weighted average of the left and right difference quotients.

Image 3.3

(14)

14 Assume ℎ𝑘 = 𝑥𝑘+1− 𝑥𝑘, ℎ𝑘+1= 𝑥𝑘+2− 𝑥𝑘+1 Difference quotient 𝛿𝑘 =𝑦𝑘+1−𝑦𝑘

𝑘 , 𝛿𝑘+1 =𝑦𝑘+2−𝑦𝑘+1

𝑘+1

Let ℎ𝑠𝑘 = ℎ𝑘+ ℎ𝑘+1, 𝑤𝑘1= 𝑘+ℎ𝑠𝑘

3ℎ𝑠𝑘 , 𝑤𝑘2 = 𝑘+1+ℎ𝑠𝑘

3ℎ𝑠𝑘

Image 3.4 𝛿 𝑚𝑎𝑥𝑘 = max(𝛿𝑘, 𝛿𝑘+1) , 𝛿 𝑚𝑖𝑛𝑘 = min(𝛿𝑘, 𝛿𝑘+1)

𝑑𝑘+1= 𝛿 𝑚𝑖𝑛𝑘

𝑤𝑘1 𝛿𝑘

𝛿 𝑚𝑎𝑥𝑘+ 𝑤𝑘2 𝛿𝑘+1 𝛿 𝑚𝑎𝑥𝑘

= 𝛿 𝑚𝑎𝑥𝑘 𝛿 𝑚𝑖𝑛𝑘

𝑤𝑘1𝛿𝑘+𝑤𝑘2𝛿𝑘+1= 3𝛿 𝑚𝑎𝑥𝑘 𝛿 𝑚𝑖𝑛𝑘(ℎ𝑘+ℎ𝑘+1)

(ℎ𝑘+2ℎ𝑘+1)𝛿𝑘+1+(2ℎ𝑘+ℎ𝑘+1)𝛿𝑘 If 𝛿𝑘 = 𝛿𝑘+1, then 𝛿 𝑚𝑎𝑥𝑘 = 𝛿 𝑚𝑖𝑛𝑘 = 𝛿𝑘 = 𝛿𝑘+1

If 𝛿𝑘 ≠ 𝛿𝑘+1, then 𝛿 𝑚𝑎𝑥𝑘 𝛿 𝑚𝑖𝑛𝑘 = 𝛿𝑘𝛿𝑘+1

𝑑𝑘+1 = 3𝛿𝑘𝛿𝑘+1(ℎ𝑘+ ℎ𝑘+1)

(ℎ𝑘+ 2ℎ𝑘+1)𝛿𝑘+1+ (2ℎ𝑘+ ℎ𝑘+1)𝛿𝑘

(3.3)

𝑑𝑘 = 3𝛿𝑘𝛿𝑘+1(ℎ𝑘− 1 + ℎ𝑘)

(2ℎ𝑘+ ℎ𝑘−1)𝛿𝑘+ (2ℎ𝑘−1+ ℎ𝑘)𝛿𝑘−1

(3.4)

Let (𝑥 − 𝑥𝑘)=𝑠, 𝑥𝑘+1− 𝑥𝑘 = ℎ𝑘, 𝑓(𝑥𝑘+1)−𝑓(𝑥𝑘)

𝑥𝑘+1−𝑥𝑘 = 𝛿𝑘 then we have

{

𝑎 =

𝑑𝑘+1− 𝛿𝑘

𝑥𝑘+1− 𝑥𝑘 𝛿𝑘− 𝑑𝑘 𝑥𝑘+1− 𝑥𝑘

𝑥𝑘+1− 𝑥𝑘 =𝑑𝑘+1+ 𝑑𝑘− 2𝛿𝑘 𝑘2

𝑏 = −𝑑𝑘+1− 𝛿𝑘

𝑥𝑘+1− 𝑥𝑘+ 2 𝛿𝑘− 𝑑𝑘

𝑥𝑘+1− 𝑥𝑘= −𝑑𝑘+1− 2𝑑𝑘− 3𝛿𝑘 𝑘

𝑐 = 𝑓(𝑥𝑘) = 𝑑𝑘 𝑑 = 𝑓(𝑥𝑘) = 𝑦𝑘 𝑑𝑘+1= 3𝛿𝑘𝛿𝑘+1(ℎ𝑘+ ℎ𝑘+1)

(ℎ𝑘+ 2ℎ𝑘+1)𝛿𝑘+1+ (2ℎ𝑘+ ℎ𝑘+1)𝛿𝑘 𝑑𝑘 = 3𝛿𝑘𝛿𝑘+1(ℎ𝑘− 1 + ℎ𝑘)

(2ℎ𝑘+ ℎ𝑘−1)𝛿𝑘+ (2ℎ𝑘−1+ ℎ𝑘)𝛿𝑘−1

(15)

15

𝑓(𝑥) = 𝑎𝑠3+ 𝑏𝑠2+ 𝑐𝑠 + 𝑑 3.1.3 The derivatives at the endpoints

According to the description of the pchipslopes function in the pchip.m file, the first- order derivative value at the endpoint uses a three-point formula that is not the midpoint and requires shape preservation. The procedure is derived as follows.

Through the quadratic interpolation polynomial of three points (𝑥0, 𝑦0), (𝑥1, 𝑦1), (𝑥2, 𝑦2), it can be expressed as

𝐿2(𝑥) =𝑦0(𝑥 − 𝑥1)(𝑥 − 𝑥2)

(𝑥0 − 𝑥1)(𝑥0 − 𝑥2)+𝑦1(𝑥 − 𝑥0)(𝑥 − 𝑥2)

(𝑥1− 𝑥0)(𝑥1− 𝑥2) +𝑦2(𝑥 − 𝑥0)(𝑥 − 𝑥1) (𝑥2− 𝑥0)(𝑥2 − 𝑥1) 𝐿2′(𝑥) = 𝑦0(2𝑥 − 𝑥1− 𝑥2)

(𝑥0− 𝑥1)(𝑥0− 𝑥2)+ 𝑦1(2𝑥 − 𝑥0 − 𝑥2)

(𝑥1 − 𝑥0)(𝑥1 − 𝑥2)+ 𝑦2(2𝑥 − 𝑥0− 𝑥1) (𝑥2− 𝑥0)(𝑥2− 𝑥1) 𝐿2′(𝑥1) = 𝑦0(𝑥1−𝑥2)

(𝑥0−𝑥1)(𝑥0−𝑥2)+ 𝑦1(2𝑥1−𝑥0−𝑥2)

(𝑥1−𝑥0)(𝑥1−𝑥2)+ 𝑦2(𝑥1−𝑥0)

(𝑥2−𝑥0)(𝑥2−𝑥1)

= −𝑦0(𝑥2−𝑥1)

(𝑥1−𝑥0)(𝑥2−𝑥1+𝑥1−𝑥0)+ 𝑦1(2𝑥1−𝑥0−𝑥2)

(𝑥1−𝑥0)(𝑥1−𝑥2)+ 𝑦2(𝑥1−𝑥0)

(𝑥2−𝑥1+𝑥1−𝑥0)(𝑥2−𝑥1)

= −𝑦0(𝑥2−𝑥1)

(𝑥1−𝑥0)(𝑥2−𝑥1)+(𝑥1−𝑥0)2+ 𝑦1(2𝑥1−𝑥0−𝑥2)

(𝑥1−𝑥0)(𝑥1−𝑥2)+ 𝑦2(𝑥1−𝑥0)

(𝑥2−𝑥1)2+(𝑥1−𝑥0)(𝑥2−𝑥1)

= −𝑦0(𝑥2−𝑥1)2

(𝑥1−𝑥0)(𝑥2−𝑥1)2+(𝑥1−𝑥0)2(𝑥2−𝑥1)+𝑦1(𝑥2−𝑥1−(𝑥1−𝑥0))(𝑥2−𝑥1+𝑥1−𝑥0)

(𝑥1−𝑥0)(𝑥2−𝑥1)(𝑥2−𝑥0) +

𝑦2(𝑥1−𝑥0)2

(𝑥2−𝑥1)2(𝑥1−𝑥0)+(𝑥1−𝑥0)2(𝑥2−𝑥1)

=𝑦1[(𝑥2−𝑥1)2−(𝑥1−𝑥0)2]−𝑦0(𝑥2−𝑥1)2+𝑦2(𝑥1−𝑥0)2

(𝑥1−𝑥0)(𝑥2−𝑥1)(𝑥2−𝑥0)

=𝑦1[(𝑥2−𝑥1)2−(𝑥1−𝑥0)2]−𝑦0(𝑥2−𝑥1)2+𝑦2(𝑥1−𝑥0)2

(𝑥1−𝑥0)(𝑥2−𝑥1)(𝑥2−𝑥0)

=(𝑦1−𝑦0)(𝑥2−𝑥1)2+(𝑦2−𝑦1)(𝑥1−𝑥0)2

(𝑥1−𝑥0)(𝑥2−𝑥1)(𝑥2−𝑥0)

=

(𝑦1−𝑦0)

(𝑥1−𝑥0)(𝑥2−𝑥1)+(𝑦2−𝑦1) (𝑥2−𝑥1)(𝑥1−𝑥0) (𝑥1−𝑥0)(𝑥2−𝑥1)(𝑥2−𝑥0)

= 𝛿01 + 𝛿10 (ℎ1+ ℎ0) Then, we also can conclude:

𝐿2(𝑥0) =𝛿0(2ℎ0+ ℎ1) − 𝛿10

(ℎ1+ ℎ0) , 𝐿2(𝑥2) =𝛿1(2ℎ1 + ℎ0) − 𝛿01 (ℎ1+ ℎ0)

The expression of 𝐿2(𝑥0) is consistent with the 𝑑0 at the endpoint of the MATLAB pchip.m file,

𝑑0 = 𝛿0(2ℎ0+ ℎ1) − 𝛿10 (ℎ1 + ℎ0)

The expression of 𝐿2(𝑥2) is consistent with the 𝑑𝑛 at the endpoint of the MATLAB

(16)

16 pchip.m file,

𝑑𝑛 =𝛿𝑛−1(2ℎ𝑛−1+ ℎ𝑛−2) − 𝛿𝑛−2𝑛−1 (ℎ1+ ℎ0)

But we should make some judgments on 𝑑0 and 𝑑𝑛. (1) If the signs of 𝑑0 and 𝛿0 are inconsistent, let 𝑑0 be 0.

(2) If the signs of 𝛿0 and 𝛿1 are inconsistent, it means that 𝑥1 is an extreme point, and the absolute value of 𝑑0 is more significant than three times the absolute value of 𝛿0, that is, |𝑑0|> 3|𝛿0|, then 𝑑0 = 3𝛿0.

(3) If the signs of 𝑑𝑛 and 𝛿𝑛−1 are inconsistent, let 𝑑𝑛 be 0.

(4) If the signs of 𝛿0 and 𝛿1 are inconsistent, it means that 𝑥1 is an extreme point, and the absolute value of 𝑑0 is more significant than three times the absolute value of 𝛿0, that is, |𝑑0|> 3|𝛿0|, then 𝑑0 = 3𝛿0.

3.2 Merits and Shortcomings of the algorithm

3.2.1 Two-point cubic Hermite interpolation

Suppose the interpolation node is 𝑥0, 𝑥1, then the interpolation condition is satisfied 𝑝(𝑥0) = 𝑓(𝑥0), 𝑝(𝑥1) = 𝑓(𝑥1), 𝑝′(𝑥0) = 𝑓′(𝑥0), 𝑝′(𝑥1) = 𝑓′(𝑥1)

The polynomial 𝑝(𝑥) becomes a two-point cubic Hermite interpolation polynomial, denoted as 𝐻3(𝑥).

Modelled on Lagrange polynomial, it can be set

𝐻3(𝑥) = 𝑎0𝛼0(𝑥) + 𝑎1𝛼1(𝑥) + 𝑏0𝛽0(𝑥) + 𝑏1𝛽1(𝑥) 𝛼0(𝑥), 𝛼1(𝑥), 𝛽0(𝑥), 𝛽1(𝑥) are all cubic polynomials and satisfied:

{

𝛼0(𝑥0) = 1 𝛼0(𝑥1) = 0 𝛼0′(𝑥0) = 0 𝛼0′(𝑥1) = 0

{

𝛼1(𝑥0) = 0 𝛼1(𝑥1) = 1 𝛼1′(𝑥0) = 0 𝛼1′(𝑥1) = 0

{

𝛽0(𝑥0) = 0 𝛽0(𝑥1) = 0 𝛽0′(𝑥0) = 1 𝛽0′(𝑥1) = 0

{

𝛽1(𝑥0) = 0 𝛽1(𝑥1) = 0 𝛽1′(𝑥0) = 0 𝛽1′(𝑥1) = 1 According to the interpolation conditions

𝐻3(𝑥) = 𝑓(𝑥0)𝛼0(𝑥) + 𝑓(𝑥1)𝛼1(𝑥) + 𝑓′(𝑥0)𝛽0(𝑥) + 𝑓′(𝑥1)𝛽1(𝑥)

Next, we have to determine the expression of 𝛼0(𝑥), 𝛼1(𝑥), 𝛽0(𝑥), 𝛽1(𝑥). We first consider 𝛼0(𝑥). Since 𝛼0(𝑥) is a cubic polynomial and 𝛼0(𝑥1) = 0, 𝛼0′(𝑥1) = 0, it can be set

𝛼0(𝑥) = (𝑎𝑥 + 𝑏)(𝑥 − 𝑥1 𝑥0− 𝑥1)2

(17)

17 Substitute 𝛼0(𝑥0) = 1, 𝛼0′(𝑥0) = 0 to get

𝑎 = 2

𝑥1− 𝑥0, 𝑏 =𝑥1− 3𝑥0

𝑥1− 𝑥0 = 1 − 2𝑥0 𝑥1− 𝑥0 𝛼0(𝑥) = (1 + 2 𝑥 − 𝑥0

𝑥1− 𝑥0)(𝑥 − 𝑥1 𝑥0− 𝑥1)2 𝛼1(𝑥) = (1 + 2 𝑥 − 𝑥1

𝑥0− 𝑥1)(𝑥 − 𝑥0 𝑥1− 𝑥0)2

Consider 𝛽0(𝑥) below. According to the interpolation condition 𝛽0(𝑥0) = 0, 𝛽0(𝑥1) = 0, 𝛽0′(𝑥1) = 0, it can be set

𝛽0(𝑥) = 𝑎(𝑥 − 𝑥0) (𝑥 − 𝑥1 𝑥0− 𝑥1)2 Bring in 𝛽0′(𝑥0) = 1 to get 𝑎 = 1, so

𝛽0(𝑥) = (𝑥 − 𝑥0) (𝑥 − 𝑥1 𝑥0− 𝑥1)2 𝛽1(𝑥) = (𝑥 − 𝑥1) (𝑥 − 𝑥0

𝑥1− 𝑥0)2 In the end we can get

𝐻3(𝑥) = 𝑓(𝑥0)(1 + 2 𝑥−𝑥0

𝑥1−𝑥0)(𝑥−𝑥1

𝑥0−𝑥1)2+ 𝑓(𝑥1)(1 + 2 𝑥−𝑥1

𝑥0−𝑥1)(𝑥−𝑥0

𝑥1−𝑥0)2+ 𝑓′(𝑥0)(𝑥 − 𝑥0) (𝑥−𝑥1

𝑥0−𝑥1)2+ 𝑓′(𝑥1)(𝑥 − 𝑥1) (𝑥−𝑥0

𝑥1−𝑥0)2

(3.1)

According to the two-point cubic Hermite interpolation formula (3.1), the expression of the piecewise function 𝐼(𝑥) on the inter-cell [𝑥𝑘, 𝑥𝑘+1] is

𝐼(𝑥) = 𝑓𝑘(1 + 2 𝑥−𝑥𝑘

𝑥𝑘+1−𝑥𝑘)(𝑥−𝑥𝑘+1

𝑥𝑘−𝑥𝑘+1)2+ 𝑓𝑘+1(1 + 2 𝑥−𝑥𝑘+1

𝑥𝑘−𝑥𝑘+1)( 𝑥−𝑥𝑘

𝑥𝑘+1−𝑥𝑘)2+ 𝑓′𝑘(𝑥 − 𝑥𝑘) (𝑥−𝑥𝑘+1

𝑥𝑘−𝑥𝑘+1)2+ 𝑓′𝑘+1(𝑥 − 𝑥𝑘+1) ( 𝑥−𝑥𝑘

𝑥𝑘+1−𝑥𝑘)2

(3.2)

3.2.2 The remainder of cubic Hermite interpolating polynomial

Suppose 𝑓(𝑥) has a fourth-order derivative in the interval [a, b] containing 𝑥0, 𝑥1 , then for any 𝑥 ∈ [𝑎, 𝑏], there is always a 𝜀 ∈ (𝑎, 𝑏)(𝜀 𝑑𝑒𝑝𝑒𝑛𝑑𝑠 𝑜𝑛 𝑥). Then, known by interpolation conditions: 𝑅3(𝑥0) = 𝑅3′(𝑥0) =0, 𝑅3(𝑥1) = 𝑅3′(𝑥1) = 0.

𝑅3(𝑥) = 𝐶(𝑥)(𝑥 − 𝑥0)2(𝑥 − 𝑥1)2

Construct 𝐹(𝑡) = 𝑓(𝑡) − 𝐻3(𝑡) − 𝐶(𝑥)(𝑡 − 𝑥0)2(𝑡 − 𝑥1)2 from 𝑓(𝑥) − 𝐻3(𝑥) = 𝐶(𝑥)(𝑥 − 𝑥0)2(𝑥 − 𝑥1)2.

References

Related documents

A review of all initiatives approved since 1912 shows that no more than 32 percent of appropriations in the 2003-04 budget were locked in by initiatives, and initiatives placed

We examined the effect of large river impoundments on fish reproductive behavior by studying the larval fish communities i n tributaries of the impounded Illinois and

F ST : The fixation index is an F-statistic that measures neutral genetic diver- gence between populations; G: Specific growth; M/M ’ : Individuals of a given size (M – small, M ’

Many consultants subcontract these services, which include testing of water or soil samples for organics, metals, and any other substances in question.. EPA or state health

Overflow detection is considered as a complicated operation with the complexity almost equal to magnitude comparison and sign detection. In this paper we proposed

mectant), (emollient), (protein reju- 와 같이 다양한 종류가 있다 환자들의 연령 및 습 venator). 진의 형태에 따라 적절한 보습제를 선택하여야 한다 보습.

In this regard, we agree with Marc Piault (1995) who sees ethnographic film festivals as spaces to break the &#34;colonial view” of the other, and to allow this &#34;view&#34; to

The study reported in this paper attempts to quantify the use of online resources by distance education students and identify the value of these resources for their learning of