Chapter 4: Interpolation and Approximation. October 28, 2005

Size: px
Start display at page:

Download "Chapter 4: Interpolation and Approximation. October 28, 2005"

Transcription

1 Chapter 4: Interpolation and Approximation October 28, 2005

2 Outline Linear Interpolation Lagrange Interpolation Newton Interpolation and Divided Differences Interpolation Error Piecewise Polynomial Interpolation An Introduction To Splines Least Squares Concepts in Approximation

3 Linear Interpolation Interpolation: estimating intermediate values of the function if we only know its values at certain points x k (k = 0,..., n) Graphs produced by computers are generally obtained by piecewise linear polynomial interpolation, in which the machine draws a very large number of straight lines to represent the curve. Given a set of data points x k (nodes), we say that the polynomial p interpolates the function f at these nodes if p(x k ) = f (x k ) We want to see to what extent the approximation is accurate. p f

4 First, we will look at the case when p(x) is a linear polynomial We know that every straight line is determined by two points. We will assume that we are given two nodes x 0, x 1 and a function f. The equation of the line passing through the points (x 0, f (x 0 )) and (x 1, f (x 1 )) is p 1 (x) = x 1 x x 1 x 0 f (x 0 ) + x x 0 x 1 x 0 f (x 1 ) Easy to check: p 1 (x 0 ) = f (x 0 ) and p 1 (x 1 ) = f (x 1 ).

5 Example Suppose the data points are (1,1) and (4,2). The linear polynomial p 1 (x) is: p 1 (x) = 4 x x = x This polynomial will in fact approximate the function y = x from which the data points were taken.

6 Question: What is the accuracy of approximating f (x) by p 1 (x)? We will use Rolle s Theorem to get an answer. Define E(x) = f (x) p 1 (x) w(x) = (x x 0 )(x x 1 ) G(x) = E(x) w(x) w(t) E(t) where t is some fixed value in (x 0, x 1 ).

7 First, we notice that G(x 0 ) = 0, G(x 1 ) = 0, G(t) = 0 By Rolle s Theorem, there are points β 0 between x 0 and t, and β 1 between t and x 1, such that G (β 0 ) = 0, G(β 1 ) = 0. Using Rolle s Theorem again, we see that there is a point ξ between β 0 and β 1 such that G (ξ) = 0. However, so that G (x) = f (x) 2 w(t) E(t) G (ξ) = 0 f (ξ) 2 w(t) = 0.

8 The consequence of this computation is that we have f (t) p 1 (t) = 1 2 (t x 0)(t x 1 )f (ξ) for any point t [x 0, x 1 ] Then, for the error of this linear polynomial approximation, we get the following upper bound: f (x) p 1 (x) 1 2 (x x 0)(x x 1 ) max x 0 t x 1 f (t) 1 2 ( max x 0 t x 1 (t x 0 )(t x 1 ) )( max x 0 t x 1 f (t) ) So, in order to find an upper bound for the error, we need to maximize the function g(x) = (x x 0 )(x x 1 ) = (x 1 x)(x x 0 ) on the interval [x 0, x 1 ]

9 The critical point for this function is the midpoint of the interval x c = x 0 + x 1 2 Since the values at the endpoints are g(x 0 ) = g(x 1 ) = 0, the maximum absolute value is at x c, and it is equal to: g(x c ) = (x 1 x 0 ) 2. 4 Substituting this maximum value into an earlier formula for the error, we get: f (x) p 1 (x) 1 8 (x 1 x 0 ) 2 ( max x 0 x x 1 f (x) ).

10 Theorem (Linear Interpolation Error) Let f have the first two derivatives on [x 0, x 1 ] and let p 1 (x) be the linear polynomial that interpolates f at x 0 and x 1. Then, for all x [x 0, x 1 ], we have f (x) p 1 (x) 1 8 (x 1 x 0 ) 2 ( max x 0 x x 1 f (x) ).

11 Example Obtain the estimate of e using the function values e 0.82 = , e 0.83 = The linear interpolating polynomial is and p 1 (x) = (0.83 x) ( ) + (x 0.82) ( ) 0.01 p 1 (0.826) = Since f (x) = e x, the error estimate will be e p 1 (0.826) 1 8 (0.01)2 e 0.83 =

12 Example We want to construct a piecewise linear approximation to f (x) = log 2 (x) using the nodes: 1/4, 1/2, 1. We construct separate linear polynomials over each pair of adjacent nodes Q 1 (x) = ( 1 2 x) log 2 ( 1 4 ) + (x 1 4 ) log 2 ( 1 2 ) = 4x Q 2 (x) = (1 x) log 2 ( 1 2 ) + (x 1 2 ) log 2 (1) = 2x 2 1 2

13 So, the piecewise interpolating polynomial function is: { 4x 3, 1 q(x) = 4 x x 2, 2 x 1 To estimate the error, we calculate the errors of individual polynomials: log 2 (x) Q 1 (x) 1 8 (1 4 )2 max t [ 1 4, 1 2 ] log 2 (e)t 2 = log 2 (x) Q 2 (x) 1 8 (1 2 )2 max t [ 1 2,1] log 2 (e)t 2 = so the maximum error will be the maximum of the two errors (which are the same in this example) log 2 (x) q(x)

14 Quadratic Interpolation Most sets of data arise from the functions whose graphs are curved rather than straight lines. In order to approximate such functions better we need to use polynomials of degree greater than one. Assume we are given three different data points: (x 0, f (x 0 )), (x 1, f (x 1 )), (x 2, f (x 2 )). We want to find three quadratic polynomials L 0 (x), L 1 (x), and L 2 (x), such that our quadratic interpolating polynomial is p 2 (x) = y 0 L 0 (x) + y 1 L 1 (x) + y 2 L 2 (x)

15 One such choice for quadratic polynomials is: L 0 (x) = (x x 1)(x x 2 ) (x 0 x 1 )(x 0 x 2 ) L 1 (x) = (x x 0)(x x 2 ) (x 1 x 0 )(x 1 x 2 ) L 2 (x) = (x x 0)(x x 1 ) (x 2 x 0 )(x 2 x 1 ) Each polynomial L i (x) has degree 2, and so the polynomial p 2 (x) will be of degree at most 2. In addition, L i (x j ) = 0, L i (x i ) = 1 i j

16 We can write this succinctly as L i (x) = δ ij where δ ij is Kronecker s delta function defined as δ ij = Now, it is easy to show that { 1, i = j 0, i j p 2 (x i ) = f (x i ), i = 0, 1, 2

17 Example Given the data points (0,-1), (1,-1), and (2,7), the interpolating quadratic polynomial is p 2 (x) = (x 1)(x 2) ( 1) + 2 x(x 2) ( 1) + 1 x(x 1) (7) 2

18 In fact, using some facts from abstract algebra, one can show that the polynomial p 2 (x) is the unique quadratic polynomial p(x) such that p(x i ) = f (x i ), i = 0, 1, 2 Namely, if there were other such polynomial q(x), then the polynomial p 2 (x) q(x) is a non-zero polynomial of degree 2 which has three distinct roots: x 0, x 1, and x 2, which is impossible.

19 Example Now, we will try to find another approximation to e 0.826, this time using a quadratic interpolating polynomial, if we are given the values e 0.82 = , e 0.83 = , e 0.84 = Using the formula for p 2 (x) and the given set of data, we have: p 2 (0.826) = This is a significant improvement over the value since the actual value is: p 1 (0.826) = e

20 General Case Suppose we are given n + 1 distinct data points: (x 0, f (x 0 )), (x 1, f (x 1 )),..., (x n, f (x n )) We are looking for polynomials L i (x) of degree n such that p n (x) = f (x 0 )L(x) + f (x 1 )L(x 1 ) f (x n )L(x n ). These polynomials of degree n are given by L i (x) = (x x 0)... (x x i 1 )(x x i+1 )... (x x n ) (x i x 0 )... (x i x i 1 )(x i x i+1 )... (x i x n )

21 As before, it is easy to check that L i (x j ) = δ ij, 0 j n Direct computation shows that p n (x j ) = f (x j ), j = 0, 1,..., n This is called Lagrange s formula for the interpolating polynomial. Again, one can easily show that this is the unique interpolating polynomial of degree n for these n + 1 data points.

22 Theorem (Polynomial Interpolation - Existence and Uniqueness) Let the nodes x i (i = 0, 1,..., n) be given. As long as all x i are distinct, there is a unique polynomial p n of degree n such that p n (x i ) = f (x i ), 0 i n for a given function f.

23 Example Suppose f (x) = e x and consider the interval [-1,1]. We want to construct an approximation using the nodes x 0 = 1, x 1 = 1 2, x 2 = 0, x 3 = 1 2, x 4 = 1

24 p 4 (x) = (x )(x 0)(x 1 2 )(x 1) ( )( 1 0)( )( 1 1)e 1 (x + 1)(x 0)(x 1 2 )(x 1) + ( )( 1 2 0)( )( 1 2 1)e + (x + 1)(x )(x 1 2 )(x 1) (0 + 1)( )(0 1 e0 2 )(0 1) + (x + 1)(x )(x 0)(x 1) 1 ( )( )( 1 2 0)( 1 2 1)e 2 + (x + 1)(x )(x 0)(x 1 2 ) (1 + 1)( )(1 0)(1 1 2 ) e1 1 2

25 This polynomial simplifies to p 4 (x) = x x x x + 1

26 Question: What is the error when approximating f (x) by p n (x)? (will be answered later) Problem: Suppose we want to add a node to the set of data. Then, all L i (x) need to be recalculated, which is rather cumbersome, so Lagrange form of the interpolating polynomial is not suitable for actual computations. There is a far superior alternative construction of p n (x) which will be given in 4.2.

27 Newton Interpolation As we have seen in 4.1, given n + 1 distinct data points (x 0, f (x 0 )), (x 1, f (x 1 )),..., (x n, f (x n )) there is a unique polynomial of degree n that interpolates them. Lagrange interpolation formula doesn t work too well in practical computations. The reason for this is that, if we add another node we have to recompute all L i.

28 An alternative form of the polynomial, which is called the Newton form of the interpolation polynomial, avoids this problem and computes p n+1 (x) recursively from p n (x). Theorem (Newton Interpolation Construction) Let p n be the polynomial that interpolates f at the nodes x 0, x 1,..., x n and let p n+1 be the polynomial that interpolates f at teh nodes x 0, x 1,..., x n, x n+1. Then, p n+1 (x) = p n (x) + a n+1 w n (x) where w n (x) = a 0 = f (x 0 ) n (x x i ) i=0 a n+1 = f (x n+1) p n (x n+1 ) w n (x n+1 )

29 To show that this is true, it suffices to show that p n+1 (x 0 ) = f (x 0 ), p n+1 (x 1 ) = f (x 1 ),..., p n+1 (x n+1 ) = f (x n+1 ). For x 0, x 1,..., x n, we see that w n (x i ) = 0, (i = 0, 1,..., n) and p n+1 will interpolate f at those points. What is left to check is that p n+1 will interpolate f at x n+1 : p n+1 (x n+1 ) = p n (x n+1 ) + a n+1 w n (x n+1 ) = p n (x n+1 ) + f (x n+1 ) p n (x n+1 ) = f (x n+1 )

30 Newton form of the interpolating polynomial can be used to construct and evaluate interpolating polynomials in a much more efficient fashion. From the theorem, it follows that p n (x) = a 0 + a 1 (x x 0 ) + a 2 (x x 0 )(x x 1 ) a n (x x 0 )... (x x n 1 ) Another way to view this formula is as: p n (x) = where we take w 1 (x) = 1. n a k w k 1 (x), k=0 This formula can also be interpreted as the Horner s Rule for evaluating polynomials: p n (x) = a 0 +(x x 0 )(a 1 +(x x 1 )(a (x x n 1 )a n )...)).

31 Example Construct a quadratic polynomial that interpolates the function f (x) = sin x on the interval [0, π] using equally spaced nodes. Since the nodes are equally spaced,. Then, x 0 = 0, x 1 = π 2, x 2 = π a 0 = f (x 0 ) = 0 p 0 (x) = 0 a 1 = f (x 1) p 0 (x 1 ) w 0 (x 1 ) a 2 = f (x 2) p 1 (x 2 ) w 1 (x 2 ) = 1 0 π 2 0 = 2 π p 1(x) = π x 0 2 = (π 0)(π π 2 ) = 4 π 2

32 So, the interpolating polynomial is p 2 (x) = 2 π x 4 π 2 x(x π 2 )

33 Divided Differences The coefficients a k in Newton interpolation formula are called divided differences. Now, we will give a slightly different way of evaluating these coefficients which is suitable for computations done by hand. This approach is called constructing the Newton interpolation polynomial using the divided-difference table

34 The zeroth divided differences are simply the values of the function at the interpolating nodes: f 0 (x k ) = f (x k ), (k = 0, 1,..., n) The first divided differences are formed recursively from the zeroth ones as: f 1 (x k ) = f 0(x k+1 ) f 0 (x k ) x k+1 x k The second divided differences are then computed recursively as: f 2 (x k ) = f 1(x k+1 ) f 1 (x k ) x k+2 x k The general formula for the j-th divided difference is: f j (x k ) = f j 1(x k+1 ) f j 1 (x k ) x k+j x k

35 Example Suppose we wanted to interpolate the function using the three nodes f (x) = log 2 x, x 0 = 1, x 1 = 2, x 2 = 4. k x k f 0 (x k )

36 Next, we calculate the first divided differences: f 1 (x 0 ) = f (x 1) f (x 0 ) x 1 x 0 = = 1 f 1 (x 1 ) = f (x 2) f (x 1 ) x 2 x 1 = = 1 2 We enter these values into our divided difference table: k x k f 0 (x k ) f 1 (x k )

37 Finally, we calculate the second divided difference: f 2 (x 0 ) = f 1(x 1 ) f 1 (x 0 ) x 2 x 0 = = 1 6. k x k f 0 (x k ) f 1 (x k ) f 2 (x k )

38 Now, p 2 (x) can be derived in two ways from the table: If we use f 0 (x 0 ), f 1 (x 0 ), and f 2 (x 0 ) (the top diagonal row): p 2 (x) = (x 1) 1 6 (x 1)(x 2) = 1 (x 1)(x 8) 6 If we use the bottom diagonal row, i.e. the values f 0 (x 2 ), f 1 (x 1 ), and f 0 (x 0 ), we get: p 2 (x) = (x 4) 1 6 (x 4)(x 2) = 1 (x 1)(x 8) 6 Then, p 2 (1) = 0, p 2 (2) = 1, p 2 (4) = 2, so this is the correct interpolating polynomial.

39 Now, suppose we want to increase the accuracy of the polynomial by adding an additional node, for example, x 3 = 1 2, for which f (x 3 ) = 1. We can add that extra node to the table: k x k f 0 (x k ) f 1 (x k ) f 2 (x k )

40 Then, we compute f 1 (x 2 ), f 2 (x 1 ) and f 3 (x 0 ), and place them into the table: k x k f 0 (x k ) f 1 (x k ) f 2 (x k ) f 3 (x k ) So, the interpolating polynomial is p 3 (x) = (x 1) 1 6 (x 1)(x 2) + 1 (x 1)(x 2)(x 4) 7

41 Interpolation Error We have seen in 2.4 that the error of the linear interpolation polynomial can be estimated as f (x) p 1 (x) 1 8 (x 1 x 0 ) 2 max x 0 x x 1 f (x) Question: Is there a similar estimate for interpolation polynomials of arbitrary degree p n (x)?

42 Theorem (Polynomial Interpolation Error Theorem) Let f be a function with n + 1 derivatives on [a, b] and let the nodes x k [a, b], for k = 0, 1,..., n. Then, for each x [a, b], we can find a ξ [a, b] such that f (x) p n (x) = w n(x) (n + 1)! f (n+1) (ξ) where n w n (x) = (x x k ) k=0 The problem is that, often, we don t know the formula for f (x) so it is impossible to estimate the maximum of f (n+1) (x) on [a, b].

43 It would be useful to have a way of measuring the size of a function on [a, b]. This is done using the norm of a function. Definition (Function Norm) A function norm is any function that assigns to a function on [a, b] a non-negative number f so that: 1 f > 0 for any function that is not the constant-zero function on [a, b] 2 af = a f, for any constant a. 3 f + g f + g, for any two functions f and g.

44 Examples 1 The infinity (pointwise) norm: f = max f (x) x [a,b] 2 The 2-norm : b f 2 = a [f (x)] 2 dx

45 Example If f (x) = cos x on [0, π], then f = max f (x) = 1 x [0,π] π π ( ) 1 + cos(2x) π f 2 = cos 2 (x)dx = dx =

46 As we have already seen, f (x) p 1 (x) 1 8 (x 1 x 0 ) 2 max x 0 x x 1 f (x) Using the infinity norm, this can be rewritten as f (x) p 1 (x) 1 8 (x 1 x 0 ) 2 f Let s try to find an upper bound for the error of the quadratic interpolating polynomial.

47 By the theorem from the beginning of this section, f (x) p 2 (x) = 1 6 (x x 0)(x x 1 )(x x 2 )f (ξ) To get a reasonable upper bound, we will assume that the nodes are equally spaced: for some h > 0. Then, x 1 x 0 = x 2 x 1 = h (x x 0 )(x x 1 )(x x 2 ) = ((x x 1 )+h)(x x 1 )((x x 1 ) h) = t(t 2 h 2 where t = x x 1. Therefore, f (x) p 2 (x) 1 6 ( max h t h t(t2 h 2 ) ) max x 0 t x 2 f (t)

48 In order to maximize this estimate, we need to maximize on [ h, h]. t(t 2 h 2 ) We can either use the maximize command in Maple, or examine the critical points (by hand) and we get max h t h t2 (t h 2 ) = h3. So, the error of quadratic interpolation is bounded above by or f (x) p 2 (x) h3 max x [x 0,x 2 ] f (t) f (x) p 2 (x) h3 f where h is the spacing between the consecutive nodes.

49 Example What is the error in quadratic interpolation to f (x) = x using equally spaced nodes on the interval [ 1 4, 1]? Solution: Since the nodes are equally spaced, h = = The third derivative of the function is: so that Then, f = f (x) = 3 8 x 5 2 max f (x) = 3 x [1/4,1] 8 (1 4 ) = 32 = f (x) p 2 (x) ( ) =

50 In a similar fashion, one can show that the error of the cubic interpolating polynomial on [a, b], with equally spaced nodes is: f (x) p 3 (x) 1 24 h4 f (4)

51 Piecewise Polynomial Approximation Interpolation might not be the best tool for approximation if we let n, the degree of the interpolation polynomial p n (x) become large. One way to avoid that problem is to keep the order of the polynomial fixed and use different polynomials over different intervals. If we let the lengths of subintervals become increasingly smaller, this way of approximating the function will be very accurate.

52 The only problem with this approach (using piecewise interpolation) is that we are dealing with different polynomials. So, in addition to being given a certain set of nodes, we have to select a subset of the se nodes which will be the endpoints of the subintervals over which the polynomials will differ. This subset of the set of all nodes are called knots of piecewise interpolation. If all the polynomials over different subintervals have the fixed degree d, the knots will be x dj, 0 j m where m is the number of different polynomials we will use.

53 Example Suppose we want to construct a piecewise quadratic approximation to f (x) = sin(πx) using the nodes x k = k, k = 0, 1, 2,..., 6 6 Since every quadratic polynomial requires three nodes in this partition, there will be three separate polynomial approximations with the knots x 0, x 2, x 4, x 6 next, we construct the three quadratic polynomials.

54 The interval [x 0, x 2 ]: x k f 0 (x k ) f 1 (x k ) f 2 (x k ) / / The interpolating polynomial is p 2,1 (x) = x x(x 1 6 )

55 The interval [x 2, x 4 ]: x k f 0 (x k ) f 1 (x k ) f 2 (x k ) 1/ / / The interpolating polynomial is p 2,2 (x) = (x 1 3 ) (x 1 3 )(x 1 2 )

56 The interval [x 4, x 6 ]: x k f 0 (x k ) f 1 (x k ) f 2 (x k ) 2/ / The interpolating polynomial is p 2,3 (x) = (x 2 3 ) (x 2 3 )(x 5 6 )

57 The piecewise polynomial will be: x x(x 1 6 ), 0 x 1 3 q 2 (x) = (x 1 3 ) (x 1 3 )(x 1 2 ), 1 3 x (x 2 3 ) (x 2 3 )(x 5 6 ) 2 3 x 1

58 Error Estimate Theorem (Piecewise Polynomial Interpolation Error Estimate) Let f have a sufficient number of derivatives on [a, b] and let q d be the piecewise polynomial interpolant of degree d for f on [a, b], using n + 1 equally spaced nodes, where n = md. Then f q d C d h d+1 f (d+1), d = 1, 2, 3 where C 1 = 1/8, C 2 = 1/9 3, C 3 = 1/24

59 Definition of the Problem We have seen that piecewise polynomial interpolants produce fairly accurate approximations to the function, but their graphs may lack smoothness" at the nodes. This is of importance in e.g. computer graphics, since the graphs are generally generated using piecewise polynomial interpolation through a finite number of sample nodes. The piecewise function q d is continuous but its derivatives may not be. So, the graph may have kinks" at the points where two different polynomials are joined (knots) Splines provide a way to rectify this.

60 We are given a set of nodes x 0, x 1,..., x n We want all the polynomials to have the same degree d, which will be the degree of the approximation of the spline. We want to find a piecewise polynomial function q d which will satisfy three properties.

61 Properties of a spline: 1 Interpolation : q d (x k ) = f (x k ), 0 k n 2 Smoothness : lim x x k q (i) d (x) = lim x x + k q (i) d (x k) for 0 i N. This N is called the degree of smoothness of the spline. 3 q d is a polynomial of degree d on each subinterval [x k 1, x k ]

62 Question: How should we choose N, the degree of smoothness? By analyzing the properties of the spline, one can show that a good choice for the degree of smoothness is N = d 1 i.e. one less than the degree of the polynomial we use. For instance, if we use cubic polynomials (d = 3), we would have N = 2, so the first and the second derivatives of polynomials on neighbouring intervals have to agree at the junction nodes x k. We will also need to impose N extra conditions on the derivatives but we will deal with that later.

63 Example For what value of k is the following a spline function? { x q(x) = 3 + 3x 2 + 1, 1 x 0 x 3 + kx 2 + 1, 0 x 1 Solution: First, the values of the two polynomials have to agree at the junction point x = 0: lim x 0 (x 3 + 3x 2 + 1) = lim x 0 +( x 3 + kx 2 + 1) which is true for every value of k. Since d = 3 we have N = 2, and the limits of the first and the second derivatives have to agree at x = 0: lim x 0 (3x 2 + 6x) = lim x 0 +( 3x 2 + 2kx) lim x 0 + 6) = lim (6x +( 6x + 2k) x 0

64 The first equality is always true, while from the second equation we have k = 3 So, k = 3 will make q(x) a spline function.

65 Cubic Splines We will now show two different constructions for a cubic spline interpolation through the set of n + 1 nodes (x 0, y 0 ), (x 1, y 1 ),..., (x n, y n ) Suppose that cubic spline is q(x). Introduce n new variables M 1, M 2,..., M n as M i := q (x i ), (i = 1, 2,..., n) We want to produce a linear system for calculating M 1, M 2,..., M n.

66 On each interval [x j 1, x j ], the function q (x) is linear, and we can use linear interpolation to write the formula for q (x) on that interval: q (x) = (x j x)m j 1 + (x xj 1)M j x j x j 1 Then, we can integrate this linear function twice and use the interpolating conditions to get q(x j 1 ) = y j 1, q(x j ) = y j q(x) = (x j x) 3 M j 1 + (x x j 1 ) 3 M j 6(x j x j 1 ) for x j 1 x x j. + (x j x)y j 1 + (x x j 1 )y j x j x j (x j x j 1 )[(x j x)m j 1 + (x x j 1 )M j ]

67 To ensure the smoothness of the curve, we differentiate this last formula for q(x) to get q (x) and make sure that the values of q (x) on two adjacent intervals [x j 1, x j ] and [x j, x j+1 ] agree at x j. After some work, it can be shown that we have x j x j 1 M j x j+1 x j 1 3 M j + x j+1 x j 6 M j+1 = y j+1 y j x j+1 x j y j y j 1 x j x j 1 for j = 1, 2,..., n 1.

68 As we have mentioned earlier, since for a cubic spline N = 2, we need two extra conditions in order to be able to solve this system (the system has n 1 equations and n + 1 variables M j ) These two conditions can be imposed in two different ways: 1 Natural Spline: M 0 = M n = 0 (these two conditions will produce a tridiagonal system) 2 Complete Spline: q (x 0 ) = f (x 0 ) and q (x n ) = f (x n ) We prefer to use the natural spline, since, sometimes, we may not know the formula for f (x), so we cannot use f

69 Example Calculate the natural cubic spline interpolating the data (1, 1), (2, 1 2 ), (3, 1 3 ), (4, 1 4 ) Solution: The number of points is 4, and all x j x j 1 = 1, j = 1, 2, 3 The system of equations becomes 1 6 M M M 2 = M M M 3 = 1 12 Since M 0 = M 3 = 0, we reduce the system to: 2 3 M M 2 = M M 2 = 1 12

70 The solution is M 1 = 1 2, M 2 = 0 The resulting cubic spline is: q(x) = 1 12 x x x x x x x x x x 4

71 Example Construct a natural cubic spline approximation to f (x) = sin(πx) on the interval [0, 1/2] using the nodes x 0 = 0, x 1 = 1/4, and x 2 = 1/2. Solution: Here, n = 2, and we have the single equation: Since the spline is natural: 1 24 M M M 2 = M 0 = M 2 = 0 and M 1 = = 24(1 2).

72 Substituting M 0 = 0, M 1 = 24(1 2), M 2 = 0into the formula for q(x), we get: 16( 2 1)x 3 + (3 2 1)x 0 x 1/4 q(x) = 16( 2 1)x 3 8( 2 1)x 2 +( 2 + 1)x + ( 2 1)/2 1/4 x 1/2

73 Error of Spline Approximation Theorem (Spline Approximation) Suppose f has continuous first four derivatives on [a, b], and q interpolates f through the nodes a = x 0 < x 1 < x 2 <... < x n 1 < x n = b with max(x i x i 1 ) h for all i. Then, f q h4 f (4)

74 Example In our previous example, f (x) = sin(πx) on [0, 1/2]. Since h = 1/4 (the nodes are equally spaced) and f (4) (x) = π 4 sin(πx) we have so that f q f (4) = π 4, ( ) 1 4 π 4 =

75 An Introduction to Data Fitting Often, when we want to find a function representing the results of some experiment, we do not want to have a curve passing through every data point. The reason for this is that the experimental data is not entirely precise; there is some error due to the measurement, etc. Rather, we ant to get some sense of how the data points are distributed: is the pattern linear, quadratic, cubic, etc? The most common approach is least squares data fitting

76 We will start with the simplest case: suppose we are given a set of data (x k, y k ), k = 1, 2,..., n for which the plot would indicate that it s distributed linearly. We want to find a linear function y = mx + b which would fit this data best. How do we measuer how well this line would represent the given points? We try to minimize the sum of the squared distances between the points and the line: F(m, b) = n (y k (mx k + b)) 2 k=1 This is a function of two variables m and b which needs to be minimized for the right choice of these two parameters.

77 Take the partial derivatives with respect to both variables: F n m = 2 (y k (mx k + b))x k = 0 k=1 F n b = 2 (y k (mx k + b)) = 0 k=1 This simplifies to the system of two linear equations in m and b: n (y k (mx k + b))x k = 0 k=1 n (y k (mx k + b)) = 0 k=1

78 This is equivalent to: ( n ) ( n ) m + b x k = k=1 x 2 k k=1 ( n ) ( n ) m x k + b 1 = k=1 k=1 This gives us the formulas for m and b: m = n x k y k ( x k )( y k ) n( x 2 k ) ( x k ) 2 n x k y k k=1 n k=1 x k b = ( x 2 k )( y k ) ( x k )( x k y k ) n( x 2 k ) ( x k ) 2

79 Example Suppose we are given data x k y k Find the least squares linear linear fit to this data. Solution: We compute x k = 15, y k = 367, xk 2 = 55, x k y k = 1303 k=1 Therefore, The linear fit is: k=1 k=1 k=1 6(1303) m = 6(55) (15) 2 = b = 6(55) (15) 2 = y = x

80 Instead of using a linear function for the least squares approximation, one can use a polynomial of any other degree. Sometimes, this is necessary, since the distribution of data may not be linear. We will sketch how to find a quadratic least squares approximation for a given set of data points. You will use this in Exercises 1 and 2 from this section.

81 Suppose we are given n data points (x k, y k ), k = 1, 2,..., n which is clustered around the graph of some quadratic function y = ax 2 + bx + c Again, we try to minimize the sum of squared distances from the points to this parabola: F(a, b, c) = n (y k (axk 2 + bx k + c)) 2 k=1 This is a function of three variables a, b, and c, so we want to make the partial derivatives F a = F b = F c = 0

82 Taking the derivatives and simplifying, we get: n 2 (y k (axk 2 + bx k + c))xk 2 = 0 2 k=1 n (y k (axk 2 + bx k + c))x k = 0 k=1 2 n (y k (axk 2 + bx k + c)) = 0 k=1 This yields the system in a, b and c: a( x 4 k ) + b( x 3 k ) + c( x 2 k ) = x 2 k y k a( x 3 k ) + b( x 2 k ) + c( x k ) = x k y k a( x 2 k ) + b( x k ) + nc = y k

83 Least Squares Approximation and Orthogonal Polynomials Given two vectors x and y in R n, we defined their inner product as x y = x 1 y 1 + x 2 y x n y n This inner product can be generalized to functions on some fixed closed interval [a, b]

84 Definition (Inner Product for Real Functions) If f and g are two functions on an interval [a, b], then their inner product (f, g) is any function which has these three properties: 1 (f, f ) > 0 for any nonzero function f. 2 (f, αg 1 + βg 2 ) = α(f, g 1 ) + β(f, g 2 ) for any two constants α and β and any functions f, g 1, g 2. 3 (f, g) = (g, f ) for any two functions f and g.

85 Example Our main example is the weighted inner product: let w(x) 0 be a non-negative integrable function on [a, b]. Then we can define the inner product of f and g as (f, g) w = b a w(x)f (x)g(x)dx If we put w(x) = 1, we get the unweighted inner product (f, g) = b a f (x)g(x)dx

86 The weighted norm of f is defined as the square root of the inner product of f with itself: b f w = a w(x)f 2 (x)dx If we put w(x) = 1, then we have the 2-norm of the function which we have seen before: b f 2 = a f 2 (x)dx For example, if f (x) = e x and w(x) = x on [0,1], we have: 1 1 e e x w = (xe x e x )dx = (xe 2x 2 )dx = 4 = e 2 0 0

87 Definition Given a weighted inner product (f, g) w on [a, b], we say that f and g are othogonal if (f, g) w = b a w(x)f (x)g(x)dx = 0 For example, if f (x) = sin x, and g(x) = cos x and the inner product is unweighted, these two functions are orthogonal on [0, π]: π π sin(2x) sin x cos xdx = dx =

88 It can be shown that if we use the families of orthogonal polynomials, we get very good least squares approximations to a given function. There are different ways to generate these families of orthogonal polynomials (Laguerre polynomials, Chebyshev polynomials, Legendre polynomials, etc) and we will explain how to generate such family, the family of Legendre polynomials This can be used to approximate functions on the interval [-1,1]; this is not a major restriction, because [-1,1] can always be changed to any other interval [a, b] using a linear function.

89 Legendre polynomials are defined recursively as: P 0 (x) = 1 P n (x) = 1 n!2 n d n dx n [ (x 2 1) n] The first few Legendre polynomials are: etc. P 1 (x) = x P 2 (x) = 1 2 (3x 2 1) P 3 (x) = 1 2 (5x 3 3x) P 4 (x) = 1 8 (35x 4 30x 2 + 3)

90 It can be shown: 1 All distinct Legendre polynomials are pairwise orthogonal in the unweighted product on [ 1, 1] (P i (x), P j (x)) = 1 1 P i (x)p j (x)dx = 0 2 Every polynomial of degree n can be written as a unique linear combination of Legendre polynomials: Q(x) = c 0 P 0 (x) + c 1 P 1 (x) c n P n (x) where c i are some constants.

91 Question: Given a function f (x) on [ 1, 1] how do we approximate it by the sum of the form c 0 P 0 (x) + c 1 P 1 (x) c n P n (x)? We can calculate the coefficients c i using the following formula: c i = (f, P i) (P i, P i )

92 Example Suppose we want to find the cubic least squares approximation to f (x) = e x on [ 1, 1] We calculate the coefficients c 0, c 1, c 2, and c 3 : c 0 = 1 (ex, P 0 (x)) (P 0 (x), P 0 (x)) = 1 ex 1dx e e 1 1 = 1 1 1dx 2 = Similar calculation using integrals will show that the coefficients are c 1 = , c 2 = , c 3 =

93 So the best cubic least squares approximation to f (x) = e x on [ 1, 1] is: P 0 (x) P 1 (x) P 2 (x) P 3 (x) If we substitute the Legendre polynomials into this formula, we get x x x 3 It can actually be shown that the maximum distance between the graph of e x and this cubic polynomial is e x P = max [ 1,1] ex P(x) =

We consider the problem of finding a polynomial that interpolates a given set of values:

We consider the problem of finding a polynomial that interpolates a given set of values: Chapter 5 Interpolation 5. Polynomial Interpolation We consider the problem of finding a polynomial that interpolates a given set of values: x x 0 x... x n y y 0 y... y n where the x i are all distinct.

More information

3.1 Interpolation and the Lagrange Polynomial

3.1 Interpolation and the Lagrange Polynomial MATH 4073 Chapter 3 Interpolation and Polynomial Approximation Fall 2003 1 Consider a sample x x 0 x 1 x n y y 0 y 1 y n. Can we get a function out of discrete data above that gives a reasonable estimate

More information

INTERPOLATION. and y i = cos x i, i = 0, 1, 2 This gives us the three points. Now find a quadratic polynomial. p(x) = a 0 + a 1 x + a 2 x 2.

INTERPOLATION. and y i = cos x i, i = 0, 1, 2 This gives us the three points. Now find a quadratic polynomial. p(x) = a 0 + a 1 x + a 2 x 2. INTERPOLATION Interpolation is a process of finding a formula (often a polynomial) whose graph will pass through a given set of points (x, y). As an example, consider defining and x 0 = 0, x 1 = π/4, x

More information

Scientific Computing

Scientific Computing 2301678 Scientific Computing Chapter 2 Interpolation and Approximation Paisan Nakmahachalasint Paisan.N@chula.ac.th Chapter 2 Interpolation and Approximation p. 1/66 Contents 1. Polynomial interpolation

More information

Chapter 3: Root Finding. September 26, 2005

Chapter 3: Root Finding. September 26, 2005 Chapter 3: Root Finding September 26, 2005 Outline 1 Root Finding 2 3.1 The Bisection Method 3 3.2 Newton s Method: Derivation and Examples 4 3.3 How To Stop Newton s Method 5 3.4 Application: Division

More information

Lectures 9-10: Polynomial and piecewise polynomial interpolation

Lectures 9-10: Polynomial and piecewise polynomial interpolation Lectures 9-1: Polynomial and piecewise polynomial interpolation Let f be a function, which is only known at the nodes x 1, x,, x n, ie, all we know about the function f are its values y j = f(x j ), j

More information

Mathematics for Engineers. Numerical mathematics

Mathematics for Engineers. Numerical mathematics Mathematics for Engineers Numerical mathematics Integers Determine the largest representable integer with the intmax command. intmax ans = int32 2147483647 2147483647+1 ans = 2.1475e+09 Remark The set

More information

Interpolation Theory

Interpolation Theory Numerical Analysis Massoud Malek Interpolation Theory The concept of interpolation is to select a function P (x) from a given class of functions in such a way that the graph of y P (x) passes through the

More information

November 20, Interpolation, Extrapolation & Polynomial Approximation

November 20, Interpolation, Extrapolation & Polynomial Approximation Interpolation, Extrapolation & Polynomial Approximation November 20, 2016 Introduction In many cases we know the values of a function f (x) at a set of points x 1, x 2,..., x N, but we don t have the analytic

More information

Scientific Computing: An Introductory Survey

Scientific Computing: An Introductory Survey Scientific Computing: An Introductory Survey Chapter 7 Interpolation Prof. Michael T. Heath Department of Computer Science University of Illinois at Urbana-Champaign Copyright c 2002. Reproduction permitted

More information

Lecture 10 Polynomial interpolation

Lecture 10 Polynomial interpolation Lecture 10 Polynomial interpolation Weinan E 1,2 and Tiejun Li 2 1 Department of Mathematics, Princeton University, weinan@princeton.edu 2 School of Mathematical Sciences, Peking University, tieli@pku.edu.cn

More information

Outline. 1 Interpolation. 2 Polynomial Interpolation. 3 Piecewise Polynomial Interpolation

Outline. 1 Interpolation. 2 Polynomial Interpolation. 3 Piecewise Polynomial Interpolation Outline Interpolation 1 Interpolation 2 3 Michael T. Heath Scientific Computing 2 / 56 Interpolation Motivation Choosing Interpolant Existence and Uniqueness Basic interpolation problem: for given data

More information

Approximation theory

Approximation theory Approximation theory Xiaojing Ye, Math & Stat, Georgia State University Spring 2019 Numerical Analysis II Xiaojing Ye, Math & Stat, Georgia State University 1 1 1.3 6 8.8 2 3.5 7 10.1 Least 3squares 4.2

More information

Lecture Note 3: Interpolation and Polynomial Approximation. Xiaoqun Zhang Shanghai Jiao Tong University

Lecture Note 3: Interpolation and Polynomial Approximation. Xiaoqun Zhang Shanghai Jiao Tong University Lecture Note 3: Interpolation and Polynomial Approximation Xiaoqun Zhang Shanghai Jiao Tong University Last updated: October 10, 2015 2 Contents 1.1 Introduction................................ 3 1.1.1

More information

A first order divided difference

A first order divided difference A first order divided difference For a given function f (x) and two distinct points x 0 and x 1, define f [x 0, x 1 ] = f (x 1) f (x 0 ) x 1 x 0 This is called the first order divided difference of f (x).

More information

LECTURE NOTES ELEMENTARY NUMERICAL METHODS. Eusebius Doedel

LECTURE NOTES ELEMENTARY NUMERICAL METHODS. Eusebius Doedel LECTURE NOTES on ELEMENTARY NUMERICAL METHODS Eusebius Doedel TABLE OF CONTENTS Vector and Matrix Norms 1 Banach Lemma 20 The Numerical Solution of Linear Systems 25 Gauss Elimination 25 Operation Count

More information

c) xy 3 = cos(7x +5y), y 0 = y3 + 7 sin(7x +5y) 3xy sin(7x +5y) d) xe y = sin(xy), y 0 = ey + y cos(xy) x(e y cos(xy)) e) y = x ln(3x + 5), y 0

c) xy 3 = cos(7x +5y), y 0 = y3 + 7 sin(7x +5y) 3xy sin(7x +5y) d) xe y = sin(xy), y 0 = ey + y cos(xy) x(e y cos(xy)) e) y = x ln(3x + 5), y 0 Some Math 35 review problems With answers 2/6/2005 The following problems are based heavily on problems written by Professor Stephen Greenfield for his Math 35 class in spring 2005. His willingness to

More information

Lecture Note 3: Polynomial Interpolation. Xiaoqun Zhang Shanghai Jiao Tong University

Lecture Note 3: Polynomial Interpolation. Xiaoqun Zhang Shanghai Jiao Tong University Lecture Note 3: Polynomial Interpolation Xiaoqun Zhang Shanghai Jiao Tong University Last updated: October 24, 2013 1.1 Introduction We first look at some examples. Lookup table for f(x) = 2 π x 0 e x2

More information

(0, 0), (1, ), (2, ), (3, ), (4, ), (5, ), (6, ).

(0, 0), (1, ), (2, ), (3, ), (4, ), (5, ), (6, ). 1 Interpolation: The method of constructing new data points within the range of a finite set of known data points That is if (x i, y i ), i = 1, N are known, with y i the dependent variable and x i [x

More information

Preliminaries Lectures. Dr. Abdulla Eid. Department of Mathematics MATHS 101: Calculus I

Preliminaries Lectures. Dr. Abdulla Eid. Department of Mathematics   MATHS 101: Calculus I Preliminaries 2 1 2 Lectures Department of Mathematics http://www.abdullaeid.net/maths101 MATHS 101: Calculus I (University of Bahrain) Prelim 1 / 35 Pre Calculus MATHS 101: Calculus MATHS 101 is all about

More information

b n x n + b n 1 x n b 1 x + b 0

b n x n + b n 1 x n b 1 x + b 0 Math Partial Fractions Stewart 7.4 Integrating basic rational functions. For a function f(x), we have examined several algebraic methods for finding its indefinite integral (antiderivative) F (x) = f(x)

More information

Georgia Department of Education Common Core Georgia Performance Standards Framework CCGPS Advanced Algebra Unit 2

Georgia Department of Education Common Core Georgia Performance Standards Framework CCGPS Advanced Algebra Unit 2 Polynomials Patterns Task 1. To get an idea of what polynomial functions look like, we can graph the first through fifth degree polynomials with leading coefficients of 1. For each polynomial function,

More information

COURSE Numerical integration of functions (continuation) 3.3. The Romberg s iterative generation method

COURSE Numerical integration of functions (continuation) 3.3. The Romberg s iterative generation method COURSE 7 3. Numerical integration of functions (continuation) 3.3. The Romberg s iterative generation method The presence of derivatives in the remainder difficulties in applicability to practical problems

More information

Section 0.2 & 0.3 Worksheet. Types of Functions

Section 0.2 & 0.3 Worksheet. Types of Functions MATH 1142 NAME Section 0.2 & 0.3 Worksheet Types of Functions Now that we have discussed what functions are and some of their characteristics, we will explore different types of functions. Section 0.2

More information

CS 450 Numerical Analysis. Chapter 8: Numerical Integration and Differentiation

CS 450 Numerical Analysis. Chapter 8: Numerical Integration and Differentiation Lecture slides based on the textbook Scientific Computing: An Introductory Survey by Michael T. Heath, copyright c 2018 by the Society for Industrial and Applied Mathematics. http://www.siam.org/books/cl80

More information

8.7 MacLaurin Polynomials

8.7 MacLaurin Polynomials 8.7 maclaurin polynomials 67 8.7 MacLaurin Polynomials In this chapter you have learned to find antiderivatives of a wide variety of elementary functions, but many more such functions fail to have an antiderivative

More information

n 1 f n 1 c 1 n+1 = c 1 n $ c 1 n 1. After taking logs, this becomes

n 1 f n 1 c 1 n+1 = c 1 n $ c 1 n 1. After taking logs, this becomes Root finding: 1 a The points {x n+1, }, {x n, f n }, {x n 1, f n 1 } should be co-linear Say they lie on the line x + y = This gives the relations x n+1 + = x n +f n = x n 1 +f n 1 = Eliminating α and

More information

The Closed Form Reproducing Polynomial Particle Shape Functions for Meshfree Particle Methods

The Closed Form Reproducing Polynomial Particle Shape Functions for Meshfree Particle Methods The Closed Form Reproducing Polynomial Particle Shape Functions for Meshfree Particle Methods by Hae-Soo Oh Department of Mathematics, University of North Carolina at Charlotte, Charlotte, NC 28223 June

More information

DRAFT - Math 101 Lecture Note - Dr. Said Algarni

DRAFT - Math 101 Lecture Note - Dr. Said Algarni 2 Limits 2.1 The Tangent Problems The word tangent is derived from the Latin word tangens, which means touching. A tangent line to a curve is a line that touches the curve and a secant line is a line that

More information

1 Roots of polynomials

1 Roots of polynomials CS348a: Computer Graphics Handout #18 Geometric Modeling Original Handout #13 Stanford University Tuesday, 9 November 1993 Original Lecture #5: 14th October 1993 Topics: Polynomials Scribe: Mark P Kust

More information

Numerical Analysis: Interpolation Part 1

Numerical Analysis: Interpolation Part 1 Numerical Analysis: Interpolation Part 1 Computer Science, Ben-Gurion University (slides based mostly on Prof. Ben-Shahar s notes) 2018/2019, Fall Semester BGU CS Interpolation (ver. 1.00) AY 2018/2019,

More information

Input: A set (x i -yy i ) data. Output: Function value at arbitrary point x. What for x = 1.2?

Input: A set (x i -yy i ) data. Output: Function value at arbitrary point x. What for x = 1.2? Applied Numerical Analysis Interpolation Lecturer: Emad Fatemizadeh Interpolation Input: A set (x i -yy i ) data. Output: Function value at arbitrary point x. 0 1 4 1-3 3 9 What for x = 1.? Interpolation

More information

Department of Applied Mathematics and Theoretical Physics. AMA 204 Numerical analysis. Exam Winter 2004

Department of Applied Mathematics and Theoretical Physics. AMA 204 Numerical analysis. Exam Winter 2004 Department of Applied Mathematics and Theoretical Physics AMA 204 Numerical analysis Exam Winter 2004 The best six answers will be credited All questions carry equal marks Answer all parts of each question

More information

g(t) = f(x 1 (t),..., x n (t)).

g(t) = f(x 1 (t),..., x n (t)). Reading: [Simon] p. 313-333, 833-836. 0.1 The Chain Rule Partial derivatives describe how a function changes in directions parallel to the coordinate axes. Now we shall demonstrate how the partial derivatives

More information

10/22/16. 1 Math HL - Santowski SKILLS REVIEW. Lesson 15 Graphs of Rational Functions. Lesson Objectives. (A) Rational Functions

10/22/16. 1 Math HL - Santowski SKILLS REVIEW. Lesson 15 Graphs of Rational Functions. Lesson Objectives. (A) Rational Functions Lesson 15 Graphs of Rational Functions SKILLS REVIEW! Use function composition to prove that the following two funtions are inverses of each other. 2x 3 f(x) = g(x) = 5 2 x 1 1 2 Lesson Objectives! The

More information

CHAPTER 4. Interpolation

CHAPTER 4. Interpolation CHAPTER 4 Interpolation 4.1. Introduction We will cover sections 4.1 through 4.12 in the book. Read section 4.1 in the book on your own. The basic problem of one-dimensional interpolation is this: Given

More information

Fixed point iteration and root finding

Fixed point iteration and root finding Fixed point iteration and root finding The sign function is defined as x > 0 sign(x) = 0 x = 0 x < 0. It can be evaluated via an iteration which is useful for some problems. One such iteration is given

More information

i x i y i

i x i y i Department of Mathematics MTL107: Numerical Methods and Computations Exercise Set 8: Approximation-Linear Least Squares Polynomial approximation, Chebyshev Polynomial approximation. 1. Compute the linear

More information

you expect to encounter difficulties when trying to solve A x = b? 4. A composite quadrature rule has error associated with it in the following form

you expect to encounter difficulties when trying to solve A x = b? 4. A composite quadrature rule has error associated with it in the following form Qualifying exam for numerical analysis (Spring 2017) Show your work for full credit. If you are unable to solve some part, attempt the subsequent parts. 1. Consider the following finite difference: f (0)

More information

Preliminary Examination in Numerical Analysis

Preliminary Examination in Numerical Analysis Department of Applied Mathematics Preliminary Examination in Numerical Analysis August 7, 06, 0 am pm. Submit solutions to four (and no more) of the following six problems. Show all your work, and justify

More information

SPLINE INTERPOLATION

SPLINE INTERPOLATION Spline Background SPLINE INTERPOLATION Problem: high degree interpolating polynomials often have extra oscillations. Example: Runge function f(x = 1 1+4x 2, x [ 1, 1]. 1 1/(1+4x 2 and P 8 (x and P 16 (x

More information

OR MSc Maths Revision Course

OR MSc Maths Revision Course OR MSc Maths Revision Course Tom Byrne School of Mathematics University of Edinburgh t.m.byrne@sms.ed.ac.uk 15 September 2017 General Information Today JCMB Lecture Theatre A, 09:30-12:30 Mathematics revision

More information

Math Numerical Analysis Mid-Term Test Solutions

Math Numerical Analysis Mid-Term Test Solutions Math 400 - Numerical Analysis Mid-Term Test Solutions. Short Answers (a) A sufficient and necessary condition for the bisection method to find a root of f(x) on the interval [a,b] is f(a)f(b) < 0 or f(a)

More information

MA2501 Numerical Methods Spring 2015

MA2501 Numerical Methods Spring 2015 Norwegian University of Science and Technology Department of Mathematics MA5 Numerical Methods Spring 5 Solutions to exercise set 9 Find approximate values of the following integrals using the adaptive

More information

Two hours. To be provided by Examinations Office: Mathematical Formula Tables. THE UNIVERSITY OF MANCHESTER. 29 May :45 11:45

Two hours. To be provided by Examinations Office: Mathematical Formula Tables. THE UNIVERSITY OF MANCHESTER. 29 May :45 11:45 Two hours MATH20602 To be provided by Examinations Office: Mathematical Formula Tables. THE UNIVERSITY OF MANCHESTER NUMERICAL ANALYSIS 1 29 May 2015 9:45 11:45 Answer THREE of the FOUR questions. If more

More information

Numerical Integration (Quadrature) Another application for our interpolation tools!

Numerical Integration (Quadrature) Another application for our interpolation tools! Numerical Integration (Quadrature) Another application for our interpolation tools! Integration: Area under a curve Curve = data or function Integrating data Finite number of data points spacing specified

More information

1 Lecture 8: Interpolating polynomials.

1 Lecture 8: Interpolating polynomials. 1 Lecture 8: Interpolating polynomials. 1.1 Horner s method Before turning to the main idea of this part of the course, we consider how to evaluate a polynomial. Recall that a polynomial is an expression

More information

Interpolation. 1. Judd, K. Numerical Methods in Economics, Cambridge: MIT Press. Chapter

Interpolation. 1. Judd, K. Numerical Methods in Economics, Cambridge: MIT Press. Chapter Key References: Interpolation 1. Judd, K. Numerical Methods in Economics, Cambridge: MIT Press. Chapter 6. 2. Press, W. et. al. Numerical Recipes in C, Cambridge: Cambridge University Press. Chapter 3

More information

Calculus I (Math 241) (In Progress)

Calculus I (Math 241) (In Progress) Calculus I (Math 241) (In Progress) The following is a collection of Calculus I (Math 241) problems. Students may expect that their final exam is comprised, more or less, of one problem from each section,

More information

Homework and Computer Problems for Math*2130 (W17).

Homework and Computer Problems for Math*2130 (W17). Homework and Computer Problems for Math*2130 (W17). MARCUS R. GARVIE 1 December 21, 2016 1 Department of Mathematics & Statistics, University of Guelph NOTES: These questions are a bare minimum. You should

More information

(a) Write down the value of q and of r. (2) Write down the equation of the axis of symmetry. (1) (c) Find the value of p. (3) (Total 6 marks)

(a) Write down the value of q and of r. (2) Write down the equation of the axis of symmetry. (1) (c) Find the value of p. (3) (Total 6 marks) 1. Let f(x) = p(x q)(x r). Part of the graph of f is shown below. The graph passes through the points ( 2, 0), (0, 4) and (4, 0). (a) Write down the value of q and of r. (b) Write down the equation of

More information

Computational Physics

Computational Physics Interpolation, Extrapolation & Polynomial Approximation Lectures based on course notes by Pablo Laguna and Kostas Kokkotas revamped by Deirdre Shoemaker Spring 2014 Introduction In many cases, a function

More information

Legendre s Equation. PHYS Southern Illinois University. October 18, 2016

Legendre s Equation. PHYS Southern Illinois University. October 18, 2016 Legendre s Equation PHYS 500 - Southern Illinois University October 18, 2016 PHYS 500 - Southern Illinois University Legendre s Equation October 18, 2016 1 / 11 Legendre s Equation Recall We are trying

More information

Examination paper for TMA4215 Numerical Mathematics

Examination paper for TMA4215 Numerical Mathematics Department of Mathematical Sciences Examination paper for TMA425 Numerical Mathematics Academic contact during examination: Trond Kvamsdal Phone: 93058702 Examination date: 6th of December 207 Examination

More information

Math 2: Algebra 2, Geometry and Statistics Ms. Sheppard-Brick Chapter 4 Test Review

Math 2: Algebra 2, Geometry and Statistics Ms. Sheppard-Brick Chapter 4 Test Review Chapter 4 Test Review Students will be able to (SWBAT): Write an explicit and a recursive function rule for a linear table of values. Write an explicit function rule for a quadratic table of values. Determine

More information

Interpolation. Chapter Interpolation. 7.2 Existence, Uniqueness and conditioning

Interpolation. Chapter Interpolation. 7.2 Existence, Uniqueness and conditioning 76 Chapter 7 Interpolation 7.1 Interpolation Definition 7.1.1. Interpolation of a given function f defined on an interval [a,b] by a polynomial p: Given a set of specified points {(t i,y i } n with {t

More information

Numerical Methods I: Polynomial Interpolation

Numerical Methods I: Polynomial Interpolation 1/31 Numerical Methods I: Polynomial Interpolation Georg Stadler Courant Institute, NYU stadler@cims.nyu.edu November 16, 2017 lassical polynomial interpolation Given f i := f(t i ), i =0,...,n, we would

More information

Numerical integration and differentiation. Unit IV. Numerical Integration and Differentiation. Plan of attack. Numerical integration.

Numerical integration and differentiation. Unit IV. Numerical Integration and Differentiation. Plan of attack. Numerical integration. Unit IV Numerical Integration and Differentiation Numerical integration and differentiation quadrature classical formulas for equally spaced nodes improper integrals Gaussian quadrature and orthogonal

More information

LEAST SQUARES APPROXIMATION

LEAST SQUARES APPROXIMATION LEAST SQUARES APPROXIMATION One more approach to approximating a function f (x) on an interval a x b is to seek an approximation p(x) with a small average error over the interval of approximation. A convenient

More information

MATH 1902: Mathematics for the Physical Sciences I

MATH 1902: Mathematics for the Physical Sciences I MATH 1902: Mathematics for the Physical Sciences I Dr Dana Mackey School of Mathematical Sciences Room A305 A Email: Dana.Mackey@dit.ie Dana Mackey (DIT) MATH 1902 1 / 46 Module content/assessment Functions

More information

Math 651 Introduction to Numerical Analysis I Fall SOLUTIONS: Homework Set 1

Math 651 Introduction to Numerical Analysis I Fall SOLUTIONS: Homework Set 1 ath 651 Introduction to Numerical Analysis I Fall 2010 SOLUTIONS: Homework Set 1 1. Consider the polynomial f(x) = x 2 x 2. (a) Find P 1 (x), P 2 (x) and P 3 (x) for f(x) about x 0 = 0. What is the relation

More information

March Algebra 2 Question 1. March Algebra 2 Question 1

March Algebra 2 Question 1. March Algebra 2 Question 1 March Algebra 2 Question 1 If the statement is always true for the domain, assign that part a 3. If it is sometimes true, assign it a 2. If it is never true, assign it a 1. Your answer for this question

More information

8.7 Taylor s Inequality Math 2300 Section 005 Calculus II. f(x) = ln(1 + x) f(0) = 0

8.7 Taylor s Inequality Math 2300 Section 005 Calculus II. f(x) = ln(1 + x) f(0) = 0 8.7 Taylor s Inequality Math 00 Section 005 Calculus II Name: ANSWER KEY Taylor s Inequality: If f (n+) is continuous and f (n+) < M between the center a and some point x, then f(x) T n (x) M x a n+ (n

More information

NUMERICAL METHODS. x n+1 = 2x n x 2 n. In particular: which of them gives faster convergence, and why? [Work to four decimal places.

NUMERICAL METHODS. x n+1 = 2x n x 2 n. In particular: which of them gives faster convergence, and why? [Work to four decimal places. NUMERICAL METHODS 1. Rearranging the equation x 3 =.5 gives the iterative formula x n+1 = g(x n ), where g(x) = (2x 2 ) 1. (a) Starting with x = 1, compute the x n up to n = 6, and describe what is happening.

More information

Introduction Linear system Nonlinear equation Interpolation

Introduction Linear system Nonlinear equation Interpolation Interpolation Interpolation is the process of estimating an intermediate value from a set of discrete or tabulated values. Suppose we have the following tabulated values: y y 0 y 1 y 2?? y 3 y 4 y 5 x

More information

Math 660-Lecture 15: Finite element spaces (I)

Math 660-Lecture 15: Finite element spaces (I) Math 660-Lecture 15: Finite element spaces (I) (Chapter 3, 4.2, 4.3) Before we introduce the concrete spaces, let s first of all introduce the following important lemma. Theorem 1. Let V h consists of

More information

x 3y 2z = 6 1.2) 2x 4y 3z = 8 3x + 6y + 8z = 5 x + 3y 2z + 5t = 4 1.5) 2x + 8y z + 9t = 9 3x + 5y 12z + 17t = 7

x 3y 2z = 6 1.2) 2x 4y 3z = 8 3x + 6y + 8z = 5 x + 3y 2z + 5t = 4 1.5) 2x + 8y z + 9t = 9 3x + 5y 12z + 17t = 7 Linear Algebra and its Applications-Lab 1 1) Use Gaussian elimination to solve the following systems x 1 + x 2 2x 3 + 4x 4 = 5 1.1) 2x 1 + 2x 2 3x 3 + x 4 = 3 3x 1 + 3x 2 4x 3 2x 4 = 1 x + y + 2z = 4 1.4)

More information

(f(x) P 3 (x)) dx. (a) The Lagrange formula for the error is given by

(f(x) P 3 (x)) dx. (a) The Lagrange formula for the error is given by 1. QUESTION (a) Given a nth degree Taylor polynomial P n (x) of a function f(x), expanded about x = x 0, write down the Lagrange formula for the truncation error, carefully defining all its elements. How

More information

Functions and Equations

Functions and Equations Canadian Mathematics Competition An activity of the Centre for Education in Mathematics and Computing, University of Waterloo, Waterloo, Ontario Euclid eworkshop # Functions and Equations c 006 CANADIAN

More information

Week 1: need to know. November 14, / 20

Week 1: need to know. November 14, / 20 Week 1: need to know How to find domains and ranges, operations on functions (addition, subtraction, multiplication, division, composition), behaviors of functions (even/odd/ increasing/decreasing), library

More information

Math 180, Exam 2, Practice Fall 2009 Problem 1 Solution. f(x) = arcsin(2x + 1) = sin 1 (3x + 1), lnx

Math 180, Exam 2, Practice Fall 2009 Problem 1 Solution. f(x) = arcsin(2x + 1) = sin 1 (3x + 1), lnx Math 80, Exam, Practice Fall 009 Problem Solution. Differentiate the functions: (do not simplify) f(x) = x ln(x + ), f(x) = xe x f(x) = arcsin(x + ) = sin (3x + ), f(x) = e3x lnx Solution: For the first

More information

Dr. Sophie Marques. MAM1020S Tutorial 8 August Divide. 1. 6x 2 + x 15 by 3x + 5. Solution: Do a long division show your work.

Dr. Sophie Marques. MAM1020S Tutorial 8 August Divide. 1. 6x 2 + x 15 by 3x + 5. Solution: Do a long division show your work. Dr. Sophie Marques MAM100S Tutorial 8 August 017 1. Divide 1. 6x + x 15 by 3x + 5. 6x + x 15 = (x 3)(3x + 5) + 0. 1a 4 17a 3 + 9a + 7a 6 by 3a 1a 4 17a 3 + 9a + 7a 6 = (4a 3 3a + a + 3)(3a ) + 0 3. 1a

More information

Cubic Splines MATH 375. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Cubic Splines

Cubic Splines MATH 375. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Cubic Splines Cubic Splines MATH 375 J. Robert Buchanan Department of Mathematics Fall 2006 Introduction Given data {(x 0, f(x 0 )), (x 1, f(x 1 )),...,(x n, f(x n ))} which we wish to interpolate using a polynomial...

More information

PART I Lecture Notes on Numerical Solution of Root Finding Problems MATH 435

PART I Lecture Notes on Numerical Solution of Root Finding Problems MATH 435 PART I Lecture Notes on Numerical Solution of Root Finding Problems MATH 435 Professor Biswa Nath Datta Department of Mathematical Sciences Northern Illinois University DeKalb, IL. 60115 USA E mail: dattab@math.niu.edu

More information

GENG2140, S2, 2012 Week 7: Curve fitting

GENG2140, S2, 2012 Week 7: Curve fitting GENG2140, S2, 2012 Week 7: Curve fitting Curve fitting is the process of constructing a curve, or mathematical function, f(x) that has the best fit to a series of data points Involves fitting lines and

More information

Calculus I Sample Exam #01

Calculus I Sample Exam #01 Calculus I Sample Exam #01 1. Sketch the graph of the function and define the domain and range. 1 a) f( x) 3 b) g( x) x 1 x c) hx ( ) x x 1 5x6 d) jx ( ) x x x 3 6 . Evaluate the following. a) 5 sin 6

More information

1 Piecewise Cubic Interpolation

1 Piecewise Cubic Interpolation Piecewise Cubic Interpolation Typically the problem with piecewise linear interpolation is the interpolant is not differentiable as the interpolation points (it has a kinks at every interpolation point)

More information

Chapter 1 Numerical approximation of data : interpolation, least squares method

Chapter 1 Numerical approximation of data : interpolation, least squares method Chapter 1 Numerical approximation of data : interpolation, least squares method I. Motivation 1 Approximation of functions Evaluation of a function Which functions (f : R R) can be effectively evaluated

More information

Section 10.7 Taylor series

Section 10.7 Taylor series Section 10.7 Taylor series 1. Common Maclaurin series 2. s and approximations with Taylor polynomials 3. Multiplication and division of power series Math 126 Enhanced 10.7 Taylor Series The University

More information

University of Houston, Department of Mathematics Numerical Analysis, Fall 2005

University of Houston, Department of Mathematics Numerical Analysis, Fall 2005 4 Interpolation 4.1 Polynomial interpolation Problem: LetP n (I), n ln, I := [a,b] lr, be the linear space of polynomials of degree n on I, P n (I) := { p n : I lr p n (x) = n i=0 a i x i, a i lr, 0 i

More information

Q 0 x if x 0 x x 1. S 1 x if x 1 x x 2. i 0,1,...,n 1, and L x L n 1 x if x n 1 x x n

Q 0 x if x 0 x x 1. S 1 x if x 1 x x 2. i 0,1,...,n 1, and L x L n 1 x if x n 1 x x n . - Piecewise Linear-Quadratic Interpolation Piecewise-polynomial Approximation: Problem: Givenn pairs of data points x i, y i, i,,...,n, find a piecewise-polynomial Sx S x if x x x Sx S x if x x x 2 :

More information

Math 241 Homework 7 Solutions

Math 241 Homework 7 Solutions Math 241 Homework 7 s Section 4.2 Problem 1. Find the value or values c that satisfy the equation = f (c) in the conclusion of the Mean Value Theorem for functions and intervals: f(b) f(a) b a f(x) = x

More information

LEAST SQUARES DATA FITTING

LEAST SQUARES DATA FITTING LEAST SQUARES DATA FITTING Experiments generally have error or uncertainty in measuring their outcome. Error can be human error, but it is more usually due to inherent limitations in the equipment being

More information

Interpolation and extrapolation

Interpolation and extrapolation Interpolation and extrapolation Alexander Khanov PHYS6260: Experimental Methods is HEP Oklahoma State University October 30, 207 Interpolation/extrapolation vs fitting Formulation of the problem: there

More information

h(x) lim H(x) = lim Since h is nondecreasing then h(x) 0 for all x, and if h is discontinuous at a point x then H(x) > 0. Denote

h(x) lim H(x) = lim Since h is nondecreasing then h(x) 0 for all x, and if h is discontinuous at a point x then H(x) > 0. Denote Real Variables, Fall 4 Problem set 4 Solution suggestions Exercise. Let f be of bounded variation on [a, b]. Show that for each c (a, b), lim x c f(x) and lim x c f(x) exist. Prove that a monotone function

More information

Chapter 2 Formulas and Definitions:

Chapter 2 Formulas and Definitions: Chapter 2 Formulas and Definitions: (from 2.1) Definition of Polynomial Function: Let n be a nonnegative integer and let a n,a n 1,...,a 2,a 1,a 0 be real numbers with a n 0. The function given by f (x)

More information

Numerical Methods of Approximation

Numerical Methods of Approximation Contents 31 Numerical Methods of Approximation 31.1 Polynomial Approximations 2 31.2 Numerical Integration 28 31.3 Numerical Differentiation 58 31.4 Nonlinear Equations 67 Learning outcomes In this Workbook

More information

Announcements. Topics: Homework: - sections , 6.1 (extreme values) * Read these sections and study solved examples in your textbook!

Announcements. Topics: Homework: - sections , 6.1 (extreme values) * Read these sections and study solved examples in your textbook! Announcements Topics: - sections 5.2 5.7, 6.1 (extreme values) * Read these sections and study solved examples in your textbook! Homework: - review lecture notes thoroughly - work on practice problems

More information

5.1 - Polynomials. Ex: Let k(x) = x 2 +2x+1. Find (and completely simplify) the following: (a) k(1) (b) k( 2) (c) k(a)

5.1 - Polynomials. Ex: Let k(x) = x 2 +2x+1. Find (and completely simplify) the following: (a) k(1) (b) k( 2) (c) k(a) c Kathryn Bollinger, March 15, 2017 1 5.1 - Polynomials Def: A function is a rule (process) that assigns to each element in the domain (the set of independent variables, x) ONE AND ONLY ONE element in

More information

Mathematics 1052, Calculus II Exam 1, April 3rd, 2010

Mathematics 1052, Calculus II Exam 1, April 3rd, 2010 Mathematics 5, Calculus II Exam, April 3rd,. (8 points) If an unknown function y satisfies the equation y = x 3 x + 4 with the condition that y()=, then what is y? Solution: We must integrate y against

More information

MTH Calculus with Analytic Geom I TEST 1

MTH Calculus with Analytic Geom I TEST 1 MTH 229-105 Calculus with Analytic Geom I TEST 1 Name Please write your solutions in a clear and precise manner. SHOW your work entirely. (1) Find the equation of a straight line perpendicular to the line

More information

MATH 1113 Exam 1 Review

MATH 1113 Exam 1 Review MATH 1113 Exam 1 Review Topics Covered Section 1.1: Rectangular Coordinate System Section 1.3: Functions and Relations Section 1.4: Linear Equations in Two Variables and Linear Functions Section 1.5: Applications

More information

Cubic Splines. Antony Jameson. Department of Aeronautics and Astronautics, Stanford University, Stanford, California, 94305

Cubic Splines. Antony Jameson. Department of Aeronautics and Astronautics, Stanford University, Stanford, California, 94305 Cubic Splines Antony Jameson Department of Aeronautics and Astronautics, Stanford University, Stanford, California, 94305 1 References on splines 1. J. H. Ahlberg, E. N. Nilson, J. H. Walsh. Theory of

More information

King Fahd University of Petroleum and Minerals Prep-Year Math Program Math Term 161 Recitation (R1, R2)

King Fahd University of Petroleum and Minerals Prep-Year Math Program Math Term 161 Recitation (R1, R2) Math 001 - Term 161 Recitation (R1, R) Question 1: How many rational and irrational numbers are possible between 0 and 1? (a) 1 (b) Finite (c) 0 (d) Infinite (e) Question : A will contain how many elements

More information

Lecture 1: Interpolation and approximation

Lecture 1: Interpolation and approximation ecture notes on Variational and Approximate Methods in Applied Mathematics - A Peirce UBC ecture : Interpolation and approximation (Compiled 6 August 207 In this lecture we introduce the concept of approximation

More information

Fourier and Partial Differential Equations

Fourier and Partial Differential Equations Chapter 5 Fourier and Partial Differential Equations 5.1 Fourier MATH 294 SPRING 1982 FINAL # 5 5.1.1 Consider the function 2x, 0 x 1. a) Sketch the odd extension of this function on 1 x 1. b) Expand the

More information

Empirical Models Interpolation Polynomial Models

Empirical Models Interpolation Polynomial Models Mathematical Modeling Lia Vas Empirical Models Interpolation Polynomial Models Lagrange Polynomial. Recall that two points (x 1, y 1 ) and (x 2, y 2 ) determine a unique line y = ax + b passing them (obtained

More information

12.0 Properties of orthogonal polynomials

12.0 Properties of orthogonal polynomials 12.0 Properties of orthogonal polynomials In this section we study orthogonal polynomials to use them for the construction of quadrature formulas investigate projections on polynomial spaces and their

More information

X. Numerical Methods

X. Numerical Methods X. Numerical Methods. Taylor Approximation Suppose that f is a function defined in a neighborhood of a point c, and suppose that f has derivatives of all orders near c. In section 5 of chapter 9 we introduced

More information

Cubic Splines; Bézier Curves

Cubic Splines; Bézier Curves Cubic Splines; Bézier Curves 1 Cubic Splines piecewise approximation with cubic polynomials conditions on the coefficients of the splines 2 Bézier Curves computer-aided design and manufacturing MCS 471

More information