lagrange interpolation

Upload: pramod-badyankal

Post on 19-Oct-2015

92 views

Category:

Documents


1 download

DESCRIPTION

sag

TRANSCRIPT

  • CE 341/441 - Lecture 6 - Fall 2004

    LECTURE

    LAGRANG

    Fit

    = ex d to estab-lish an in

    = a hrough allspecified ).

    N 1+

    f x( )

    g x( )p. 6.1

    6

    E INTERPOLATION

    points with an degree polynomial

    act function of which only discrete values are known and useterpolating or approximating function

    pproximating or interpolating function. This function will pass t interpolation points (also referred to as data points or nodes

    Nth

    f1

    x0

    g(x)f(x)

    f0

    f2f3 f4 fN

    x1 x2 x3 x4 xN...

    N 1+g x( )

    N 1+

  • CE 341/441 - Lecture 6 - Fall 2004

    The inter

    There exi et ofpoints. It

    where

    No matter

    Fitting

    Lagra

    Newto

    The resul

    N 1+

    aip. 6.2

    polation points or nodes are given as:

    :

    sts only one degree polynomial that passes through a given ss form is (expressed as a power series):

    = unknown coefficients, ( coefficients).

    how we derive the degree polynomial,

    power series

    nge interpolating functions

    n forward or backward interpolation

    ting polynomial will always be the same!

    xo f xo( ) f ox1 f x1( ) f 1x2 f x2( ) f 2

    xN f xN( ) f N

    Nth

    g x( ) ao a1x a2x2 a3x3 aN xN+ + + + +=

    i 0 N,= N 1+

    Nth

  • CE 341/441 - Lecture 6 - Fall 2004

    Power Seri

    mus

    Solve set

    It is relati ating func-tion

    g x( )

    g x( )p. 6.3

    es Fitting to Define Lagrange Interpolation

    t match at the selected data points

    : :

    of simultaneous equations

    vely computationally costly to solve the coefficients of the interpol (i.e. you need to program a solution to these equations).

    f x( )

    g xo( ) f o= ao a1xo a2xo2 aN xoN+ + + + f o=

    g x1( ) f 1= ao a1x1 a2x12+ + aN x1N+ + f 1=

    g xN( ) f N= ao a1xN+ a2xN2 aN xNN+ + + f N=

    1 xo xo2

    xoN

    1 x1 x12

    x1N

    1 xN xN2

    xNN

    ao

    a1

    :

    aN

    f of 1:

    f N

    =

  • CE 341/441 - Lecture 6 - Fall 2004

    Lagrange I

    We note t

    Let

    where at

    For exam

    Using the ;

    Vi

    3 x3( ) 1=V 4 x3( ) =p. 6.4

    nterpolation Using Basis Functions

    hat in general

    = polynomial of degree associated with each node such th

    ple if we have 5 interpolation points (or nodes)

    definition for : ; ; ;,we have:

    g xi( ) f i=

    g x( ) f i Vi x( )i 0=

    N

    =

    x( ) N i

    Vi x j( )0 i j1 i = j

    g x3( ) f oV o x3( ) f 1V 1 x3( ) f 2V 2 x3( ) f 3V 3 x3( ) f 4V 4 x3( )+ + + +=

    V i x j( ) V 0 x3( ) 0= V 1 x3( ) 0= V 2 x3( ) 0= V0

    g x3( ) f 3=

  • CE 341/441 - Lecture 6 - Fall 2004

    How do w

    Degre

    Roots

    Let

    The f als zero atnode

    Degre

    Howe

    We norma

    V i xi( )

    W i x( )p. 6.5

    e construct ?

    e

    at (at all nodes except )

    unction is such that we do have the required roots, i.e. it equs except at node

    e of is

    ver in the form presented will not equal to unity at

    lize and define the Lagrange basis functions

    V i x( )

    N

    xo x1 x2 xi 1 xi 1+ xN, , , , , , xi

    1=

    x xo( ) x x1( ) x x2( ) x xi 1( ) x xi 1+( ) x xN( )=

    W ixo x1 x2 ... , xN, , , xi

    W i x( ) N

    W i x( ) xi

    W i x( ) V i x( )

    Vi x( )x xo( ) x x1( ) x x2( ) x xi 1( ) x xi 1+( ) x xN( )

    xi xo( ) xi x1( ) xi x2( ) xi xi 1( ) xi xi 1+( ) xi xN( )-----------------------------------------------------------------------------------------------------------------------------------------------------------=

  • CE 341/441 - Lecture 6 - Fall 2004

    Now we h

    We also s

    The gener f is:

    The su

    .

    V i

    V i x( )

    g x( ) o aN, ,p. 6.6

    ave such that equals:

    atisfy

    e.g.

    al form of the interpolating function with the specified form o

    m of polynomials of degree is also polynomial of degree

    is equivalent to fitting the power series and computing coefficients

    V i x( ) V i xi( )

    xi( )xi xo( ) xi x1( ) xi x2( ) xi xi 1( ) 1( ) xi xi 1+( ) xi xN( )

    xi xo( ) xi x1( ) xi x2( ) xi xi 1( ) xi xi 1+( ) xi xN( )--------------------------------------------------------------------------------------------------------------------------------------------------------------=

    V i xi( ) 1=

    V i x j( ) 0 for i j=

    V 1 x2( )x2 xo( ) 1( ) x2 x2( ) x2 x3( ) x2 xN( )x1 xo( ) 1( ) x1 x2( ) x1 x3( ) x1 xN( )

    ---------------------------------------------------------------------------------------------------------- 0= =

    g x( )

    g x( ) f iVi x( )i 0=

    N

    =

    N N

    a

  • CE 341/441 - Lecture 6 - Fall 2004

    Lagrange L

    Linear La

    wherep. 6.7

    inear Interpolation Using Basis Functions

    grange is the simplest form of Lagrange Interpolation

    and

    N 1=( )

    g x( ) f iV i x( )i 0=

    1

    =

    g x( ) f oV o x( ) f 1V 1 x( )+=

    V o x( )x x1( )xo x1( )

    ---------------------

    x1 x( )x1 xo( )

    ---------------------= = V 1 x( )x xo( )x1 xo( )

    ---------------------=

    x0(x)

    V0 (x)

    x1

    V1(x)1.0

  • CE 341/441 - Lecture 6 - Fall 2004

    Example

    Given the

    Find the l

    Lagrange

    Interpolatp. 6.8

    following data:

    inear interpolating function

    basis functions are:

    and

    ing function g(x) is:

    xo 2= f o 1.5=x1 5= f 1 4.0=

    g x( )

    V o x( )5 x

    3-----------= V 1 x( )x 2

    3-----------=

    g x( ) 1.5V o x( ) 4.0V 1 x( )+=

  • CE 341/441 - Lecture 6 - Fall 2004p. 6.9

    x0 = 2

    1.5 V0 (x)42

    42

    x1 = 5x

    4.0 V1(x)

    x0 = 2 x1 = 5x

    x0 = 2 x1 = 5

    g(x) = 1.5 V0(x) + 4.0V1(x)

  • CE 341/441 - Lecture 6 - Fall 2004

    Lagrange Q For quadr

    wherep. 6.10

    uadratic Interpolation Using Basis Functionsatic Lagrange interpolation, N=2

    g x( ) f i V i x( )i 0=

    2

    =

    g x( ) f oV o x( ) f 1V 1 x( ) f 2V 2 x( )+ +=

    V o x( )x x1( ) x x2( )

    xo x1( ) xo x2( )-------------------------------------------=

    V 1 x( )x xo( ) x x2( )

    x1 xo( ) x1 x2( )-------------------------------------------=

    V 2 x( )x xo( ) x x1( )

    x2 xo( ) x2 x1( )-------------------------------------------=

  • CE 341/441 - Lecture 6 - Fall 2004

    Note that ch that thebasic prep. 6.11

    the location of the roots of , and are defined sumise of interpolation is satisfied, namely that . Thus:

    x0

    V0 (x)1.0

    x1 x

    x2

    V1(x) V2(x)

    V 0 x( ) V 1 x( ) V 2 x( )g xi( ) f i=

    g xo( ) V o xo( ) f o V 1 xo( ) f 1 V 2 xo( ) f 2+ + f 0= =

    g x1( ) V o x1( ) f o V 1 x1( ) f 1 V 2 x1( ) f 2+ + f 1= =

    g x2( ) V o x2( ) f o V 1 x2( ) f 1 V 2 x2( ) f 2+ + f 2= =

  • CE 341/441 - Lecture 6 - Fall 2004

    Example Given the

    Find the q

    Lagrange

    Interpolatp. 6.12

    following data:

    uadratic interpolating function

    basis functions are

    ing function g(x) is:

    xo 3= f o 1=x1 4= f 1 2=x2 5= f 2 4=

    g x( )

    V o x( ) x 4( ) x 5( )3 4( ) 3 5( )----------------------------------=

    V 1 x( ) x 3( ) x 5( )4 3( ) 4 5( )----------------------------------=

    V 2 x( ) x 3( ) x 4( )5 3( ) 5 4( )----------------------------------=

    g x( ) 1.0V o x( ) 2.0V 1 x( ) 4.0V 2 x( )+ +=

  • CE 341/441 - Lecture 6 - Fall 2004p. 6.13

    1.0 V0 (x)1.0x

    4.0 V2(x)

    x1 = 4x0 = 3 x2 = 5

    2.0

    4.0

    x1 = 4x0 = 3 x2 = 5

    x1 = 4x0 = 3 x2 = 5

    x

    x

    2.0 V1(x)

    x1 = 4x0 = 3 x2 = 5

    4.0g(x) = 1.0 V0(x) + 2.0V1(x) + 4.0V2(x)

  • CE 341/441 - Lecture 6 - Fall 2004

    Lagrange C

    For Cubic

    Example Consider )

    Find g 0.(p. 6.14

    ubic Interpolation Using Basis Functions

    Lagrange interpolation, N=3

    the following table of functional values (generated with

    as:

    0 0.40 -0.9162911 0.50 -0.6931472 0.70 -0.3566753 0.80 -0.223144

    f x( ) xln=

    i xi f i

    60)

    g x( ) f ox x1( ) x x2( ) x x3( )

    xo x1( ) xo x2( ) xo x3( )----------------------------------------------------------------- f 1

    x xo( ) x x2( ) x x3( )x1 xo( ) x1 x2( ) x1 x3( )

    -----------------------------------------------------------------+=

    f 2x xo( ) x x1( ) x x3( )

    x2 xo( ) x2 x1( ) x2 x3( )----------------------------------------------------------------- f 3

    x xo( ) x x1( ) x x2( )x3 xo( ) x3 x1( ) x3 x2( )

    -----------------------------------------------------------------+ +

  • CE 341/441 - Lecture 6 - Fall 2004p. 6.15

    g 0.60( ) 0.916291 0.60 0.50( ) 0.60 0.70( ) 0.60 0.80( )0.40 0.50( ) 0.40 0.70( ) 0.40 0.80( )------------------------------------------------------------------------------------------------=

    0.693147 0.60 0.40( ) 0.60 0.70( ) 0.60 0.80( )0.50 0.40( ) 0.50 0.70( ) 0.50 0.80( )------------------------------------------------------------------------------------------------

    0.356675 0.60 0.40( ) 0.60 0.50( ) 0.60 0.80( )0.70 0.40( ) 0.70 0.50( ) 0.70 0.80( )------------------------------------------------------------------------------------------------

    0.223144 0.60 0.40( ) 0.60 0.50( ) 0.60 0.70( )0.80 0.40( ) 0.80 0.50( ) 0.80 0.70( )------------------------------------------------------------------------------------------------

    g 0.60( ) 0.509976=

  • CE 341/441 - Lecture 6 - Fall 2004

    Errors Ass

    Using Tay

    where

    Notes

    If

    Theref

    f N +

    L x(

    f x(p. 6.16

    ociated with Lagrange Interpolation

    lor series analysis, the error can be shown to be given by:

    derivative of w.r.t. evaluated at

    = polynomial of degree where , then

    for all xore will be an exact representation of

    e x( ) f x( ) g x( )=

    e x( ) L x( ) f N 1+( ) ( )= xo xN

    1 ( ) N 1th+= f x

    ) x xo( ) x x1( ) x xN( )N 1+( )!----------------------------------------------------------------- an N 1

    th degree polynomial+= =

    ) M M N

    f N 1+( ) x( ) 0= e x( ) 0=g x( ) f x( )

  • CE 341/441 - Lecture 6 - Fall 2004

    Sincedoes

    es

    e.g

    e interval.

    f N 1+( ) x( )

    f N 1+(

    L x( )

    L x( )

    L

    Lp. 6.17

    in general is not known, if the interval is small and ifnot change rapidly in the interval

    where .

    can be estimated by using Finite Difference (F.D.) formulae

    will significantly effect the distribution of the error

    is a minimum at the center of and a maximum near the edg

    . using 6 point interpolation looks like:

    at all data points

    largest . becomes very large outside of th

    xo xN,[ ]

    e x( ) L x( ) f N 1+( ) xm( ) xmxo xN+

    2-------------------=

    )

    xo xN,[ ]

    L x( )

    0 1 2 3 4 5

    x( ) 0=x( ) 0 x 1 4 x 5 L x( )

  • CE 341/441 - Lecture 6 - Fall 2004

    As the rror withinthe in

    As

    Howe

    Th

    Prope

    N

    xx0 x xN p. 6.18

    size of the interpolating domain increases, so does the maximum eterval

    increases from a small value,

    ver as for a given and thus

    erefore convergence as does not necessarily occur!!

    rties of will also influence error as and vary

    D xN xo= Lmaxx0 x xN

    emaxx0 x xN

    Lmaxx0 x xN

    emaxx0 x xN

    N NCRIT> Lmaxx0 x xN

    xo xN,[ ] ema

    N

    f N 1+( ) ( ) D N

  • CE 341/441 - Lecture 6 - Fall 2004

    Example

    Estimate usually wedo not ha

    e

    )

    ep. 6.19

    the error made in the previous example knowing that (ve this information).

    f x( ) x( )ln=

    x( ) L x( ) f N 1+( ) xm( )

    e x( ) x xo( ) x x1( ) x x2( ) x x3( )3 1+( )!----------------------------------------------------------------------------- f3 1+( )

    xm( )

    e 0.60( ) 0.60 0.40( ) 0.60 0.50( ) 0.60 0.70( ) 0.60 0.80( )3 1+( )!-------------------------------------------------------------------------------------------------------------------------------- f3 1+( ) 0.6(

    0.60( ) 0.000017 f 4( ) 0.6( )=

  • CE 341/441 - Lecture 6 - Fall 2004

    We estim

    Therefore

    Exact erro

    Therefore

    Typically nce (F.D.)approximp. 6.20

    ate the fourth derivative of f(x) using the analytical function itself

    r is computed as:

    error estimate is excellent

    we would also have to estimate using a Finite Differeation (a discrete differentiation formula).

    f x( ) xln=

    f 1( ) x( ) x 1=

    f 2( ) x( ) x 2=

    f 3( ) x( ) 2x 3=

    f 4( ) x( ) 6x 4=

    f 4( ) 0.6( ) 46.29=

    e 0.60( ) 0.00079=

    E x( ) 0.60( ) g 0.60( )ln 0.00085= =

    f N 1+( ) xm( )

  • CE 341/441 - Lecture 6 - Fall 2004

    SUMMAR

    Linear int

    Power se ficients bysolving a

    Lagrange points Use spec

    where

    fi = th

    Each L nity at thedata onzero in-betw

    g x( )

    V i x( )p. 6.21

    Y OF LECTURES 5 AND 6

    erpolation passes a straight line through 2 data points.

    ries data points degree polynomial find coef matrix

    Interpolation passes an degree polynomial through dataialized nodal functions to make finding easier.

    = the interpolating function approximating f(x)e value of the function at the data (or interpolation) point i = the Lagrange basis function

    agrange polynomial or basis function is set up such that it equals upoint with which it is associated, zero at all other data points and neen.

    N 1+ Nth

    Nth N 1+g x( )

    g x( ) f iV i x( )i 0=

    N

    =

  • CE 341/441 - Lecture 6 - Fall 2004

    For exp. 6.22

    ample when N 2= 3 data points

    V0 V1 V2

    0 1 2

    g x( ) f oV o x( ) f 1V 1 x( ) f 2V 2 x( )+ +=

    f0

    f1

    f2 g(x)

  • CE 341/441 - Lecture 6 - Fall 2004

    Linear int

    Error esti e point inthe interv

    where

    f N 1+

    L x( )p. 6.23

    erpolation is the same as Lagrange Interpolation with

    mates can be derived but depend on knowing (or at somal).

    derivative of w.r.t. evaluated at

    N 1=

    f N 1+( ) xm( )

    e x( ) L x( ) f N 1+( ) ( )= xo xN

    ( ) N 1th+= f x x xo( ) x x1( ) x xN( )

    N 1+( )!----------------------------------------------------------------- an N 1th degree polynomial+= =

    LECTURE 6LAGRANGE INTERPOLATION Fit points with an degree polynomial = exact function of which only discrete values are known and used to establish an interpolating... = approximating or interpolating function. This function will pass through all specified interp... The interpolation points or nodes are given as::

    There exists only one degree polynomial that passes through a given set of points. Its form is...where = unknown coefficients, ( coefficients). No matter how we derive the degree polynomial, Fitting power series Lagrange interpolating functions Newton forward or backward interpolation

    The resulting polynomial will always be the same!

    Power Series Fitting to Define Lagrange Interpolation must match at the selected data points : :

    Solve set of simultaneous equations It is relatively computationally costly to solve the coefficients of the interpolating function...

    Lagrange Interpolation Using Basis Functions We note that in general Letwhere = polynomial of degree associated with each node such that For example if we have 5 interpolation points (or nodes)

    Using the definition for : ; ; ; ; ,we have: How do we construct ? Degree Roots at (at all nodes except )

    Let The function is such that we do have the required roots, i.e. it equals zero at nodes except at... Degree of is However in the form presented will not equal to unity at

    We normalize and define the Lagrange basis functions Now we have such that equals:

    We also satisfye.g.

    The general form of the interpolating function with the specified form of is: The sum of polynomials of degree is also polynomial of degree is equivalent to fitting the power series and computing coefficients .

    Lagrange Linear Interpolation Using Basis Functions Linear Lagrange is the simplest form of Lagrange Interpolation

    whereand

    Example Given the following data:Find the linear interpolating function Lagrange basis functions are:and

    Interpolating function g(x) is:

    Lagrange Quadratic Interpolation Using Basis Functions For quadratic Lagrange interpolation, N=2

    where Note that the location of the roots of , and are defined such that the basic premise of interpo...

    Example Given the following data:Find the quadratic interpolating function Lagrange basis functions are Interpolating function g(x) is:

    Lagrange Cubic Interpolation Using Basis Functions For Cubic Lagrange interpolation, N=3

    Example Consider the following table of functional values (generated with )

    00.40-0.91629110.50-0.69314720.70-0.35667530.80-0.223144 Find as:

    Errors Associated with Lagrange Interpolation Using Taylor series analysis, the error can be shown to be given by:wherederivative of w.r.t. evaluated at Notes If = polynomial of degree where , then for all x

    Therefore will be an exact representation of Since in general is not known, if the interval is small and if does not change rapidly in the i...where .

    can be estimated by using Finite Difference (F.D.) formulae will significantly effect the distribution of the error is a minimum at the center of and a maximum near the edges e.g. using 6 point interpolation looks like: at all data points largest . becomes very large outside of the interval.

    As the size of the interpolating domain increases, so does the maximum error within the interval

    As increases from a small value, However as for a given and thus Therefore convergence as does not necessarily occur!!

    Properties of will also influence error as and vary

    Example Estimate the error made in the previous example knowing that (usually we do not have this infor...

    We estimate the fourth derivative of f(x) using the analytical function itself

    Therefore Exact error is computed as:Therefore error estimate is excellent Typically we would also have to estimate using a Finite Difference (F.D.) approximation (a disc...

    SUMMARY OF LECTURES 5 AND 6 Linear interpolation passes a straight line through 2 data points. Power series data points degree polynomial find coefficients by solving a matrix Lagrange Interpolation passes an degree polynomial through data points Use specialized nodal ...where= the interpolating function approximating f(x)fi = the value of the function at the data (or interpolation) point i= the Lagrange basis function Each Lagrange polynomial or basis function is set up such that it equals unity at the data poin... For example when Linear interpolation is the same as Lagrange Interpolation with Error estimates can be derived but depend on knowing (or at some point in the interval).

    wherederivative of w.r.t. evaluated at