• Aucun résultat trouvé

Hermite Interpolation and Splines

Dans le document in C++ and MPI (Page 134-139)

float + floatImplicit Casting

3.1.6 Hermite Interpolation and Splines

We now turn to piecewise polynomial interpolation using relatively low-order polynomials, unlike the single domain global interpolation. As we know from our previous discussion, the more (distinct) grid points that we introduce into the polynomial approximation, the higher the order of the interpolating polynomial. As the degree of the polynomial increases,

the interpolating polynomial becomes more oscillatory. One solution to this problem is to use multiple piecewise polynomials of low-order instead of one high-order polynomial. This has the advantage that the interpolation error is proportional to a lower order derivative resulting in better accuracy and more flexibility. The method of splines, first used in naval architecture, is a very effective way of such an approach and facilitates smooth transition between subdomains.

To proceed, let us first consider cubic Hermite interpolation where both function and derivatives are interpolated. The interpolation problem can be stated as follows:

Given data for the function values y and slopes s, (xL;yL;sL) and (xR;yR;sL) at the left(xL)and right(xR)boundaries of one-dimensional domain, find a cubic polynomial

p(x) =a0+a1(x−xL) +a2(x−xL)2 +a3(x−xL)2(x−xR) with the four unknown coefficients obtained from

p(xL) =yL, p(xR) =yR p(xL) =sL, p(xR) =sR. The first derivative is

p(x) =a1+ 2a2(x−xL) +a3[2(x−xL)(x−xR) + (x−xL)2] and by substituting the known data at the boundaries, we have

p(xL) =yL=a0; a0+a1∆x+a2(∆x)2 =yR p(xL) =sL =a1; a1+ 2a2∆x+a3(∆x)2 =sR,

where ∆x≡xR−xLis the domain size. We recast the above in matrix-vector form as follows

and we see that the coefficient matrix is lower-triangular.

The solution is obtained by forward substitution:

a0 =yL, a2 =yL a1 =sL, a3 =yL

where we have defined the forward differencesat the left boundary as:

yL = yR−yL

∆x , yL = yL −sL

∆x , yL = sL2yL +sR

∆x2 .

Theorem on Accuracy of Hermite Interpolation: For a function f(x) interpolated by a cubic Hermite polynomial p(x) in a domain of size ∆x, the error is bounded from above by

f(x)−p(x) f(4)(x)

384 (∆x)4.

This theorem guarantees that if the domain is divided into 100 subintervals then the error will be reduced by a factor of 108! The proof is based on evaluating themaximumcontribution of the remainder at the mid-point of the domain.

Constructing Cubic Splines: Having obtained simple formulas for Hermite cubic polyno-mial interpolation, we now proceed to construct formulas for different types of cubic splines.

Here we replace the extra information given for first derivatives (sL, sR) at the end-points of the domain by imposing continuity at the interior points. We assume, therefore, that the entire domain is subdivided into subdomains or cells and that the function and its derivatives are continuous at the breakup points, which we call the interior points. We can state the problem of constructing splines as follows:

Given the data points (x1, y1), . . .(xn, yn), find a piecewise cubic interpolant S(x) so that S(x), S(x) and S(x) are continuous at all interior points xi, i= 2, . . . ,(n1).

To achieve this we have to choose the slopes (si, i= 1, . . . , n) at all points appropriately. To maintain continuity of the slopes we simply assign a single value at each point. However, we have to enforce continuity of the second derivative explicitly. To this end, we consider the subdomain x∈[xi, xi+1] and apply Hermite interpolation as before where the pointxi is the left boundary and the point xi+1 is the right boundary, as shown in figure 3.7.

i i+1

x

L

x

R

Figure 3.7: Interpolation in the intervalx∈[xi, xi+1].

We then construct the cubic polynomial

pi(x) =yi+si(x−xi) +yi(x−xi)2 +yi(x−xi)2(x−xi+1), where

yi = yi+1−yi

∆xi ; yi = yi−si

∆xi ; yi = si2yi+si+1 (∆xi)2 , with ∆xi ≡xi+1−xi. We also obtain the second derivative

pi(x) = 2yi+yi[4(x−xi) + 2(x−xi+1)].

Next, we move to the adjacent cell x [xi+1, xi+2] in order to apply Hermite interpolation on this interval, see figure 3.8.

i+1 i+2

x

L

x

R

Figure 3.8: Interpolation in the intervalx∈[xi+1, xi+2].

We construct the polynomial

pi+1(x) =yi+1+si+1(x−xi+1) +yi+1(x−xi+1)2+yi+1 (x−xi+1)2(x−xi+2), and its second derivative

pi+1(x) = 2yi+1 +yi+1 [4(x−xi+1) + 2(x−xi+2)].

Next, we enforce continuity of second derivative at xi+1 and obtain equations for the unknown slopes:

2

∆xi

(2si+1+si3yi) = 2

∆xi+1

(3yi+1 2si+1−si+2), which can be re-written as

∆xi+1si+ 2(∆xi+ ∆xi+1)si+1+ ∆xisi+2 = 3(∆xi+1yi+ ∆xiyi+1 ) (3.9) i= 1, . . . , n2.

The above equations can be recast in a matrix-vector form with a tridiagonal coefficient matrix. However, we have no information for the slopess1, sn (the end-slopes), and thus we cannot solve for the slopes yet; we need additional information, the type of which specifies different classes of splines:

I. The Complete Spline: Here the additional information is given at the end-points where the end-slopes are explicitly specified, i.e., s1 =SL and sn =SR.

II. The Natural Spline: In this case the curvature(i.e., p(x)) at the end-points is set to zero, i.e.

p1(xL) = 0⇒s1 = 1

2(3y1 −s2) and sn = 1

2(3yn1−sn1).

III. The Not-A-Knot Spline: In this case, no explicit information on the end-points is provided, but instead we use continuity of the third-derivative p(x) at the points x2 and xn1. Using

pi (x) = 6si+si+12yi (∆xi)2 , and enforcing the continuity condition, we obtain

s1 =−s2+ 2y1 +

$∆x1

∆x2

%2

(s2+s32y2).

This forms the first row in the triagonal matrix-vector system, which now has a band-width of two instead of one. A similar equation is valid for the other end (last row in the matrix-vector system).

IV. The B-Spline: An example of a very popular cubic spline derived from the above Hermite interpolation is thebasicorB-spline. It corresponds to zero slopes at the end-points, i.e., sL =sR = 0, and it is symmetric. Its support is five points, that is, it is non-zero within four equidistant intervals ∆x. It is defined by the five points

(xi, yi) = [(1,0),(1,1),(2,4),(3,1),(4,0)].

Solving the matrix-vector system constructed from equation (3.9):

and it is zero everywhere else as shown in figure 3.9. Note that the B-spline, which has its origin in applications of beam vibrations, satisfies aminimum principle. Specifically, the B-spline has the smallest bending energy

E(B(x)) =

among all functions or other splines that go through the same data points.

Next, we state a theorem that gives upper bounds for the error of spline interpolation up to the third derivative. This depends on the end-points, so the theorem is for the complete spline:

Theorem on Accuracy of Complete Splines: Let S(x) be the cubic spline that interpo-latesf(x), x[a, b]at points xi =i∆x, where ∆x= (bna), i= 0, . . . , n, and alsosL=f(a) and sR =f(b), then:

S(r)(x)−f(r)(x)2 rf(4) 2 (∆x)4r, r= 0,1,2,3 where 0 = 3845 , 1 = 241, 2 = 38 and 3 = 1.

0 0.5 1 1.5 2 2.5 3 3.5 4 0

0.5 1 1.5 2 2.5

Dans le document in C++ and MPI (Page 134-139)