Numerical Analysis/Lagrange example

From testwiki
Jump to navigation Jump to search

We'll find the interpolating polynomial passing through the points (1,6), (2,2), (4,12), using the Lagrange method.

We first use the formula to write the following:

p(x)=6(x2)(12)(x4)(14)+2(x1)(21)(x4)(24)+12(x1)(41)(x2)(42)

After some simplification, we get:

p(x)=2(x2)(x4)1(x1)(x4)+2(x1)(x2)

p(x)=2(x26x+8)1(x25x+4)+2(x23x+2)

And our answer:

p(x)=x2+11x16.

Adding a point

Now we'll add a point to our data set, and find a new interpolating polynomial. Let us add the point (3,10) to our set. Starting over with the Lagrange formula, we write:

p(x)=6(x2)(12)(x4)(14)(x3)(13)+2(x1)(21)(x4)(24)(x3)(23)+12(x1)(41)(x2)(42)(x3)(43)10(x1)(31)(x2)(32)(x4)(34)

Simplifying, we get:

p(x)=(x2)(x4)(x3)+(x1)(x4)(x3)+2(x1)(x2)(x3)+5(x1)(x2)(x4)

p(x)=(x39x2+26x24)+(x38x2+19x12)+2(x36x2+11x6)+5(x37x2+14x8)

And our polynomial is:

p(x)=9x364x2+137x88.