0% found this document useful (0 votes)
133 views10 pages

Dse 1 Unit 3

Uploaded by

kkant872002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
133 views10 pages

Dse 1 Unit 3

Uploaded by

kkant872002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

DSE-1: Numerical Techniques-Unit-3

Interpolation: In numerical analysis, interpolation is a type


of estimation, a method of constructing new data points within the x f(x)
range of a discrete set of known data points. Suppose a set of data 0 0
points for an unknown function is as shown in the table. Interpolation 1 0.8415
provides a means of estimating the function at intermediate points. 2 0.9093
One of the example in this data set may be finding the value of f(x) for 3 0.1411
x = 1.5. By extrapolation, one can estimate a data point outside of 4 -0.7568
the known range of data.

Lagrange’s Interpolation:

Let the function f(x) is approximated by a straight line P1(x) between two points x0
and x1 (i.e. P1(x) ≈ f(x)). Let x be a point in between x0 and x1. Now the equation of
the straight line with two point form can be written as

P1(x) – f(x0) f(x1) – f(x0)


=
(x – x0) (x1 – x0)
[f(x1) - f(x0)] * (x - x0)
P1(x) – f(x0) =
(x1 – x0)
xf(x1) – xf(x0) – x0f(x1) + x0f(x0)
P1(x) – f(x0) =
(x1 – x0)
xf(x1) – xf(x0) – x0f(x1) + x0f(x0)
P1(x) = + f(x0)
(x1 – x0)
xf(x1) – xf(x0) – x0f(x1) + x0f(x0) + (x1 – x0)f(x0)
P1(x) =
(x1 – x0)
xf(x1) – xf(x0) – x0f(x1) + x0f(x0) + x1f(x0) – x0f(x0)
P1(x) = (x1 – x0)
xf(x1) – xf(x0) – x0f(x1) + x1f(x0)
P1(x) =
(x1 – x0)

Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 1 of 10
f(x0)(x1 – x) + f(x1)(x – x0)
P1(x) =
(x1 – x0)
f(x0)(x1 – x) f(x1)(x – x0)
P1(x) = +
(x1 – x0) (x1 – x0)
f(x0)(x - x1) f(x1)(x- x0)
P1(x) = +
(x0 – x1) (x1 – x0)
or P1(x) = L0f0 + L1f1
Where L0 = (x - x1) / (x0 - x1), L1 = (x - x0 ) / (x1 - x0), f0 = f(x0), and f1 = f(x1)
So, for n+1 points (x0, y0),..................., (xn, yn), pn(x) can be written as

Pn(x) = L0f0 + L1f1 + .................................... + Lnfn

(x – x1) * (x – x2) * ...... * (x – xn)


Where L0 =
(x0 – x1) * (x0 – x2) * ...... * (x0 – xn)

(x – x0) * (x – x2) * ...... * (x – xn)


L1 =
(x1 – x0) * (x1 – x2) * ...... * (x1 – xn)

...

(x – x0) * (x – x1) * ...... * (x – xn-1)


Ln =
(xn – x0) * (xn – x1) * ...... * (xn – xn-1)

Example-1: Using Lagrange’s interpolation formula find y(10) from the following
table:
x 5 6 9 11

y 12 13 14 16

Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 2 of 10
Solution: Here the intervals are unequal. By Lagrange’s interpolation formula we
have

Assignment-1: Interpolate the value of the function corresponding to x=4 using


Lagrange’s interpolation formula from the following set of data:
x 2 3 5 8 12
f(x) 10 15 25 40 60

Newton’s Divided Difference Interpolation: It is an interpolation technique


used when the interval difference is not same for all sequence of values.
Let us assume that the function f(x) is linear then f(xi) – f(xj)
we have (xi – xj)
where xi and xj are any two tabular points, is independent of xi and xj. This ratio is
called the first divided difference of f(x) relative to xi and xj and is denoted by
f[xi, xj]. That is
f(xi) – f(xj)
f [xi, xj] = = f [xj, xi]
(xi – xj)
Since the ratio is independent of xi and xj we can write f [x0, x] = f [x0, x1]
f(x) – f(x0)
= f [x0, x1]
(x – x0)

f(x) = f(x0) + (x – x0) f [x0, x1]

Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 3 of 10
So if f(x) is approximated with a linear polynomial then the function value at any
point x can be calculated by using f(x) ≈ P1(x) = f(x0) + (x – x1) f [x0, x1]
where f [x0, x1] is the first divided difference of f relative to x0 and x1.
Similarly if f(x) is a second degree polynomial then the secant slope defined above
is not constant but a linear function of x. Hence we have
f [x1, x2] – f [x0, x1]
x2 – x 0
is independent of x0, x1 and x2. This ratio is defined as second divided difference
of f relative to x0, x1 and x2. The secind divided difference are denoted as
f [x1, x2] – f [x0, x1]
f [x0, x1, x2] =
x2 – x 0
Now again since f [x0, x1,x2] is independent of x0, x1 and x2 we have f [x1, x0, x] = f
[x0, x1, x2]
f [x0, x] – f [x1, x0]
= f [x0, x1, x2]
x - x1

f [x0, x] = f [x0, x1] + (x – x1) f [x0, x1, x2]

f [x] – f [x0]
= f [x0, x1] + (x – x1) f [x0, x1, x2]
x – x0

f [x] = f [x0] + (x – x0) f [x0, x1] + (x – x0) (x – x1) f [x0, x1, x2]

This is equivalent to the second degree polynomial approximation passing through


three data points.
x0 x1 x2
f0 f1 f2

So whenever f(x) is approximated with a second degree polynomial, the value


of f(x) at any point x can be computed using the above polynomial.
In the same way if we define recursively nth divided difference by the relation
f [x1, x2, . . ., xn] – f [x0, x1, . . ., xn-1]
f [x0, x1, . . ., xn] =
xn - x0

The nth degree polynomial approximation to f(x) can be written as

f(x) ≈ Pn(x) = f [x0] + (x – x0) f [x0, x1] + (x – x0) (x – x1) f [x0, x1, x2]
+ . . . + (x – x0) (x – x1) . . . (x – xn-1) f [x0, x1, . . ., xn]

This formula is called Newton's Divided Difference Formula. Once we have the
divided differences of the function f relative to the set of points then we can use the
above formula to compute f(x) at any non in between the first and last point.
Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 4 of 10
Computing divided differences using divided difference table: Let us consider the
points (x1, f1), (x2, f2), (x3, f3) and (x4, f4) where x1, x2, x3 and x4 are not necessarily
equi-distant points then the divided difference table can be written as
xi fi f [xi, xj] f [xi, xj, xk ] f [xi, xj, xk, xl]
x0 f0
f1 - f 0
f [x0,x1] =
x1-x0
f[x1, x2] - f[x0,x1]
x0 f1 f[x0, x1,x2] =
x2 - x0
f2-f1 f[x1, x2,x3]-f[x0,x1,x2]
f[x1,x2] = f[x0,x1,x2,x3] =
x2-x1 x3 - x0
f[x2, x3]-f[x1, x2]
x1 f2 f [x1,x2,x3] =
x3 - x1
f3 - f 2
f[x2, x3] =
x3 - x 2
x2 f3

Example: Compute f(0.3) using Newton's divided difference formula for the following
data.
x 0 1 3 4
f(x) 1 3 49 129

Solution: The Divided difference table is as follows


xi fi
0 1
2
1 3 7
23 3
3 49 19
80
4 129

Now Newton's divided difference formula is


f(x) = f [x0] + (x - x0) f [x0, x1] + (x - x0) (x - x1) f [x0, x1, x2] + (x - x0) (x - x1) (x - x2)f [x0,
x1, x2, x3]
f(0.3) = 1 + (0.3 - 0) 2 + (0.3)(0.3 - 1) 7 + (0.3) (0.3 - 1) (0.3 - 3) 3
= 1.831

Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 5 of 10
Gregory Newton forward differences Interpolation: This interpolation
formula is applicable when the points are equidistance with respect to x-axis
x
i.e xi+1 – xi = h (constant).

The first order forward difference ∆fi is defined as ∆fi = fi+1 - fi


The second order forward difference ∆2 fi is defined as ∆2 fi = ∆fi+1
+1 - ∆fi

The kth order forward difference ∆k fi is defined as ∆k fi = ∆k-1fi+1 - ∆k-11fi


NB: ∆0 fi = fi

From the Newton’s Divided Difference Interpolation formula, we know that

(1)
Similarly we can get

(2)
By the definition of second order forward difference ∆2f0, we get

In a similar way, in general, we can show that

(3)

(4)

For ,

(5)
From Newton’s divided difference we know,
f(x) ≈ Pn(x) = f [x0] + (x - x0) f [x0, x1] + (x - x0) (x - x1) f [x0, x1, x2]
+ . . . + (x - x0) (x - x1) . . . (x - xn-1) f [x0, x1, . . ., xn]
Let x - x0 = rh or r = (x - x0)/h
 f(x) ≈ Pn(x) = f [x0] + rh f [x0, x1] + rh(r-1)h f [x0, x1, x2]
+ . . . + rh(r-1)h . . . (r – (n-1))h f [x0, x1, . . ., xn]
 f(x) ≈ Pn(x) = f [x0] + rh f [x0, x1] + r(r-1)h2 f [x0, x1, x2]
+ . . . + r(r-1) . . . (r – n+1)hn f [x0, x1, . . ., xn]
 f(x) ≈ Pn(x) = f [x0] + rh∆f0/h + r(r-1)h2 ∆2f0/(h22!)
+ . . . + r(r-1) . . . (r – n+1)hn ∆nf0/(hnn!)
r(r-1)∆2f0 r(r-1) . . . (r – n+1)∆nf0
f(x) ≈ Pn(x) = f0 + r∆f0 + +...+
2! n!
OR

n
r
Pn(x) = ∑ (
k
) ∆kf0 where
k=0

This is known as Newton-Gregory forward difference interpolation polynomial.

Constructing ∆kf0:

Example: If f(x) is known at the following data points, then find f(0.5) using Newton's
forward difference formula.
xi 0 1 2 3

fi 1 7 23 55

Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 7 of 10
Solution : The Forward difference table can be constructed as follows:
xi fi ∆fi ∆2fi ∆3fi
0 1
6
1 7 10
16 6
2 23 16
32
3 55
By Newton's forward difference formula
r(r-1) 2 r(r-1)(r-2) 3
f(x) = f0 + r∆f0 + ∆ f0 + ∆ f0
2! 3!
at x = 0.5, r = (x - x0) / h = (0.5 - 0) / 1 = 0.5
0.5(0.5 - 1) x 10 0.5(0.5 - 1)(0.5 - 2) x 6
f(0.5) = 1 + 0.5 x 6 + +
2 6
= 1 + 3 + 2.5 x (-0.5) + 0.5(-0.5)(-1.5)
= 3.125

Gregory Newton backward differences Interpolation: If the data size is


big then the divided difference table will be too long. Suppose the desired
intermediate value ‘x’ at which one needs to estimate the function (i.e. f(x)) falls
towards the end or say in the second half of the data set then it may be better to
start the estimation process from the last data set point. For this we need to use
backward-differences and backward difference table.
Let us first define backward differences and generate backward difference table, say
for the data set (xi, fi) where i=0, 1, 2, 3, 4.
First order backward difference ∇ fi is defined as: ∇ fi = fi - fi-1
Second order backward difference ∇ 2 fi is defined as: 2
∇ fi = ∇ fi - ∇ fi-1
In general, the kth order backward difference is defined as: ∇ k fi = ∇ k-1 fi - ∇ k-1 fi-1

In this case the reference point is xn and therefore we can derive the Newton-
Gregory backward difference interpolation polynomial as:

r(r+1)∇2fn r(r+1) . . . (r + n-1)∇ nfn


f(x) ≈ Pn(x) = fn + r∇fn + +...+
2! n!

Where r = (x – xn)/h

For constructing Pn(x) using the abve formula, it will be easier if we first generate
backward-difference table. The backward difference table for the data (xi, fi), i = 0, 1,
2, 3, 4 is given below:

Manas Ku Mishra, Asst. Prof. of Comp. Sc., FM (A) College, BLS. Page 8 of 10
Example: Given the following data estimate f(4.12) using Newton-Gregory
Newton
backward difference interpolation polynomial:

xi 0 1 2 3 4 5

fi 1 2 4 8 16 32

Solution: Here

Newton Backward Difference polynomial P5(x) is given by


Let us first generate backward difference table:
3 4 5
i xi fi ∇f ∇ 2f ∇ f ∇ f ∇ f
0 0 1
1
1 1 2 1
2 1
2 2 4 2 1
4 2 1
3 3 8 4 2
8 4
4 4 16 8
16
5 5 32

(1)

=17.39135

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy