Sec 3 1 Interpolation and the Lagrange Polynomials

  • Slides: 14
Download presentation
Sec: 3. 1 Interpolation and the Lagrange Polynomials

Sec: 3. 1 Interpolation and the Lagrange Polynomials

Sec: 3. 1 Interpolation and the Lagrange Polynomials Find a polynomial that passes through

Sec: 3. 1 Interpolation and the Lagrange Polynomials Find a polynomial that passes through these n+1 points . . .

Sec: 3. 1 Interpolation and the Lagrange Polynomials Consider the following polynomial deg poly

Sec: 3. 1 Interpolation and the Lagrange Polynomials Consider the following polynomial deg poly ? L(1) = L(2) = L(9) = L(8) = L(5) = Define: Difference ? Lagrange interpolating polynomial

Sec: 3. 1 Interpolation and the Lagrange Polynomials Consider 1 2 3 200 500

Sec: 3. 1 Interpolation and the Lagrange Polynomials Consider 1 2 3 200 500 900 Lagrange interpolating polynomial

Sec: 3. 1 Interpolation and the Lagrange Polynomials Lagrange interpolating polynomial Given the set

Sec: 3. 1 Interpolation and the Lagrange Polynomials Lagrange interpolating polynomial Given the set of data Realize that each term Ln, k (x) will be 1 at x = xk and 0 at all other sample points

Sec: 3. 1 Interpolation and the Lagrange Polynomials Lagrange interpolating polynomial Given the set

Sec: 3. 1 Interpolation and the Lagrange Polynomials Lagrange interpolating polynomial Given the set of data Realize that each term Ln, k (x) will be 1 at x = xk and 0 at all other sample points

Sec: 3. 1 Interpolation and the Lagrange Polynomials Given the set of data Theorem

Sec: 3. 1 Interpolation and the Lagrange Polynomials Given the set of data Theorem 3. 2 If x 0, x 1, . . . , xn are n + 1 distinct numbers and f is a function whose values are given at these numbers, then a unique polynomial p(x) of degree at most n exists with f (xk) = p(xk), for each k = 0, 1, . . . , n. This polynomial is given by Remark

Sec: 3. 1 Interpolation and the Lagrange Polynomials Example Given the data Estimate f

Sec: 3. 1 Interpolation and the Lagrange Polynomials Example Given the data Estimate f (4) using Lagrange interpolating polynomials of order 3.

Sec: 3. 1 Interpolation and the Lagrange Polynomials Exam 1 Term 171 clear; clc

Sec: 3. 1 Interpolation and the Lagrange Polynomials Exam 1 Term 171 clear; clc p 2 = @(x) (x-2. 75). *(x-4)/(4*0. 75). . . +(x-2). *(x-4)/(-2. 75*0. 75*1. 25). . . +(x-2). *(x-2. 75)/(4*2*1. 25); f = @(x) 1. /x; x=2: 0. 1: 4; fx=f(x); p 2 x=p 2(x); plot(x, fx, 'r-', x, p 2 x, 'k-'); grid on

Sec: 3. 1 Interpolation and the Lagrange Polynomials

Sec: 3. 1 Interpolation and the Lagrange Polynomials

Sec: 3. 1 Interpolation and the Lagrange Polynomials Example Given the data Estimate f

Sec: 3. 1 Interpolation and the Lagrange Polynomials Example Given the data Estimate f (4) using Lagrange interpolating polynomials of order 3. x=[1 2 3 5] y=[-8 6 16 48] a =4 n = length(x); sum = 0; for i=1: n product = y(i); for j=1: n if (i~= j) ; product = product*(a-x(j))/(x(i)-x(j)); end sum = sum + product; end ya = sum x= 1 2 3 5 y= -8 6 16 48 a= 4 ya = 28

Sec: 3. 1 Interpolation and the Lagrange Polynomials Example Given the data Estimate f

Sec: 3. 1 Interpolation and the Lagrange Polynomials Example Given the data Estimate f (4) using Lagrange interpolating polynomials of order 3. function [ya] = langrange(x, y, a) n = length(x); sum = 0; for i=1: n product = y(i); for j=1: n if (i~= j) ; product = product*(a-x(j))/(x(i)-x(j)); end sum = sum + product; end ya = sum; end FUNCTION in MATLAB A function is a group of statements that together perform a task. In MATLAB, functions are defined in separate files. The name of the file and of the function should be the same. Functions operate on variables within their own workspace, which is also called the local workspace, separate from the workspace you access at the MATLAB command prompt which is called the base workspace. p=[1 2 3 5] q=[-8 6 16 48] z=4 [yz] = langrange(p, q, z)

Sec: 3. 1 Interpolation and the Lagrange Polynomials bound for the error Where is

Sec: 3. 1 Interpolation and the Lagrange Polynomials bound for the error Where is the maximum error? Note that the error form for the Lagrange polynomial is quite similar to that for the Taylor polynomial.

Sec: 3. 1 Interpolation and the Lagrange Polynomials Errors of Lagrange Interpolating Poly Determine

Sec: 3. 1 Interpolation and the Lagrange Polynomials Errors of Lagrange Interpolating Poly Determine the error form for this polynomial, and the maximum error