0% found this document useful (0 votes)
2 views

Polynomial Approximation

The document discusses interpolation and polynomial approximation in numerical analysis, emphasizing the use of polynomials to estimate missing function values and create algorithms for various applications. It covers methods such as linear interpolation, forward and backward differences, and Newton's interpolation polynomials, providing examples and exercises for practical understanding. Additionally, it introduces Lagrange's interpolating polynomial for constructing polynomials that fit given data points.

Uploaded by

mukisasamuel2020
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Polynomial Approximation

The document discusses interpolation and polynomial approximation in numerical analysis, emphasizing the use of polynomials to estimate missing function values and create algorithms for various applications. It covers methods such as linear interpolation, forward and backward differences, and Newton's interpolation polynomials, providing examples and exercises for practical understanding. Additionally, it introduces Lagrange's interpolating polynomial for constructing polynomials that fit given data points.

Uploaded by

mukisasamuel2020
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

MTH2203: Numerical Analysis

Interpolation and Polynomial Approximation

Rashidah Kasauli Namisanvu

Makerere University
[email protected]

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 1 / 26


Introduction to interpolation

Polynomials are used to design software algorithms to approximate


functions, for numerical differentiation, numerical integration and for
making computer drawn curves that must pass through specified
points.
Interpolation means to estimate a missing function value by taking a
weighted average of known function values at neighbouring points.
Linear interpolation uses a line segment that passes through two
points
The slope between (x0 , y0 ) and (x1 , y1 ) is m = (y1 − y0 )/(x1 − x0 )

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 2 / 26


Interpolation and Polynomial Approximation

Consider a function f (x) possibly we do not know


e.g. a function for the population of Uganda over the past 50 years
We may know the values at certain points
e.g. the population every census year
But we may need to know more populations other than in census years

Polynomial Approximation
We generate a polynomial P(x) so that for all known points (xn , yn ) where
y = f (x), the values of P(x) and f(x) are the same i.e. P(x) = f (x). P(x)
is then used to interpolate and extrapolate f (x).

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 3 / 26


Polynomial Approximation

P(x) is not unique for a set of points


If the number of points to interpolate are few, we have so many
options and a big error
If the points are many, its the reverse

Issues that matter


spacing of known points, accuracy envisaged, action expected
(interpolation/extrapolation)

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 4 / 26


Operators

Forward difference (△f (x) = f (x + h) − f (x))

Backward Difference(▽f (x) = f (x) − f (x − h))

Central Difference(δf (x) = f (x + h2 ) + f (x − h2 ))

Average Operator (µf (x) = {f (x + h2 ) + f (x − h2 )}/2)

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 5 / 26


General Points

Consider a function y = f (x), let the x values be:


x0
x1 = x0 + h
x2 = x1 + h
···
xn = xn−1 + h
Generally xi = x0 + ih, ∀i = 0, 1, 2, · · · , n
And the corresponding values of y are y0 , y1 , y2 , etc

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 6 / 26


Forward Differences

From the Definitions,


△y0 = y1 − y0
△y1 = y2 − y1
△y2 = y3 − y2
···
△yn = yn+1 − yn
These are first forward differences. The differences of the first forward
differences are called the second forward differences △2
△2 y0 = △y1 − △y0 = y2 − 2y1 + y0
△2 y1 = △y2 − △y1 = y3 − 2y2 + y1
△2 y2 = △y3 − △y2 = y4 − 2y3 + y2
···

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 7 / 26


General Forward Finite Difference Table

x0 y0 △y0 △2 y0 △3 y0 △4 y0 △5 y0
x1 y1 △y1 △2 y1 △3 y1 △4 y1
x2 y2 △y2 △2 y2 △3 y2
x3 y3 △y3 △2 y3
x4 y4 △y4
x5 y5

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 8 / 26


Table Construction

Construct the forward and finite difference tables for the following data
and deduce the power of the polynomial
x 1 2 3 4 5 6
y 2 4 12 32 70 132

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 9 / 26


Forward Difference Table

Solution table for forward difference


x y △y △2 y △3 y
1 2 2 6 6
2 4 8 12 6
3 12 20 18 6
4 32 38 24
5 70 62
6 132

Since we get a fixed value at △3 y , then the polynomial is of order 3

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 10 / 26


Backward Differences

Solution table for backward difference


x y ▽y ▽2 y ▽3 y
1 2
2 4 2
3 12 8 6
4 32 20 12 6
5 70 38 18 6
6 132 62 24 6

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 11 / 26


Newton’s Interpolation Polynomials

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 12 / 26


Definition

Interpolation is the process of finding equations to approximate


straight lines and curves that best fit given sets of data.
Given (x0 , y0 ), ..., (x1 , y1 ), ..., (xn , yn ), finding the value of ’y ’ at a
value of ’x’ in (x0 , xn ) is called interpolation.

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 13 / 26


Newton’s Polynomials

Two Common Polynomials


The Newton Forward Finite Differences Interpolating Polynomial
The Newton Backward Finite Differences Interpolating Polynomial
Better to use Forward when interpolated value is close to x0
Better to use Backward when interpolated value is closer to xn
If terms are many enough to get the polynomial order, the two
polynomials will be the same
To get the rate of change, we differentiate the polynomial

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 14 / 26


NFFDIP / NBFDIP

NFFDIP

p(p − 1) 2 p(p − 1)(p − 2) 3


P(x) ≈ y0 + p △ y0 + △ y0 + △ y0 + · · ·
2! 3!
x−x0
where p = h and h is the step length

NBFDIP

p(p + 1) 2 p(p + 1)(p + 2) 3


P(x) ≈ yn + p ▽ yn + ▽ y0 + ▽ y0 + · · ·
2! 3!
x−xn
where p = h and h is the step length

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 15 / 26


Example
For data points (1, 4). (2, 10), (3, 30), (4, 70), (5, 136). Use NFFDIP to
estimate y (2.3) and the rate of change when x = 3.2
We first generate the forward differences table for the data
x y △y △2 y △3 y
1 4 6 14 6
2 10 20 20 6
3 30 40 26
4 70 66
5 136

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 16 / 26


Example
For data points (1, 4). (2, 10), (3, 30), (4, 70), (5, 136). Use NFFDIP to
estimate y (2.3) and the rate of change when x = 3.2
We first generate the forward differences table for the data
x y △y △2 y △3 y
1 4 6 14 6
2 10 20 20 6
3 30 40 26
4 70 66
5 136
p(p−1) p(p−1)(p−2)
P(x) ≈ y0 + p △ y0 + 2! △2 y0 + 3! △3 y0 + · · ·

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 16 / 26


Example
For data points (1, 4). (2, 10), (3, 30), (4, 70), (5, 136). Use NFFDIP to
estimate y (2.3) and the rate of change when x = 3.2
We first generate the forward differences table for the data
x y △y △2 y △3 y
1 4 6 14 6
2 10 20 20 6
3 30 40 26
4 70 66
5 136
p(p−1)
P(x) ≈ y0 + p △ y0 + 2! △2 y0 + p(p−1)(p−2)
3! △3 y0 + · · ·
P(x) = 4 + 6p + 14 p(p−1)
2 + 6 p(p−1)(p−2)
6 but p = x−1
1 =x − 1
P(x) ≈ 4 + 6(x − 1) + 7(x − 1)(x − 2) + (x − 1)(x − 2)(x − 3)

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 16 / 26


Example
For data points (1, 4). (2, 10), (3, 30), (4, 70), (5, 136). Use NFFDIP to
estimate y (2.3) and the rate of change when x = 3.2
We first generate the forward differences table for the data
x y △y △2 y △3 y
1 4 6 14 6
2 10 20 20 6
3 30 40 26
4 70 66
5 136
p(p−1)
P(x) ≈ y0 + p △ y0 + 2! △2 y0 + p(p−1)(p−2)
3! △3 y0 + · · ·
P(x) = 4 + 6p + 14 p(p−1)
2 + 6 p(p−1)(p−2)
6 but p = x−1
1 =x − 1
P(x) ≈ 4 + 6(x − 1) + 7(x − 1)(x − 2) + (x − 1)(x − 2)(x − 3)
P(x) ≈ x 3 + x 2 − 4x + 6
y (2.3) ≈ P(2.3) = 2.33 + 2.32 − 4 × 2.3 + 6 = 14.275

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 16 / 26


Exercise

Redo the example above using the backward Interpolating polynomial


For values 1,2,3,4. Generate the values of the natural logs round to 3
decimal places. Use forward finite differences polynomial to estimate
1
In(2.5) and 2.5
Estimate f(42) from the following data using newton backward
x: 20 25 30 35 40 45
interpolation.
f(x): 354 332 291 260 231 204

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 17 / 26


Lagrange’s Interpolating Polynomial

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 18 / 26


Lagrange interpolating polynomial

Given the values of the function f (x) at n + 1 distinct points i.e.


x0 , x1 , x2 , ..., xn as
f0 , f1 , f2 , ..., fn
where fi = f (xi ) for i = 0, ..., n.
Find a polynomial, P(x), of degree n, such that P(xi ) = fi

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 19 / 26


Lagrange interpolating polynomial

Consider a function f (x) that passes through two distinct points


(x0 , f (x0 )) and (x1 , f (x1 )) .
The first order polynomial can be expressed as P(x) = a + bx
where a and b are constants
In Lagrangian form P(x) = c0 (x − x1 ) + c1 (x − x0 )
f (x0 ) f (x1 )
where c0 = x0 −x1 , and c1 = x1 −x0
Giving P(x) = xx−x 1
0 −x1
f (x0 ) + xx−x 0
1 −x0
f (x1 )

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 20 / 26


Lagrange interpolating polynomial

The first order polynomial


( basis function L0 (x) is defined as
1 at x = 0
L0 (x) = xx−x 1
0 −x1
=
0 at x = 1
Similarly, the first(order polynomial basis function L1 (x) is defined as
1 at x = 1
L1 (x) = xx−x 0
1 −x0
=
0 at x = 0
In terms of the basis function, P(x) can be written as
P(x) = L0 (x)f (x0 ) + L1 (x)f (x1 )

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 21 / 26


Lagrange Interpolating Polynomial - the general case

A polynomial of degree n which is zero at all points except xk is given


by (x − x0 )(x − x1 )...(x − xk−1 )(x − xk+1 )...(x − xn )
If we want that polynomial to have value one at xk we must divide by
(x−x0 )...(x−xk−1 )(x−xk+1 )...(x−xn )
its value at xk giving . Lk (x) = (xk −x0 )...(xk −xk−1 )(xk −xk+1 ). . . (x−xn )

Lk (x) is called basic Lagrange polynomial of degree n.


Then P(x)
Pn= Ln,0 f (x0 ) + Ln,1 f (x1 ) + ... + Ln,n f (xn )
P(x) = k=0 Ln,k f (xk )

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 22 / 26


Example 1

Find the Lagrange interpolation polynomial that takes the values


prescribed below
xk 0 1 2 4
f (xk ) 1 1 2 5
P3
Solution P(x) = k=0 L3,k f (xk )
(x−1)(x−2)(x−4) (x−0)(x−2)(x−4)
P(x) = (0−1)(0−2)(0−4) (1) + (1−0)(1−2)(1−4) (1)

(x − 0)(x − 1)(x − 4) (x − 0)(x − 1)(x − 2)


+ (2) + (5)
(2 − 0)(2 − 1)(2 − 4) (4 − 0)(4 − 1)(4 − 2)

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 23 / 26


The Interpolation Error

En (x) = f (x)–Pn (x)


The error varies from point to point.
The error is zero in the interpolation points but it is non-zero in other
points.
We will be most interested in the error bound |En (x)| over the
interval [a,b].
f n+1 (ξ(x))
Approximated using En (x) = (n+1)! (x − x0 )...(x − xn )

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 24 / 26


Example 2

For the function f (x) = ln(x + 1), construct interpolation polynomials


of degree one and two to approximate f (0.45) from the given nodes.
Find the error bound and the actual error.
xk 0 0.6 0.9
ln(x + 1) 1 0.47000 0.64185
Solution
First degree polynomial P1 (0.45) = 0.3525
Error bound = 3.375x10−2
Actual error = 1.906x10−2

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 25 / 26


The End

Rashidah Kasauli Namisanvu MTH2203: Numerical AnalysisInterpolation and Polynomial Approximation 26 / 26

You might also like