Chap 13 Interpolation and Approximation

Chap 13 Interpolation and Approximation - FIRST YEAR...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: FIRST YEAR CALCULUS W W L CHEN c W W L Chen, 1987, 2005. This chapter originates from material used by the author at Imperial College, University of London, between 1981 and 1990. It is available free to all individuals, on the understanding that it is not to be used for financial gain, and may be downloaded and/or photocopied, with or without permission from the author. However, this document may not be kept on any information storage and retrieval system without permission from the author, unless such system is not accessible to any individuals other than its owners. Chapter 13 INTERPOLATION AND APPROXIMATION 13.1. Exact Fitting Example 13.1.1. We wish to find a polynomial through the points (0, 6), (1, 2) and (5, 6). To do this, consider a polynomial p(x) = ax2 + bx + c, where we shall determine suitable values for the three coefficients. Since the polynomial p(x) passes through (0, 6), (1, 2) and (5, 6), we must have p(0) = 6, p(1) = 2 and p(5) = 6. It follows that we must have 6 = c, 2 = a + b + c, 6 = 25a + 5b + c. This is a system of 3 linear equations in 3 unknowns. Solving this system, we get a = 1, b = −5 and c = 6. Hence p(x) = x2 − 5x + 6. Example 13.1.2. We wish to find a polynomial through the points (−1, 5), (0, 1), (1, −1) and (3, 49). To do this, consider a polynomial p(x) = ax3 + bx2 + cx + d, where we shall determine suitable values for the four coefficients. Since the polynomial p(x) passes through (−1, 5), (0, 1), (1, −1) and (3, 49), we must have p(−1) = 5, p(0) = 1, p(1) = −1 and p(3) = 49. It follows that we must have 5 = −a + b − c + d, 1 = d, −1 = a + b + c + d, 49 = 27a + 9b + 3c + d. This is a system of 4 linear equations in 4 unknowns. Solving this system, we get a = 2, b = 1, c = −5 and d = 1. Hence p(x) = 2x3 + x2 − 5x + 1. Chapter 13 : Interpolation and Approximation page 1 of 6 First Year Calculus c W W L Chen, 1987, 2005 The two examples above illustrate a very crude technique. When we attempt to fit a polynomial through k points, we use a polynomial of degree (k − 1). We then have to determine the k coefficients of this polynomial. This amounts to solving a system of k linear equations in the k unknowns. Clearly it is rather tedious, particularly when k is large. Let us therefore use a different approach on the same problems. Example 13.1.3. As in Example 13.1.1, let us find a polynomial through the points (0, 6), (1, 2) and (5, 6). Try p(x) = a(x − 1)(x − 5) + b(x − 0)(x − 5) + c(x − 0)(x − 1). Since p(0) = 6, we must have 6 = a(0 − 1)(0 − 5), so that a = 6/5. Since p(1) = 2, we must have 2 = b(1 − 0)(1 − 5), so that b = −1/2. Since p(5) = 6, we must have 6 = c(5 − 0)(5 − 1), so that c = 3/10. Hence p(x) = 6(x − 1)(x − 5) (x − 0)(x − 5) 3(x − 0)(x − 1) − + = x2 − 5x + 6. 5 2 10 Example 13.1.4. As in Example 13.1.2, let us find a polynomial through the points (−1, 5), (0, 1), (1, −1) and (3, 49). Try p(x) = a(x − 0)(x − 1)(x − 3) + b(x + 1)(x − 1)(x − 3) + c(x + 1)(x − 0)(x − 3) + d(x + 1)(x − 0)(x − 1). Since p(−1) = 5, we must have 5 = a(−1 − 0)(−1 − 1)(−1 − 3), so that a = −5/8. Since p(0) = 1, we must have 1 = b(0+1)(0 − 1)(0 − 3), so that b = 1/3. Since p(1) = −1, we must have −1 = c(1+1)(1 − 0)(1 − 3), so that c = 1/4. Since p(3) = 49, we must have 49 = d(3 + 1)(3 − 0)(3 − 1), so that d = 49/24. Hence p(x) = − 5x(x − 1)(x − 3) (x + 1)(x − 1)(x − 3) x(x + 1)(x − 3) 49x(x + 1)(x − 1) + + + 8 3 4 24 3 2 = 2x + x − 5x + 1. Let us look at one more example. However, we shall be a little more systematic. Example 13.1.5. We wish to find a polynomial through the points (1, −3), (3, 3) and (4, 9). Try p(x) = a(x − 3)(x − 4) + b(x − 1)(x − 4) + c(x − 1)(x − 3). Substituting x = 1, x = 3, x = 4, we obtain respectively a= Hence p(x) = p(1) (x − 3)(x − 4) (x − 1)(x − 4) (x − 1)(x − 3) + p(3) + p(4) . (1 − 3)(1 − 4) (3 − 1)(3 − 4) (4 − 1)(4 − 3) p(1) , (1 − 3)(1 − 4) b= p(3) , (3 − 1)(3 − 4) c= p(4) . (4 − 1)(4 − 3) Since p(1) = −3, p(3) = 3 and p(4) = 9, a little calculation gives p(x) = x2 − x − 3. Consider now the general situation. Suppose that we wish to find a polynomial through the points (x1 , y1 ), . . . , (xk , yk ). Then it is not too difficult to see that the polynomial k k (1) p(x) = i=1 yi j =1 j =i x − xj xi − xj Chapter 13 : Interpolation and Approximation page 2 of 6 First Year Calculus c W W L Chen, 1987, 2005 satisfies the requirements. To see that, note that for every i = 1, . . . , k , we have k j =1 j =i x − xj xi − xj = 1 if x = xi , 0 if x = x1 , . . . , xi−1 , xi+1 , . . . , xk . The polynomial (1) is called the Lagrange interpolation polynomial. 13.2. Approximate Fitting Fitting the points exactly is unsatisfactory from the numerical point of view, particularly so when the number of points is large. We therefore sometimes attempt to fit all points closely but not exactly. After all, experimental data are subject to errors anyway! Consider a given set of n points (x1 , y1 ), . . . , (xn , yn ). We now attempt to fit these points with a polynomial p(x) = ak−1 xk−1 + ak−2 xk−2 + . . . + a0 . Recall that when k ≥ n, this can always be done; for example, simply take p(x) to be the Lagrange interpolation polynomial. However, if k < n, an exact fit may not be possible; for example, it is not possible to fit a straight line (k = 2) to go through three non-collinear points (n = 3) exactly. We therefore consider the errors i = |p(xi ) − yi |, where i = 1, . . . , n. The problem now is to choose a0 , . . . , ak−1 in such a way in order to make the errors small. There are many ways to make errors small, and the following are examples: n (A) Choose a0 , . . . , ak−1 to minimize i=1 i. i (B) Choose a0 , . . . , ak−1 to minimize max (C) Choose a0 , . . . , ak−1 to minimize 1≤i≤n n 2 i i=1 – minimax approximation. – least squares approximation. Remark. It is generally considered that (A) is the best criterion but most awkward, and that (C) is the least satisfactory criterion but easiest to use. An analogous problem to that discussed in the previous section is the question of approximating a function f (x) by a polynomial p(x) = ak−1 xk−1 + ak−2 xk−2 + . . . + a0 in an interval a ≤ x ≤ b. Here we consider the errors (x) = |p(x) − f (x)|, where a ≤ x ≤ b. The problem now is to choose a0 , . . . , ak−1 in such a way in order to make the errors small. There are many ways to make errors small, and the following are examples: b (A) Choose a0 , . . . , ak−1 to minimize a (x) dx. a≤x≤b b 2 a (B) Choose a0 , . . . , ak−1 to minimize max (x) – minimax approximation. (C) Choose a0 , . . . , ak−1 to minimize (x) dx – least squares approximation. Remark. As before, it is generally considered that (A) is the best criterion but most awkward, and that (C) is the least satisfactory criterion but easiest to use. Chapter 13 : Interpolation and Approximation page 3 of 6 First Year Calculus c W W L Chen, 1987, 2005 13.3. Minimax Approximation We shall illustrate the technique by two of the simplest examples. Example 13.3.1. Consider the points (1, −3), (3, 3) and (4, 9). It was shown in Example 13.1.5 that we can fit the polynomial x2 − x − 3 precisely. Suppose now that we wish to find a minimax approximation by a polynomial of degree 1 (linear minimax approximation). Suppose that p(x) = ax + b. We then consider the errors 1 2 3 = |p(x1 ) − y1 | = |a + b + 3|, = |p(x2 ) − y2 | = |3a + b − 3|, = |p(x3 ) − y3 | = |4a + b − 9|, and minimize max{|a + b + 3|, |3a + b − 3|, |4a + b − 9|}. If we take a = 4 and b = −8, then max{|a+b+3|, |3a+b−3|, |4a+b−9|} = 1. Hence p(x) = 4x−8 is a linear approximation with maximum error 1. It can be shown that this is the best minimax approximation by a polynomial of degree 1, but demonstrating this point is not so straightforward. Example 13.3.2. Consider the function f (x) = x2 in the interval 0 ≤ x ≤ 2. Suppose that we wish to find a minimax approximation by a polynomial of degree 1 (linear minimax approximation). Suppose that p(x) = ax + b. We then consider the errors (x) = |ax + b − x2 |, where 0 ≤ x ≤ 2. Consider first of all the function h(x) = ax + b − x2 . Then h(x) has a maximum value when dh/dx = 0. This occurs when x = a/2, and this is in the interval 0 ≤ x ≤ 2 provided that 0 ≤ a ≤ 4. Note that h(a/2) = a2 /4 + b. Also h(0) = b and h(2) = 2a + b − 4. We now choose a and b such that h(0) = h(2) < 0 < h a = −h(0) 2 (the reader should draw a picture of h(x) in the interval 0 ≤ x ≤ 2 to illustrate these special requirements). Then we must have b = 2a + b − 4 < 0 < a2 + b = −b, 4 so that a = 2 and b = −1/2. Hence the linear polynomial p(x) = 2x − 1/2 gives max (x) = 1 . 2 0≤x≤2 It should by now be clear that minimax approximations are rather awkward to use, even in the simplest cases. 13.4. Least Squares Approximation We shall illustrate the technique by two simple examples. Chapter 13 : Interpolation and Approximation page 4 of 6 First Year Calculus c W W L Chen, 1987, 2005 Example 13.4.1. Consider the points (1, 1), (2, 3), (3, 4), (4, 3), (5, 4) and (6, 2). Suppose that we wish to find a least squares approximation by a polynomial of degree 1 (linear least squares approximation). Suppose that p(x) = ax + b. We then consider the errors i = |p(xi ) − yi | = |axi + b − yi |, where i = 1, 2, 3, 4, 5, 6, and choose a and b so as to minimize 6 6 2 i i=1 S (a, b) = = i=1 (axi + b − yi )2 . Let us now think of S (a, b) as a function of the two variables a and b. We then must have 0= ∂S xi (axi + b − yi ), =2 ∂a i=1 ∂S =2 (axi + b − yi ), ∂b i=1 6 6 0= so that 6 6 6 x2 i i=1 6 a+ i=1 6 xi b= i=1 6 xi yi , yi . i=1 xi i=1 a+ i=1 1 b= Substituting for (xi , yi ) for i = 1, 2, 3, 4, 5, 6, we have 91a + 21b = 63, 21a + 6b = 17, so that a = 1/5 and b = 32/15. Hence p(x) = is the best linear least squares approximation. Example 13.4.2. As in Example 13.3.2, consider the function f (x) = x2 in the interval 0 ≤ x ≤ 2. Suppose that we wish to find a least squares approximation by a polynomial of degree 1 (linear least squares approximation). Suppose that p(x) = ax + b. We then consider the errors (x) = |ax + b − x2 |, and choose a and b so as to minimize 2 2 2 0 1 32 x+ 5 15 where 0 ≤ x ≤ 2, T (a, b) = (x) dx = 0 (ax + b − x2 )2 dx. Let us now think of T (a, b) as a function of the two variables a and b. We then must have 0= ∂T =2 ∂a 2 x(ax + b − x2 ) dx = 2 0 2 8 a + 2b − 4 , 3 8 3 , page 5 of 6 ∂T 0= =2 ∂b (ax + b − x2 ) dx = 2 2a + 2b − 0 Chapter 13 : Interpolation and Approximation First Year Calculus c W W L Chen, 1987, 2005 so that a = 2 and b = −2/3. Hence p(x) = 2x − is the best linear least squares approximation. In general, if we try to fit a polynomial p(x) = ak xk + . . . + a0 to n points (x1 , y1 ), . . . , (xn , yn ), then we choose a0 , . . . , ak to minimize n 2 3 S (a0 , . . . , ak ) = i=1 (p(xi ) − yi )2 . The requirement that ∂S = 0 for every j = 0, . . . , k ∂aj gives rise to a system of (k + 1) linear equations in the (k + 1) unknowns a0 , . . . , ak . If we try to fit a polynomial p(x) = ak xk + . . . + a0 to a given function f (x) in an interval a ≤ x ≤ b, then we choose a0 , . . . , ak to minimize b T (a0 , . . . , ak ) = a (p(x) − f (x))2 dx. The requirement that ∂T = 0 for every j = 0, . . . , k ∂aj gives rise to a system of (k + 1) linear equations in the (k + 1) unknowns a0 , . . . , ak . Hence the determination of the best least squares approximations amounts to nothing more than solving a system of linear equations. Squaring the errors removes any ambiguity on the sign of the errors. Problems for Chapter 13 1. Find a polynomial to pass through the points (−2, 99), (−1, 11), (0, 1), (1, 3) and (2, 47). 2. Find the best linear least squares approximation to the points (−2, 99), (−1, 11), (0, 1), (1, 3) and (2, 47). 3. Find the best linear least squares approximation to the function ex in the interval [0, 1]. Chapter 13 : Interpolation and Approximation page 6 of 6 ...
View Full Document

Ask a homework question - tutors are online