Polynomial Interpolation

Similar documents
Polynomial Interpolation

Lecture 15. Interpolation II. 2 Piecewise polynomial interpolation Hermite splines

Numerical Differentiation

Lecture XVII. Abstract We introduce the concept of directional derivative of a scalar function and discuss its relation with the gradient operator.

HOMEWORK HELP 2 FOR MATH 151

5.1 introduction problem : Given a function f(x), find a polynomial approximation p n (x).

Copyright c 2008 Kevin Long

Chapter 4: Numerical Methods for Common Mathematical Problems

Consider a function f we ll specify which assumptions we need to make about it in a minute. Let us reformulate the integral. 1 f(x) dx.

Order of Accuracy. ũ h u Ch p, (1)

LECTURE 14 NUMERICAL INTEGRATION. Find

5 Ordinary Differential Equations: Finite Difference Methods for Boundary Problems

lecture 26: Richardson extrapolation

232 Calculus and Structures

(a) At what number x = a does f have a removable discontinuity? What value f(a) should be assigned to f at x = a in order to make f continuous at a?

Exam 1 Review Solutions

NUMERICAL DIFFERENTIATION. James T. Smith San Francisco State University. In calculus classes, you compute derivatives algebraically: for example,

The total error in numerical differentiation

How to Find the Derivative of a Function: Calculus 1

2.8 The Derivative as a Function

Section 3.1: Derivatives of Polynomials and Exponential Functions

The Laplace equation, cylindrically or spherically symmetric case

Precalculus Test 2 Practice Questions Page 1. Note: You can expect other types of questions on the test than the ones presented here!

1 Calculus. 1.1 Gradients and the Derivative. Q f(x+h) f(x)

Poisson Equation in Sobolev Spaces

Math Spring 2013 Solutions to Assignment # 3 Completion Date: Wednesday May 15, (1/z) 2 (1/z 1) 2 = lim

A h u h = f h. 4.1 The CoarseGrid SystemandtheResidual Equation

Chapter 2 Limits and Continuity

A = h w (1) Error Analysis Physics 141

Differentiation in higher dimensions

Math 242: Principles of Analysis Fall 2016 Homework 7 Part B Solutions

Taylor Series and the Mean Value Theorem of Derivatives

Bob Brown Math 251 Calculus 1 Chapter 3, Section 1 Completed 1 CCBC Dundalk

Continuity and Differentiability of the Trigonometric Functions

Differential equations. Differential equations

New Fourth Order Quartic Spline Method for Solving Second Order Boundary Value Problems

4. The slope of the line 2x 7y = 8 is (a) 2/7 (b) 7/2 (c) 2 (d) 2/7 (e) None of these.

5.1 We will begin this section with the definition of a rational expression. We

1. Questions (a) through (e) refer to the graph of the function f given below. (A) 0 (B) 1 (C) 2 (D) 4 (E) does not exist

Click here to see an animation of the derivative

Polynomials 3: Powers of x 0 + h

Functions of the Complex Variable z

Mathematics 5 Worksheet 11 Geometry, Tangency, and the Derivative

IEOR 165 Lecture 10 Distribution Estimation

2.11 That s So Derivative

The derivative function

Chapter 5 FINITE DIFFERENCE METHOD (FDM)

Digital Filter Structures

1 1. Rationalize the denominator and fully simplify the radical expression 3 3. Solution: = 1 = 3 3 = 2

Chapter 8. Numerical Solution of Ordinary Differential Equations. Module No. 2. Predictor-Corrector Methods

1. Consider the trigonometric function f(t) whose graph is shown below. Write down a possible formula for f(t).

MVT and Rolle s Theorem

Flavius Guiaş. X(t + h) = X(t) + F (X(s)) ds.

1 The concept of limits (p.217 p.229, p.242 p.249, p.255 p.256) 1.1 Limits Consider the function determined by the formula 3. x since at this point

2.1 THE DEFINITION OF DERIVATIVE

ERROR BOUNDS FOR THE METHODS OF GLIMM, GODUNOV AND LEVEQUE BRADLEY J. LUCIER*

MATHEMATICS FOR ENGINEERING DIFFERENTIATION TUTORIAL 1 - BASIC DIFFERENTIATION

CS522 - Partial Di erential Equations

Notes on Multigrid Methods

Exercises for numerical differentiation. Øyvind Ryan

3.1 Extreme Values of a Function

ALGEBRA AND TRIGONOMETRY REVIEW by Dr TEBOU, FIU. A. Fundamental identities Throughout this section, a and b denotes arbitrary real numbers.

Combining functions: algebraic methods

Definition of the Derivative

SECTION 3.2: DERIVATIVE FUNCTIONS and DIFFERENTIABILITY

2.3 Algebraic approach to limits

Solution for the Homework 4

Analytic Functions. Differentiable Functions of a Complex Variable

Function Composition and Chain Rules

A MONTE CARLO ANALYSIS OF THE EFFECTS OF COVARIANCE ON PROPAGATED UNCERTAINTIES

THE IMPLICIT FUNCTION THEOREM

160 Chapter 3: Differentiation

Rules of Differentiation

Cubic Functions: Local Analysis

Derivatives. By: OpenStaxCollege

Chapters 19 & 20 Heat and the First Law of Thermodynamics

The Verlet Algorithm for Molecular Dynamics Simulations

MA455 Manifolds Solutions 1 May 2008

Volume 29, Issue 3. Existence of competitive equilibrium in economies with multi-member households

Solutions to the Multivariable Calculus and Linear Algebra problems on the Comprehensive Examination of January 31, 2014

A CLASS OF EVEN DEGREE SPLINES OBTAINED THROUGH A MINIMUM CONDITION

Solution. Solution. f (x) = (cos x)2 cos(2x) 2 sin(2x) 2 cos x ( sin x) (cos x) 4. f (π/4) = ( 2/2) ( 2/2) ( 2/2) ( 2/2) 4.

Chapter 1. Density Estimation

POLYNOMIAL AND SPLINE ESTIMATORS OF THE DISTRIBUTION FUNCTION WITH PRESCRIBED ACCURACY

Derivatives and Rates of Change

Gradient Descent etc.

Logarithmic functions

Chapter 2. Limits and Continuity 16( ) 16( 9) = = 001. Section 2.1 Rates of Change and Limits (pp ) Quick Review 2.1

Recall from our discussion of continuity in lecture a function is continuous at a point x = a if and only if

11.6 DIRECTIONAL DERIVATIVES AND THE GRADIENT VECTOR

NON STANDARD FITTED FINITE DIFFERENCE METHOD FOR SINGULAR PERTURBATION PROBLEMS USING CUBIC SPLINE

University Mathematics 2

1 Lecture 13: The derivative as a function.

Fractional Derivatives as Binomial Limits

Finite Difference Method

Math 1241 Calculus Test 1

THE IDEA OF DIFFERENTIABILITY FOR FUNCTIONS OF SEVERAL VARIABLES Math 225

Symmetry Labeling of Molecular Energies

Finite Difference Methods Assignments

158 Calculus and Structures

Transcription:

Capter 4 Polynomial Interpolation In tis capter, we consider te important problem of approximating a function f(x, wose values at a set of distinct points x, x, x 2,,x n are known, by a polynomial P (x suc tat P (x i =f(x i, i =,, 2,,n Suc a polynomial is known as an interpolating polynomial An approximation of tis function is desirable if f(x is difficult to evaluate or manipulate like te error function erf(x = 2 x e t2 dt, π for example Note tat polynomials are easily evaluated, differentiated or integrated Anoter purpose of suc an approximation is tat a very long table of function values f(x i may be replaced by a sort table and a compact interpolation subroutine 4 Linear Interpolation Let f(x be given at two distinct points x i and x i+ Now, given f(x i =f i and f(x i+ =f i+, we wis to determine te interpolating polynomial P (x of degree (ie, a straigt line tat approximates f(x onteinterval[x i,x i+ ] Let P (x =αx + β From te conditions P (x i =f i and P (x i+ =f i+ we obtain te two equations ie, ( xi x i+ αx i + β = f i αx i+ + β = f i+, ( α β = ( fi f i+ Tis system is clearly nonsingular since x i x i+, and it as a unique solution: α = f i+ f i x i+ x i β = f ix i+ f i+ x i x i+ x i 68

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 69 Terefore, Example 4 wic gives ( fi+ f i P (x =f i + (x x i x i+ x i Using linear interpolation, approximate sin 65 from a table (a sin 6 =45; sin 7 =287 (b sin =;sin =765 Solution ( 287 45 (a P (65 = 45 + 7 6 2 (b P (65 = + 765 (65 287 Te first answer is correct to 5 decimals wereas te second answer is correct only to 2 decimals! Conclusion: Linear interpolation is suitable only over small intervals 42 Polynomial Interpolation Since linear interpolation is not adequate unless te given points are closely spaced, we consider iger order interpolating polynomials Let f(x begiven at te selected sample of (n + points: x <x < <x n, ie, we ave (n +pairs(x i,f i, i =,, 2,,n Te objective now is to find te lowest degree polynomial tat passes troug tis selected sample of points f(x P n (x f(x x x x 2 x x n Figure 4: Interpolating te function f(x by a polynomial of degree n, P n (x Consider te nt degree polynomial P n (x =a + a x + a 2 x 2 + + a n x n

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 7 We wis to determine te coefficients a j, j =,,,n, suc tat P n (x j =f(x j, j =,, 2,,n Tese (n + conditions yield te linear system a + a x + a 2 x 2 + + a nx n = f a + a x + a 2 x 2 + + a nx n = f a + a x 2 + a 2 x 2 2 + + a n x n 2 = f 2 a + a x n + a 2 x 2 n + + a nx n n = f n or V a = f, were a T =(a,a,,a n, f T =(f,f,,f n, and V is an (n + (n +matrixgivenby x x 2 x n x x 2 x n V = x 2 x 2 2 x n 2 x n x 2 n x n n Te matrix V is known as te Vandermonde matrix nonzero determinant n det(v = (x i x j j= i>j It is nonsingular wit For n =, for example, det(v =(x x (x 2 x (x x (x 2 x (x x (x x 2 Hence a can be uniquely determined as a = V f Anoter proof of te uniqueness of te interpolating polynomial can be given as follows Teorem 4 Uniqueness of interpolating polynomial Given a set of points x <x < <x n, tere exists only one polynomial tat interpolates a function at tose points Proof Let P (x andq(x be two interpolating polynomials of degree at most n, for te same set of points x <x < <x n Also, let R(x =P (x Q(x Ten R(x is also a polynomial of degree at most n Since P (x i =Q(x i =f i, we ave, R(x i =fori =,,,n In oter words R(x as(n +roots From te Fundamental Teorem of Algebra owever, R(x cannot ave more tan n roots A contradiction! Tus, R(x, and P (x Q(x Example 42 Given te following table for te function f(x, obtain te lowest degree interpolating polynomial

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 7 x k 2 4 f k 4 4 Solution Since te number of nodes = = n +, terefore n =2 Let P 2 (x =a + a x + a 2 x 2, tat satisfies te following conditions at te points x =;x =2,x 2 =4: P ( = ; P (2 = 4; P (4 = 4 2 4 a a = 4 4 6 a 2 4 Using Gaussian elimination wit partial pivoting, we compute te solution a = a a = 4 2, a 2 Terefore, te interpolating polynomial is given by P 2 (x = 4 2x + x 2 We can use tis approximation to estimate te root of f(x tat lies in te interval [2, 4]: γ = 2+ 4+6 =+ 5 2 An important remark is in order One, in general, sould not determine te interpolating polynomial by solving te Vandermonde linear system Tese systems are surprisingly ill-conditioned for n no larger tan For example, for <x <x < <x n = uniformly distributed in [,], large n yields a Vandermonde matrix wit almost linearly dependent columns, and te Vandermonde system becomes almost singular A more satisfactory form of te interpolating polynomial is due to Lagrange, P n (x =f(x L (x+f(x L (x+ + f(x n L n (x Here L j (x, for j n, are polynomials of degree n called fundamental polynomials or Lagrange polynomials From te(n + conditions P n (x i =f(x i, i n, we see tat L j (x i = { i j i = j

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 72 Te above property is certainly satisfied if we coose ie, L j (x = (x x (x x (x x j (x x j+ (x x n (x j x (x j x (x j x j (x j x j+ (x j x n L j (x = n i= i j (x x i (x j x i Te fact tat L j (x is unique follows from te uniqueness of te interpolation polynomial Recall tat tere is one and only one polynomial of degree n or less tat interpolates f(x atte(n +nodesx <x < <x n Tus,fortisgiven set of nodes, bot forms yield te same polynomial! Vandermonde Approac n P n (x = a i x i i= V a = f Operation count: It can be sown tat te Vandermonde system V a = f can be solved in O(n 2 aritmetic operations rater tan O(n operations because of te special form of te Vandermonde matrix Lagrange Approac P n (x = n f j L j (x = j= n j= g j n (x x i i= (x x j = n g j ν j j= were g j = f(x j n (x j x i i= i j Operation count: Te Lagrange form avoids solving te ill-conditioned Vandermonde linear, systems, and evaluates te polynomials ν j = (x x j n (x x i i=

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 7 for a given x Te cost of tese operations for eac j =,, 2,,n are: u(x = n (x x i (2n +ops i= ν j = u(x (x x j f j g j = n (x j x i i= i j (n +ops Now, te cost for evaluating te polynomial P n (x = 2n(n + ops (evaluated once only n g j ν j j= (2n +ops Terefore, te total number of operations are 5n +onceg j s are evaluated 4 Error in Polynomial Interpolation Let e n (x be te error in polynomial interpolation given by Since P n (x i =f(x i, we ave e n (x =f(x P n (x e n (x i = x <x < <x n In oter words e n (x is a function wit at least (n + roots Hence, we can f(x P n (x f(x x x x 2 x x n Figure 42: Computing te error in polynomial interpolation write e n (x =(x x (x x (x x n (x =π(x (x were (x is a function of x Let us define g(z =e n (z π(z(x

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 74 were x x j,for j n Tus, g(x =, g(x j =, j n, ie, g(z as(n + 2 distinct roots Assuming tat f(x as at least n + continuous derivatives, te (n + t derivative of g(z, ie, d (n+ dz g(z (n+ g(n+ (z as at least one root x Hence, g(z x x x 2 x x 4 g ( z g ( z g ( z g iv ( z x* Figure 4: Te (n + t derivative of a function g(x witn +2 roots(n = must ave at least one root g (n+ (z =e (n+ n (z (xπ (n+ (z, were π (n+ (z =(n +! Moreover, since e n (z =f(z P n (z, terefore, e (n+ n (z =f (n+ (z P (n+ (z in wic te last term P n (n+ (z is zero Using te above equations, we ave g (n+ (z =f (n+ (z (x(n +! We ad sown earlier tat g (n+ (z as at least one root x in te interval containing x and x j, j =,,n Tis implies tat g (n+ (x =, and terefore, (x = f (n+ (x (n +! n

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 75 Consequently, we ave te following representation of te error in polynomial interpolation e n (x =f(x P n (x =(x x (x x (x x n f (n+ (x (n +! were x is in te interval containing x and x j, j =,,n Example 4 Obtain te Lagrange interpolating polynomial from te data sin =, sin π 6 = 2, sin π = 2, sin π 2 =, and use it to evaluate sin π 2 and sin π 4 Solution Te interpolating polynomial is given by At x = π 2, Terefore, P (x = f L (x+f L (x+f 2 L 2 (x+f L (x = 2 L (x+ 2 L 2(x+L (x 2 L = 2 π 2 π ( 2 2 π 6 6 π 6 π = 5 6 2 2 L 2 = 2 π 6 2 π ( 2 2 π π 6 π = 5 6 2 2 L = 2 π 6 2 π ( 2 π 2 2 π 6 2 π = 6 P =2662 2 Since sin π 2 =25882, we ave error =8 At x = π 4, L =5625, L 2 =5625, L =625 4 4 4 Terefore P =7589 4 Since sin π 4 =77, we ave error =22 Let us estimate te error e n (x atx = π 4 : e = 4 4 4 π 6 4 π 4 π f (4 (x 2 4! Since f(x =sinx; f (4 (x =sinx, and tus, f (4 (x

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 76 Terefore, ( π π e 4 4 π 2 π 2 π 4 4! =76 Similarly, e n (x atx = π 2 is bounded by ( π π e 2 2 π 2 π 4 5π 2 4! =294 44 Runge s Function and Equidistant Interpolation In tis section, we discuss a problem tat arises wen one constructs a global interpolation polynomial on a fairly large number of equally spaced nodes Consider te problem of approximating te following function on te interval [, ] f(x = +25x 2 using te interpolation polynomial P n (x on te equidistant nodes x j = + 2j n, j =,,,n Figure 44 sows ow te polynomials P 4 (x, P 8 (x, P 2 (x, and P 6 (x approximate f(x on[, ] We see tat as n increases, te interpolation error in te central portion of te interval diminises, wile increasing rapidly near te ends of te interval Suc beavior is typical in equidistant interpolation wit polynomials of ig degree Tis is known as Runge s penomenon, and te function f(x is known as Runge s function If te (n + interpolation nodes are not cosen equally spaced, but rater placed near te ends of te interval at te roots of te so called Cebysev polynomial of degree (n +, te problem wit Runge s function disappears (see Fig 45 Te roots of te Cebysev polynomial of degree (n + are given by ( k + 2 x k = cos n + π, k =,,,n 45 Te Newton Representation Te Lagrange form for te interpolating polynomial is not suitable for practical computations Te Newton form of te interpolating polynomial proves to be muc more convenient Let us obtain a different form of te lowest degree interpolating polynomial at te distinct interpolation nodes given by x <x <x 2 < <x n

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 77 n = 4 n = 8 8 8 6 6 4 4 2 2 2 4 6 2 8 4 8 6 4 2 2 4 6 8 n = 2 8 6 4 2 2 4 6 8 2 n = 6 5 2 5 4 5 6 2 8 25 5 2 4 8 6 4 2 2 4 6 8 4 8 6 4 2 2 4 6 8 Figure 44: Equal spaced interpolation of Runge s function were f(x j =f j, j =,,,n Let te interpolating polynomial be Using te n conditions P n (x = c + c (x x +c 2 (x x (x x + c (x x (x x (x x 2 + + c n (x x (x x (x x n P n (x j =f j, j =,,,n, we can construct a system of equations in te unknown c j For n =,for example, tis yields a system of linear equations of te form Lc = f, werel is given by, L = (x x (x 2 x (x 2 x (x 2 x (x x (x x (x x (x x (x x (x x 2 Note tat te evaluation of L for n nodes requires O(n 2 aritmetic operations Assuming tat te nodes are equidistant, ie, x i+ x i =, te system Lc = f

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 78 2 n = 4 2 n = 8 8 8 6 6 4 4 2 2 2 8 6 4 2 2 4 6 8 n = 2 2 8 6 4 2 2 4 6 8 n = 6 9 9 8 8 7 7 6 6 5 5 4 4 2 2 8 6 4 2 2 4 6 8 8 6 4 2 2 4 6 8 Figure 45: Cebysev interpolation of Runge s function is given by Step 2 2 2 6 2 6 c c c 2 c = f f f 2 f c = f f ( = (f f / f ( 2 = (f 2 f /2 f ( = (f f / Ten we ave te system order : Step 2 c c 2 = 2 2 2 c c = f ( f ( f ( 2 f (

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 79 f (2 2 = (f ( 2 f ( / f (2 = (f ( f ( /2 Ten we get te system of order 2: ( ( c2 c = ( f (2 2 f (2 Step c 2 = f (2 2 f ( = (f (2 f (2 2 / Step 4 c = f ( MATLAB function c = InterpolateNewton(x,f % x: interpolating nodes % f: function values at x % c: coef of Newton s form of interpolating polynomial n = lengt(x; for k = :n- f(k+:n = (f(k+:n-f(k/(x(k+:n-x(k; end c = y; 46 Spline Interpolation Draftsmen used to draw smoot curves troug data points by using splines Tese are tin flexible strips of plastic or wood wic were laid on paper and eld wit weigts so as to pass troug te required data points (or nodes Te weigts are constructed in suc a way tat te spline is free to slip As a result, te flexible spline straigtens out as muc as it can subject to passing over tese points Teory of elasticity suggests tat tis mecanical spline is given by a cubic polynomial (degree polynomial in eac subinterval [x i,x i+ ], i =, 2,,n, wit adjacent cubics joint continuously wit continuous first and second derivatives Let s(x =a + a x + a 2 x 2 + a x, be te form of eac cubic spline Since we ave (n subintervals [x i,x i+ ], i n, ten we ave 4(n unknowns; (4 parameters for eac subinterval: x,a,a 2,anda Suppose s i (x denotestecubicsplineteit interval Te conditions to be satisfied by tese cubic splines are:

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 8 x x 2 x x 4 Figure 46: Spline interpolation Continuity at eac interior node: s i (x i =s i (x i, i =2,,,n 2 Continuity of first derivative at eac interior node: s i (x i=s i (x i, i =2,,,n Continuity of second derivative at eac interior node: s i (x i=s i (x i, i =2,,,n 4 Interpolation of function at eac node: s(x j =f(x j, j =, 2,,n Tese provide (n 2 + n =4n 6 conditions; owever, in order to completely specify te cubic splines, we still need 2 additional conditions Tese are conditions specified at te end points x and x n For te mecanical or natural spline we set s (x =s (x n = Let te nodes x j, j =, 2,,n, be equidistant, ie, x j+ x j = and let, ie, σ j = 6 s (x j s i (x i=s i (x i=6σ i

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 8 for all i satisfying condition Since we ave s(x =a + a x + a 2 x 2 + a x, s (x = a +2a 2 x +a x 2 s (x = 2a 2 +6a x, ie, s (x is a straigt line Tus, s i (x takes te following form (see Fig 47: i (x =x i+ x (6σ i + (x x i (6σ i+, i =, 2,,n s s'' i ( x 6σ i+ 6σ i x i x xi+ Figure 47: Computing spline witin an interval Integrating once, we ave s i (x = 6σ i (x i+ x 2 + 6σ i+ (x x i 2 + β 2 2 and integrating once more, we ave s i (x = σ i (x i+ x + σ i+ (x x i + β x + β 2 were β and β 2 are constants Clearly we can write s i (x as follows, s i (x = σ i (x i+ x + σ i+ (x x i + γ (x x i +γ 2 (x i+ x Using conditions 4 and, Terefore, s i (x i =f i f i = σ i 2 + γ 2 s i (x i+ =f i+ f i+ = σ i+ 2 + γ γ = f i+ σ i+, γ 2 = f i σ i,

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 82 and s i (x = σ i (x i+ x + σ i+ ( fi + σ i ( (x x i fi+ + (x i+ x s i (x = σ i (x i+ x 2 + σ i+ (x x i 2 + ( fi σ i σ i+ (x x i ( fi+ σ i+ Using condition 2, ie, s i (x i=s i (x i, we get ( ( fi+ f i fi f i σ i + (σ i+ σ i =σ i + (σ i σ i or σ i+ +4σ i + σ i = i i i =2,,,n, were i = f i+ f i Using te additional conditions σ = σ n =,weave 4σ 2 + σ = ( 2 / σ i +4σ i + σ i+ = ( i i / i =, 4,,n 2 σ n 2 +4σ n = ( n n 2 / Now, assigning g j = j j we ave te linear system 4 4 4 4 = f j+ 2f j + f j 2, σ 2 σ σ n 2 σ n = g 2 g g n 2 g n Te tridiagonal system above, denoted by [, 4, ], may be factored as follows: µ λ µ 2 λ 2 µ λ n µ n 2

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 8 Te following conditions must be satisfied: µ =4, λ i µ i =, λ i + µ i+ =4 Te algoritm for computing L andu is given below Triangular decomposition for system [,4,] µ =4 for i =, 2,,n λ i = µ i µ i+ =4 λ i end; Once L andu are obtained, te above system is solved as sown in Capter

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 84 47 Appendix: Cubic Spline Interpolation In tis Appendix, we discuss ow to find out te coefficients in te cubic splines in an intuitive way (no integration involved Basically, it follows te 4 conditions to derive te coefficients but will result in a better way for uman beings to calculate Tecubicpolynomialoninterval[x i,x i+ ]is s i (x =a i + b i (x x i +c i (x x i 2 + d i (x x i, i =,,n ( Apply condition (iv, So, we ave all te values of a i s (2 Apply condition (i, Ten, s i (x i =a i = f(x i, i =,,n s i (x i+ =s i+ (x i+ =f(x i+, i =,,n 2 s i (x i+ =a i + b i (x i+ x i +c i (x i+ x i 2 + d i (x i+ x i = f(x i+, were i =,,n 2 Let i = x i+ x i Ten, a i + b i i + c i 2 i + d i i = f(x i+ =a i+, i =,,n 2 Since i is from to n 2, we migt define a n = f(x n Ten, a i+ = a i + b i i + c i 2 i + d i i, i =,,n (A ( Te first derivative of s i is Apply condition (ii, Ten, s i (x =b i +2c i (x x i +d i (x x i 2 s i(x i+ =s i+(x i+ =b i+, i =,,n 2 b i+ = s i(x i+ =b i +2c i i +d i 2 i, i =,,n 2 Since i is from to n 2, we migt define b n = s (x n Ten, b i+ = b i +2c i i +d i 2 i, i =,,n (B

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 85 (4 Te second derivative of s i is s i (x =2c i +6d i (x x i Apply condition (iii, s i (x i+ =s i+(x i+ =2c i+, i =,,n 2 Ten, 2c i+ = s i (x i+ =2c i +6d i i, i =,,n 2 Since i is from to n 2, we migt define c n = s (x n /2 Ten, c i+ = c i +d i i, i =,,n (C (5 We ave all a i s in (, for all i =, n From(C,weknow d i = c i+ c i, i =,,n (D i Introduce (D into (A, ten a i+ = a i + b i i + c i 2 i + d i i = a i + b i i + c i 2 i + c i+ c i i i = a i + b i i + 2 i (c i+ +2c i (E Introduce (D into (B, ten b i+ = b i +2c i i +d i 2 i = b i +2c i i +(c i+ c i i = b i + i (c i+ + c i (F (6 From (E, we get b i i = (a i+ a i 2 i (c i+ +2c i b i = (a i+ a i i i (c i+ +2c i (G Consider (F wit (G using indices i and i (ie (F is written as b i = b i + i (c i + c i, were i =2,,n Ten, (a i+ a i i i (c i+ +2c i = (a i a i i i (c i +2c i + i (c i + c i (a i+ a i (a i a i = i i i (c i+ +2c i i (c i +2c i + i (c i + c i (a i+ a i (a i a i i i = i (c i+ +2c i i (c i +2c i + i (c i + c i = i c i+ +2 i c i i c i 2 i c i + i c i + i c i = i c i+ +2 i c i +2 i c i + i c i = i c i +2c i ( i + i + i c i+,

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 86 were i =2,,n Ten, i c i +2c i ( i + i + i c i+ = (a i+ a i (a i a i, i i were i =2,,n (7 Now, use te natural conditions Since S (x n =, by te definition of c n we gave in (4, c n = On te oter and, because S (x =, s (x =2c +6d (x x = So,c = (8 Consider te results in (6 and (7 We can construct a linear system to solve for all c i s as below c 2( + 2 2 c 2 2 2( 2 + c n 2 2(n n 2 + n n c n c n = 2 (a a 2 (a 2 a (a 4 a 2 (a a 2 n (a n a n n 2 (a n a n 2 Let tis linear system be represented as Ac = b Matriax A is a strictly diagonally dominant matrix; terefore, is nonsingular So te above linear system as an unique solution for c (9 Up to now, we get all a i s and c i s We can obtain b i s and d i s by te equations we ad derived in (D and (G, respectively d i = i (c i+ c i b i = (a i+ a i i i (c i+ +2c i Example 44 Obtain te natural cubic spline interpolation for f(x wose values are given at four points: f( = 2, f( 2 =, f( =, f(4 = Solution Weuseatalbetoelpuscalculate

Cap 4 Polynomial Interpolation Numerical Metods Class Notes 87 = x =( a =2 b =( 25 87 c = d = 4 87 2 = x 2 =( 2 a 2 = b 2 =( 92 87 c 2 = 4 29 d 2 =( 9 = x = a = b =( 76 87 c =( 67 87 d = 67 78 x 4 =4 a 4 = b 4 =x c 4 = d 4 =x 78 We already ave te a i = f i for i =, 2,, 4 Ten, we need to find all c i s One can construct a linear system for c i s as c 8 c 2 2 c = 9 5 c 4 Ten, c = c 4 = Furtermore,c 2 = 4 29 and c =( 67 87 After aving all c i s and a i s, we can decide te d i s and b i s as follow: d = d 2 = d = (c 2 c = 4 29 = 4 87 (c c 2 = 2 9 ( 9 87 =( 9 78 (c 4 c = 67 9 87 = 67 87 Te cubic splines are b = (a 2 a (c 2 +2c =( 25 87 b 2 = (a a 2 2 2 (c +2c 2 =( 92 87 b = (a 4 a (c 4 +2c = 76 87 s = 2+( 25 87 s 2 = +( 92 4 (x ( 2 + 87 4 (x ( + + (x ( 87 29 (x ( 22 +( 9 78 s = + 76 (x + ( 67 87 87 (x 2 + 67 78 (x Te natural cubic spline interpolation S = s s 2 s (x ( 2