Lecture 4 II Lagrange polynomial Polynomial interpolation 2008
- Slides: 28
Lecture 4 II Ø Lagrange polynomial Ø Polynomial interpolation 數值方法 2008 Applied Mathematics, NDHU 1
poly l Express a polynomial according to given zeros poly([-5 0 5]) l poly. m returns coefficients of a polynomial with roots – 5, 0 and 5 數值方法 2008 Applied Mathematics, NDHU 2
>> poly([-5 0 5]) ans = 1 0 -25 0 數值方法 2008 Applied Mathematics, NDHU 3
polyval x=linspace(-5, 5); p=poly([-5 0 5]); y=polyval(p, x); Polynomial evaluation l polyval. m substitutes elements in x to polynomial p is a vector that represents a polynomial with roots 5, 0 and -5 l 數值方法 2008 Applied Mathematics, NDHU 4
Lagrange polynomial l n knots, l l Li denotes the ith Lagrange polynomial that responds one to xi and zeros to the other knots 數值方法 2008 Applied Mathematics, NDHU 5
Mathematical expression 數值方法 2008 Applied Mathematics, NDHU 6
Proof 數值方法 2008 Applied Mathematics, NDHU 7
Proof 數值方法 2008 Applied Mathematics, NDHU 8
Product form 數值方法 2008 Applied Mathematics, NDHU 9
Lagrange polynomial Given n knots, Let Li denote the ith Lagrange polynomial l Li is a polynomial of degree n-1 l Li has n-1 roots: l Normalization: Li satisfies Li(xi)=1 數值方法 2008 Applied Mathematics, NDHU 10
Polynomial of n-1 roots lx is a vector that consists of n distinct knots xzeros=[x(1, : i-1) x(i+1: n)]; pi=poly(xzeros); l pi is a polynomial whose roots are all knots except for xi 數值方法 2008 Applied Mathematics, NDHU 11
Normalization c=polyval(pi, x(i)); pi=pi/c; Normalization condition 數值方法 2008 Applied Mathematics, NDHU 12
Implementation I l Apply poly. m and polyval. m xzeros=[x(1: i-1) x(i+1: n)]; pi=poly(xzeros); c=polyval(pi, x(i)); pi=pi/c; 數值方法 2008 Applied Mathematics, NDHU 13
Lagrange polynomial evaluation y=lagrange_poly(v, x, i) % x contains n knots % Substitute elements in v to Li defined by given knots % y= Li(v) 數值方法 2008 Applied Mathematics, NDHU 14
Implementation II y=lagrange_poly(v, x, i) y=ones(size(v)) n=length(x) for j=1: n i==j Y y=…. 數值方法 2008 Applied Mathematics, NDHU 15
Evaluation of product form by for-looping function y=lagrange_poly(v, x, i) % evaluation of Li defined by knots in x y=ones(size(v)); n=length(x); for j=1: n if j~=i y=y. *(v-x(j))/(x(i)-x(j)); end return 數值方法 2008 Applied Mathematics, NDHU 16
n=4, i=1 v=linspace(-2, 3); y=lagrange_poly(v, [-1 0 1 2], 1); plot(v, y); 數值方法 2008 Applied Mathematics, NDHU 17
n=4, i=1 x=[-1 0 1 2]; i=1; n=length(x); xzeros=[x(1: i-1) x(i+1: n)]; pi=poly(xzeros); pi=pi/polyval(pi, x(i)); v=linspace(-2, 3); plot(v, polyval(pi, v), 'r'); 數值方法 2008 Applied Mathematics, NDHU 18
n=4, i=2 (Implementation I) x=[-1 0 1 2]; i=2; n=length(x); xzeros=[x(1: i-1) x(i+1: n)]; pi=poly(xzeros); pi=pi/polyval(pi, x(i)); v=linspace(-2, 3); plot(v, polyval(pi, v), 'r'); plot(v, 0); 數值方法 2008 Applied Mathematics, NDHU 19
n=4, i=2 v=linspace(-2, 3); y=lagrange_poly(v, [-1 0 1 2], 2); plot(v, y); plot(v, 0); 數值方法 2008 Applied Mathematics, NDHU 20
Polynomial interpolation l Find a polynomial well interpolating given points l Input: paired data, S={(xi, yi)}i l Output: a polynomial p(x) that pass all points in S xi p(x) 數值方法 2008 Applied Mathematics, NDHU yi 21
Sampling A sample from an unknown target function y 數值方法 2008 Applied Mathematics, NDHU x 22
Polynomial interpolation l Given l Find a polynomial that satisfies for all i 數值方法 2008 Applied Mathematics, NDHU 23
Interpolating polynomial l. A linear combination of n Lagrange polynomials defined by n knots lf is a polynomial of degree n-1 l Li denotes the ith Lagrange polynomial 數值方法 2008 Applied Mathematics, NDHU 24
Verification 數值方法 2008 Applied Mathematics, NDHU 25
Evaluation of interpolating polynomial l function z=int_poly(v, x, y) % x contains n knots % y contains desired targets % substitute elements in v to f 數值方法 2008 Applied Mathematics, NDHU 26
Evaluation of interpolating polynomial l function z=int_poly(v, x, y) n=length(x) z=zeros(size(v)) for i=1: n % call lagrange_poly(v, x, i) to evaluate Li(v) 數值方法 2008 Applied Mathematics, NDHU 27
function z=int_poly(v, x, y) z=zeros(size(v)); n=length(x); for i=1: n z=z+lagrange_poly(v, x, i)*y(i); end return 數值方法 2008 Applied Mathematics, NDHU 28
- Spline interpolation vs polynomial interpolation
- Newton's backward interpolation formula
- Lagrange interpolating polynomial formula
- Lagrange interpolation formula
- Tem secret
- Lagrange interpolation formula
- 2008 2008
- Newton interpolation java
- Polynomial interpolation
- 01:640:244 lecture notes - lecture 15: plat, idah, farad
- Numpy.polynomial.polynomial
- How to divide a polynomial by another polynomial
- Algebraic structures examples
- Lagrange
- Euler lagrange
- Point lagrange
- Lagrange basis functions
- Holonomic constraints
- Lagrangian optimization
- Euler lagrange
- Produto vetorial propriedades
- Eksponansiyel fonksiyon
- Fungsi lagrange matematika ekonomi
- Lagrange yöntemi
- It rd
- State and prove lagrange's theorem
- Interpolasi polinomial newton
- Lagrange
- Abhas singh iitk