Sie sind auf Seite 1von 156

Numerical Methods - Interpolation

Unequal Intervals
Dr. N. B. Vyas
Department of Mathematics,
Atmiya Institute of Tech. and Science, Rajkot (Guj.)
niravbvyas@gmail.com

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Interpolation
To find the value of y for an x between different x - values
x0 , x1 , . . . , xn is called problem of interpolation.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Interpolation
To find the value of y for an x between different x - values
x0 , x1 , . . . , xn is called problem of interpolation.
To find the value of y for an x which falls outside the range of x
(x < x0 or x > xn ) is called the problem of extrapolation.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Interpolation
To find the value of y for an x between different x - values
x0 , x1 , . . . , xn is called problem of interpolation.
To find the value of y for an x which falls outside the range of x
(x < x0 or x > xn ) is called the problem of extrapolation.
Theorem by Weierstrass in 1885, Every continuous
function in an interval (a,b) can be represented in that
interval to any desired accuracy by a polynomial.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Interpolation
To find the value of y for an x between different x - values
x0 , x1 , . . . , xn is called problem of interpolation.
To find the value of y for an x which falls outside the range of x
(x < x0 or x > xn ) is called the problem of extrapolation.
Theorem by Weierstrass in 1885, Every continuous
function in an interval (a,b) can be represented in that
interval to any desired accuracy by a polynomial.
Let us assign polynomial Pn of degree n (or less) that assumes
the given data values

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Interpolation
To find the value of y for an x between different x - values
x0 , x1 , . . . , xn is called problem of interpolation.
To find the value of y for an x which falls outside the range of x
(x < x0 or x > xn ) is called the problem of extrapolation.
Theorem by Weierstrass in 1885, Every continuous
function in an interval (a,b) can be represented in that
interval to any desired accuracy by a polynomial.
Let us assign polynomial Pn of degree n (or less) that assumes
the given data values
Pn (x0 ) = y0 , Pn (x1 ) = y1 , . . ., Pn (xn ) = yn

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Interpolation
To find the value of y for an x between different x - values
x0 , x1 , . . . , xn is called problem of interpolation.
To find the value of y for an x which falls outside the range of x
(x < x0 or x > xn ) is called the problem of extrapolation.
Theorem by Weierstrass in 1885, Every continuous
function in an interval (a,b) can be represented in that
interval to any desired accuracy by a polynomial.
Let us assign polynomial Pn of degree n (or less) that assumes
the given data values
Pn (x0 ) = y0 , Pn (x1 ) = y1 , . . ., Pn (xn ) = yn
This polynomial Pn is called interpolation polynomial.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Interpolation
To find the value of y for an x between different x - values
x0 , x1 , . . . , xn is called problem of interpolation.
To find the value of y for an x which falls outside the range of x
(x < x0 or x > xn ) is called the problem of extrapolation.
Theorem by Weierstrass in 1885, Every continuous
function in an interval (a,b) can be represented in that
interval to any desired accuracy by a polynomial.
Let us assign polynomial Pn of degree n (or less) that assumes
the given data values
Pn (x0 ) = y0 , Pn (x1 ) = y1 , . . ., Pn (xn ) = yn
This polynomial Pn is called interpolation polynomial.
x0 , x1 , . . . , xn is called the nodes ( tabular points, pivotal
points or arguments).
Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Interpolation with unequal intervals

Lagranges interpolation formula with unequal intervals:


Let y = f (x) be continuous and differentiable in the interval
(a, b).

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Interpolation with unequal intervals

Lagranges interpolation formula with unequal intervals:


Let y = f (x) be continuous and differentiable in the interval
(a, b).
Given the set of n + 1 values (x0 , y0 ), (x1 , y1 ), . . . , (xn , yn ) of x
and y, where the values of x need not necessarily be equally
spaced.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Interpolation with unequal intervals

Lagranges interpolation formula with unequal intervals:


Let y = f (x) be continuous and differentiable in the interval
(a, b).
Given the set of n + 1 values (x0 , y0 ), (x1 , y1 ), . . . , (xn , yn ) of x
and y, where the values of x need not necessarily be equally
spaced.
It is required to find Pn (x), a polynomial of degree n such that y
and Pn (x) agree at the tabulated points.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Interpolation with unequal intervals

Lagranges interpolation formula with unequal intervals:


Let y = f (x) be continuous and differentiable in the interval
(a, b).
Given the set of n + 1 values (x0 , y0 ), (x1 , y1 ), . . . , (xn , yn ) of x
and y, where the values of x need not necessarily be equally
spaced.
It is required to find Pn (x), a polynomial of degree n such that y
and Pn (x) agree at the tabulated points.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Interpolation

This polynomial is given by the following formula:

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Interpolation

This polynomial is given by the following formula:


(x x1 )(x x2 ) . . . (x xn )
y = f (x) Pn (x) =
y0
(x0 x1 )(x0 x2 ) . . . (x0 xn )

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Interpolation

This polynomial is given by the following formula:


(x x1 )(x x2 ) . . . (x xn )
y = f (x) Pn (x) =
y0
(x0 x1 )(x0 x2 ) . . . (x0 xn )
(x x0 )(x x2 ) . . . (x xn )
y1 + . . .
+
(x1 x0 )(x1 x2 ) . . . (x1 xn )

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Interpolation

This polynomial is given by the following formula:


(x x1 )(x x2 ) . . . (x xn )
y = f (x) Pn (x) =
y0
(x0 x1 )(x0 x2 ) . . . (x0 xn )
(x x0 )(x x2 ) . . . (x xn )
y1 + . . .
+
(x1 x0 )(x1 x2 ) . . . (x1 xn )
(x x0 )(x x1 ) . . . (x xn1 )
+
yn
(xn x0 )(xn x1 ) . . . (xn xn1 )

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Interpolation

This polynomial is given by the following formula:


(x x1 )(x x2 ) . . . (x xn )
y = f (x) Pn (x) =
y0
(x0 x1 )(x0 x2 ) . . . (x0 xn )
(x x0 )(x x2 ) . . . (x xn )
y1 + . . .
+
(x1 x0 )(x1 x2 ) . . . (x1 xn )
(x x0 )(x x1 ) . . . (x xn1 )
+
yn
(xn x0 )(xn x1 ) . . . (xn xn1 )
NOTE:
The above formula can be used irrespective of whether the values
x0 , x1 , . . . , xn are equally spaced or not.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Inverse Interpolation


In the Lagranges interpolation formula y is treated as dependent
variable and expressed as function of independent variable x.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Inverse Interpolation


In the Lagranges interpolation formula y is treated as dependent
variable and expressed as function of independent variable x.
Instead if x is treated as dependent variable and expressed as the
function of independent variable y, then Lagranges interpolation
formula becomes

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Inverse Interpolation


In the Lagranges interpolation formula y is treated as dependent
variable and expressed as function of independent variable x.
Instead if x is treated as dependent variable and expressed as the
function of independent variable y, then Lagranges interpolation
formula becomes
(y y1 )(y y2 ) . . . (y yn )
x = g(y) Pn (y) =
x0
(y0 y1 )(y0 y2 ) . . . (y0 yn )

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Inverse Interpolation


In the Lagranges interpolation formula y is treated as dependent
variable and expressed as function of independent variable x.
Instead if x is treated as dependent variable and expressed as the
function of independent variable y, then Lagranges interpolation
formula becomes
(y y1 )(y y2 ) . . . (y yn )
x = g(y) Pn (y) =
x0
(y0 y1 )(y0 y2 ) . . . (y0 yn )
(y y0 )(y y2 ) . . . (y yn )
+
x1 + . . .
(y1 y0 )(y1 y2 ) . . . (y1 yn )

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Inverse Interpolation


In the Lagranges interpolation formula y is treated as dependent
variable and expressed as function of independent variable x.
Instead if x is treated as dependent variable and expressed as the
function of independent variable y, then Lagranges interpolation
formula becomes
(y y1 )(y y2 ) . . . (y yn )
x = g(y) Pn (y) =
x0
(y0 y1 )(y0 y2 ) . . . (y0 yn )
(y y0 )(y y2 ) . . . (y yn )
+
x1 + . . .
(y1 y0 )(y1 y2 ) . . . (y1 yn )
(y y0 )(y y1 ) . . . (y yn1 )
+
xn
(yn y0 )(yn y1 ) . . . (yn yn1 )

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Inverse Interpolation


In the Lagranges interpolation formula y is treated as dependent
variable and expressed as function of independent variable x.
Instead if x is treated as dependent variable and expressed as the
function of independent variable y, then Lagranges interpolation
formula becomes
(y y1 )(y y2 ) . . . (y yn )
x = g(y) Pn (y) =
x0
(y0 y1 )(y0 y2 ) . . . (y0 yn )
(y y0 )(y y2 ) . . . (y yn )
+
x1 + . . .
(y1 y0 )(y1 y2 ) . . . (y1 yn )
(y y0 )(y y1 ) . . . (y yn1 )
+
xn
(yn y0 )(yn y1 ) . . . (yn yn1 )
This relation is referred as Lagranges inverse interpolation
formula.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. Given the table of values:


x

y= x
Evaluate

150
12.247

152
12.329

154
12.410

156
12.490

155 using Lagranges interpolation formula.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Here x0 = 150, x1 = 152, x2 = 154 and x3 = 156

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Here x0 = 150, x1 = 152, x2 = 154 and x3 = 156
y0 = 12.247, y1 = 12.329, y2 = 12.410 and y3 = 12.490

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Here x0 = 150, x1 = 152, x2 = 154 and x3 = 156
y0 = 12.247, y1 = 12.329, y2 = 12.410 and y3 = 12.490
By Lagranges interpolation formula,

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Here x0 = 150, x1 = 152, x2 = 154 and x3 = 156
y0 = 12.247, y1 = 12.329, y2 = 12.410 and y3 = 12.490
By Lagranges interpolation formula,
f (x) Pn (x) =

(x x1 )(x x2 )(x x3 )
y0
(x0 x1 )(x0 x2 )(x0 x3 )

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Here x0 = 150, x1 = 152, x2 = 154 and x3 = 156
y0 = 12.247, y1 = 12.329, y2 = 12.410 and y3 = 12.490
By Lagranges interpolation formula,
(x x1 )(x x2 )(x x3 )
y0
(x0 x1 )(x0 x2 )(x0 x3 )
(x x0 )(x x2 )(x x3 )
+
y1
(x1 x0 )(x1 x2 )(x1 x3 )
f (x) Pn (x) =

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Here x0 = 150, x1 = 152, x2 = 154 and x3 = 156
y0 = 12.247, y1 = 12.329, y2 = 12.410 and y3 = 12.490
By Lagranges interpolation formula,
(x x1 )(x x2 )(x x3 )
y0
(x0 x1 )(x0 x2 )(x0 x3 )
(x x0 )(x x2 )(x x3 )
+
y1
(x1 x0 )(x1 x2 )(x1 x3 )
(x x0 )(x x1 )(x x3 )
y2
+
(x2 x0 )(x2 x1 )(x2 x3 )
f (x) Pn (x) =

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Here x0 = 150, x1 = 152, x2 = 154 and x3 = 156
y0 = 12.247, y1 = 12.329, y2 = 12.410 and y3 = 12.490
By Lagranges interpolation formula,
(x x1 )(x x2 )(x x3 )
y0
(x0 x1 )(x0 x2 )(x0 x3 )
(x x0 )(x x2 )(x x3 )
+
y1
(x1 x0 )(x1 x2 )(x1 x3 )
(x x0 )(x x1 )(x x3 )
y2
+
(x2 x0 )(x2 x1 )(x2 x3 )
(x x0 )(x x1 )(x x2 )
y3
+
(x3 x0 )(x3 x1 )(x3 x2 )
f (x) Pn (x) =

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Here x0 = 150, x1 = 152, x2 = 154 and x3 = 156
y0 = 12.247, y1 = 12.329, y2 = 12.410 and y3 = 12.490
By Lagranges interpolation formula,
(x x1 )(x x2 )(x x3 )
y0
(x0 x1 )(x0 x2 )(x0 x3 )
(x x0 )(x x2 )(x x3 )
+
y1
(x1 x0 )(x1 x2 )(x1 x3 )
(x x0 )(x x1 )(x x3 )
y2
+
(x2 x0 )(x2 x1 )(x2 x3 )
(x x0 )(x x1 )(x x2 )
y3
+
(x3 x0 )(x3 x1 )(x3 x2 )
f (x) Pn (x) =

for x = 155
f (155) =
Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. Compute f (0.4) for the table below by the Lagranges


interpolation:
x
f (x)

0.3
0.61

Dr. N. B. Vyas

0.5
0.69

0.6
0.72

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. Using Lagranges formula, find the form of f (x) for the following
data:
x
f (x)

0
2

Dr. N. B. Vyas

1
3

2
12

5
147

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. Using Lagranges formula, find x for y = 7 for the following data:
x
y

1
4

Dr. N. B. Vyas

3
12

4
19

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. Using Lagranges formula, express the function


3x2 + x + 1
(x 1)(x 2)(x 3)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Let us evaluate y = 3x2 + x + 1 for x = 1, x = 2 and x = 3

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Let us evaluate y = 3x2 + x + 1 for x = 1, x = 2 and x = 3
These values are x0 = 1, x1 = 2 and x2 = 3 and

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Let us evaluate y = 3x2 + x + 1 for x = 1, x = 2 and x = 3
These values are x0 = 1, x1 = 2 and x2 = 3 and
y0 = 5,

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Let us evaluate y = 3x2 + x + 1 for x = 1, x = 2 and x = 3
These values are x0 = 1, x1 = 2 and x2 = 3 and
y0 = 5, y1 = 15 and y2 = 31
By Lagranges interpolation formula,

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Let us evaluate y = 3x2 + x + 1 for x = 1, x = 2 and x = 3
These values are x0 = 1, x1 = 2 and x2 = 3 and
y0 = 5, y1 = 15 and y2 = 31
By Lagranges interpolation formula,
y=

(x x1 )(x x2 )
(x x0 )(x x2 )
y0 +
y1
(x0 x1 )(x0 x2 )
(x1 x0 )(x1 x2 )

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Let us evaluate y = 3x2 + x + 1 for x = 1, x = 2 and x = 3
These values are x0 = 1, x1 = 2 and x2 = 3 and
y0 = 5, y1 = 15 and y2 = 31
By Lagranges interpolation formula,
(x x1 )(x x2 )
(x x0 )(x x2 )
y0 +
y1
(x0 x1 )(x0 x2 )
(x1 x0 )(x1 x2 )
(x x0 )(x x1 )
+
y2
(x2 x0 )(x2 x1 )

y=

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Let us evaluate y = 3x2 + x + 1 for x = 1, x = 2 and x = 3
These values are x0 = 1, x1 = 2 and x2 = 3 and
y0 = 5, y1 = 15 and y2 = 31
By Lagranges interpolation formula,
(x x1 )(x x2 )
(x x0 )(x x2 )
y0 +
y1
(x0 x1 )(x0 x2 )
(x1 x0 )(x1 x2 )
(x x0 )(x x1 )
+
y2
(x2 x0 )(x2 x1 )
substituting above values, we get

y=

y = 2.5(x 2)(x 3) 15(x 1)(x 3) + 15.5(x 1)(x 2)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol.: Let us evaluate y = 3x2 + x + 1 for x = 1, x = 2 and x = 3
These values are x0 = 1, x1 = 2 and x2 = 3 and
y0 = 5, y1 = 15 and y2 = 31
By Lagranges interpolation formula,
(x x1 )(x x2 )
(x x0 )(x x2 )
y0 +
y1
(x0 x1 )(x0 x2 )
(x1 x0 )(x1 x2 )
(x x0 )(x x1 )
+
y2
(x2 x0 )(x2 x1 )
substituting above values, we get

y=

y = 2.5(x 2)(x 3) 15(x 1)(x 3) + 15.5(x 1)(x 2)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Thus
3x2 + x + 1
(x 1)(x 2)(x 3)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Thus
3x2 + x + 1
(x 1)(x 2)(x 3)
=

2.5(x 2)(x 3) 15(x 1)(x 3) + 15.5(x 1)(x 2)


(x 1)(x 2)(x 3)

2.5
15
15.5
+
(x 1) (x 2)
(x 3)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Error in Interpolation
Error in Interpolation:
We assume that f (x) has continuous derivatives of order upto
n + 1 for all x (a, b). Since, f (x) is approximated by Pn (x), the
results contains errors. We define the error of interpolation or
truncation error as

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Error in Interpolation
Error in Interpolation:
We assume that f (x) has continuous derivatives of order upto
n + 1 for all x (a, b). Since, f (x) is approximated by Pn (x), the
results contains errors. We define the error of interpolation or
truncation error as
(x x0 )(x x1 ) . . . (x xn ) (n+1)
E(f, x) = f (x) Pn (x) =
f
()
(n + 1)!
where min(x0 , x1 , . . . , xn , x) < < min(x0 , x1 , . . . , xn , x)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Error in Interpolation
Error in Interpolation:
We assume that f (x) has continuous derivatives of order upto
n + 1 for all x (a, b). Since, f (x) is approximated by Pn (x), the
results contains errors. We define the error of interpolation or
truncation error as
(x x0 )(x x1 ) . . . (x xn ) (n+1)
E(f, x) = f (x) Pn (x) =
f
()
(n + 1)!
where min(x0 , x1 , . . . , xn , x) < < min(x0 , x1 , . . . , xn , x)
since, is an unknown, it is difficult to find the value of error.
However, we can find a bound of the error. The bound of the
error is obtained as

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Error in Interpolation
Error in Interpolation:
We assume that f (x) has continuous derivatives of order upto
n + 1 for all x (a, b). Since, f (x) is approximated by Pn (x), the
results contains errors. We define the error of interpolation or
truncation error as
(x x0 )(x x1 ) . . . (x xn ) (n+1)
E(f, x) = f (x) Pn (x) =
f
()
(n + 1)!
where min(x0 , x1 , . . . , xn , x) < < min(x0 , x1 , . . . , xn , x)
since, is an unknown, it is difficult to find the value of error.
However, we can find a bound of the error. The bound of the
error is obtained as
|(x x0 )(x x1 ) . . . (x xn )|
|E(f, x)|
max |f (n+1) ()|
ab
(n + 1)!

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. Using the data sin(0.1) = 0.09983 and sin(0.2) = 0.19867, find
an approximate value of sin(0.15) by Lagrange interpolation.
Obtain a bound on the error at x = 0.15.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Interpolation

Disadvantages:
In practice, we often do not know the degree of the interpolation
polynomial that will give the required accuracy, so we should be
prepared to increase the degree if necessary.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Interpolation

Disadvantages:
In practice, we often do not know the degree of the interpolation
polynomial that will give the required accuracy, so we should be
prepared to increase the degree if necessary.
To increase the degree the addition of another interpolation point
leads to re-computation.
i.e. no previous work is useful.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Interpolation

Disadvantages:
In practice, we often do not know the degree of the interpolation
polynomial that will give the required accuracy, so we should be
prepared to increase the degree if necessary.
To increase the degree the addition of another interpolation point
leads to re-computation.
i.e. no previous work is useful.
E.g: In calculating Pk (x), no obvious advantage can be taken of
the fact that one already has calculated Pk1 (x).

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Lagranges Interpolation

Disadvantages:
In practice, we often do not know the degree of the interpolation
polynomial that will give the required accuracy, so we should be
prepared to increase the degree if necessary.
To increase the degree the addition of another interpolation point
leads to re-computation.
i.e. no previous work is useful.
E.g: In calculating Pk (x), no obvious advantage can be taken of
the fact that one already has calculated Pk1 (x).
That means we need to calculate entirely new polynomial.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Divided Difference

Let f (x0 ), f (x1 ), . . . , f (xn ) be the values of a function f


corresponding to the arguments x0 , x1 , . . . , xn where the intervals
x1 x0 , x2 x1 , . . . , xn xn1 are not necessarily equally spaced.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Divided Difference

Let f (x0 ), f (x1 ), . . . , f (xn ) be the values of a function f


corresponding to the arguments x0 , x1 , . . . , xn where the intervals
x1 x0 , x2 x1 , . . . , xn xn1 are not necessarily equally spaced.
Then the first divided difference of f for the arguments
x0 , x1 , . . . , xn are defined by ,

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Divided Difference

Let f (x0 ), f (x1 ), . . . , f (xn ) be the values of a function f


corresponding to the arguments x0 , x1 , . . . , xn where the intervals
x1 x0 , x2 x1 , . . . , xn xn1 are not necessarily equally spaced.
Then the first divided difference of f for the arguments
x0 , x1 , . . . , xn are defined by ,
f (x0 , x1 ) =

Dr. N. B. Vyas

f (x1 ) f (x0 )
x1 x0

Numerical Methods - Interpolation Unequal Intervals

Divided Difference

Let f (x0 ), f (x1 ), . . . , f (xn ) be the values of a function f


corresponding to the arguments x0 , x1 , . . . , xn where the intervals
x1 x0 , x2 x1 , . . . , xn xn1 are not necessarily equally spaced.
Then the first divided difference of f for the arguments
x0 , x1 , . . . , xn are defined by ,
f (x0 , x1 ) =

f (x1 ) f (x0 )
x1 x0

f (x1 , x2 ) =

f (x2 ) f (x1 )
x2 x1

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Divided Difference

The second divided difference of f for three arguments


x0 , x1 , x2 is defined by
f (x0 , x1 , x2 ) =

Dr. N. B. Vyas

f (x1 , x2 ) f (x0 , x1 )
x2 x0

Numerical Methods - Interpolation Unequal Intervals

Divided Difference

The second divided difference of f for three arguments


x0 , x1 , x2 is defined by
f (x0 , x1 , x2 ) =

f (x1 , x2 ) f (x0 , x1 )
x2 x0

and similarly the divided difference of order n is defined by

f (x0 , x1 , . . . , xn ) =

f (x1 , x2 , . . . , xn ) f (x0 , x1 , . . . , xn1 )


xn x0

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Divided Difference

Properties:
The divided differences are symmetrical in all their arguments;
that is, the value of any divided difference is independent of the
order of the arguments.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Divided Difference

Properties:
The divided differences are symmetrical in all their arguments;
that is, the value of any divided difference is independent of the
order of the arguments.
The divided difference operator is linear.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Divided Difference

Properties:
The divided differences are symmetrical in all their arguments;
that is, the value of any divided difference is independent of the
order of the arguments.
The divided difference operator is linear.
The nth order divided differences of a polynomial of degree n are
constant, equal to the coefficient of xn .

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation


An interpolation formula which has the property that a
polynomial of higher degree may be derived from it by simply
adding new terms.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation


An interpolation formula which has the property that a
polynomial of higher degree may be derived from it by simply
adding new terms.
Newtons general interpolation formula is one such formula and
terms in it are called divided differences.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation


An interpolation formula which has the property that a
polynomial of higher degree may be derived from it by simply
adding new terms.
Newtons general interpolation formula is one such formula and
terms in it are called divided differences.
Let f (x0 ), f (x1 ), . . . , f (xn ) be the values of a function f
corresponding to the arguments x0 , x1 , . . . , xn where the intervals
x1 x0 , x2 x1 , . . . , xn xn1 are not necessarily equally spaced.
By the definition of divided difference,

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation


An interpolation formula which has the property that a
polynomial of higher degree may be derived from it by simply
adding new terms.
Newtons general interpolation formula is one such formula and
terms in it are called divided differences.
Let f (x0 ), f (x1 ), . . . , f (xn ) be the values of a function f
corresponding to the arguments x0 , x1 , . . . , xn where the intervals
x1 x0 , x2 x1 , . . . , xn xn1 are not necessarily equally spaced.
By the definition of divided difference,
f (x, x0 ) =

Dr. N. B. Vyas

f (x) f (x0 )
x x0

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation


An interpolation formula which has the property that a
polynomial of higher degree may be derived from it by simply
adding new terms.
Newtons general interpolation formula is one such formula and
terms in it are called divided differences.
Let f (x0 ), f (x1 ), . . . , f (xn ) be the values of a function f
corresponding to the arguments x0 , x1 , . . . , xn where the intervals
x1 x0 , x2 x1 , . . . , xn xn1 are not necessarily equally spaced.
By the definition of divided difference,
f (x, x0 ) =

f (x) f (x0 )
x x0

f (x) = f (x0 ) + (x x0 )f (x, x0 ) (1)


Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation


Further
f (x, x0 , x1 ) =

f (x, x0 ) f (x0 , x1 )
x x1

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation


Further
f (x, x0 , x1 ) =

f (x, x0 ) f (x0 , x1 )
x x1

which yields
f (x, x0 ) = f (x0 , x1 ) + (x x1 )f (x, x0 , x1 ) (2)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation


Further
f (x, x0 , x1 ) =

f (x, x0 ) f (x0 , x1 )
x x1

which yields
f (x, x0 ) = f (x0 , x1 ) + (x x1 )f (x, x0 , x1 ) (2)
Similarly
f (x, x0 , x1 ) = f (x0 , x1 , x2 ) + (x x2 )f (x, x0 , x1 , x2 ) (3)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation


Further
f (x, x0 , x1 ) =

f (x, x0 ) f (x0 , x1 )
x x1

which yields
f (x, x0 ) = f (x0 , x1 ) + (x x1 )f (x, x0 , x1 ) (2)
Similarly
f (x, x0 , x1 ) = f (x0 , x1 , x2 ) + (x x2 )f (x, x0 , x1 , x2 ) (3)
and in general
f (x, x0 , ..., xn1 ) = f (x0 , x1 , ..., xn ) + (x xn )f (x, x0 , x1 , ..., xn ) (4)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation

multiplying equation (2) by (x x0 )

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation

multiplying equation (2) by (x x0 ) , (3) by (x x0 ) (x x1 )


and so on,

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation

multiplying equation (2) by (x x0 ) , (3) by (x x0 ) (x x1 )


and so on, and finally the last term (4) by
(x x0 ) (x x1 ) ... (x xn1 ) and

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation

multiplying equation (2) by (x x0 ) , (3) by (x x0 ) (x x1 )


and so on, and finally the last term (4) by
(x x0 ) (x x1 ) ... (x xn1 ) and adding (1), (2) , (3) up to (4)
we obtain

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation

multiplying equation (2) by (x x0 ) , (3) by (x x0 ) (x x1 )


and so on, and finally the last term (4) by
(x x0 ) (x x1 ) ... (x xn1 ) and adding (1), (2) , (3) up to (4)
we obtain
f (x) =
f (x0 ) + (x x0 ) f (x0 , x1 ) + (x x0 ) (x x1 ) f (x0 , x1 , x2 ) + ... +
(x x0 ) (x x1 ) ... (x xn1 ) f (x0 , x1 , ..., xn )
This formula is called Newtons divided difference formula.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Newtons Divided Difference Interpolation

The divided difference upto third order


x y 1st div.diff. 2nd div.diff.
3rd div.diff.
x 0 y0
[x0 , x1 ]
x 1 y1
[x0 , x1 , x2 ]
[x1 , x2 ]
[x0 , x1 , x2 , x3 ]
x2 y2
[x1 , x2 , x3 ]
[x2 , x3 ]
x3 y3

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. Obtain the divided difference table for the data:


x
y

-1
-8

0
3

2
1

3
12

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. We have the following divided difference table for the data:
x
-1

y
-8

First d.d
3+8
= 11
0+1

3
13
= 1
20

1
12 1
= 11
32

Second d.d

1 11
= 4
2+1
11 + 1
=4
30

Third d.d

4+4
=2
3+1

12

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. Find f (x) as a polynomial in x for the following data by Newtons


divided difference formula:
x
f (x)

-4
1245

-1
33

0
5

2
9

5
1335

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. We have the following divided difference table for the data:
x
-4

y
1245

-1

33

1st d.d

2nd d.d

3rd d.d

4th d.d

404
94
28

14
10

3
13

88
442

1335

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

The Newtons divided difference formula gives:

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

The Newtons divided difference formula gives:


f (x) = f (x0 ) +

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

The Newtons divided difference formula gives:


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

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

The Newtons divided difference formula gives:


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

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

The Newtons divided difference formula gives:


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 ]

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

The Newtons divided difference formula gives:


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 ]
+

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

The Newtons divided difference formula gives:


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 ]
+ (x x0 )(x x1 )(x x2 )(x x3 )f [x0 , x1 , x2 , x3 , x4 ]

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

The Newtons divided difference formula gives:


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 ]
+ (x x0 )(x x1 )(x x2 )(x x3 )f [x0 , x1 , x2 , x3 , x4 ]
= ...
= 3x4 5x3 + 6x2 14x + 5

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. Find f (x) as a polynomial in x for the following data by Newtons


divided difference formula:
x
f (x)

-2
9

-1
16

0
17

1
18

3
44

4
81

Hence, interpolate at x = 0.5 and x = 3.1.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. We form the divided difference table for the given data.
x
2

f (x)
9

1st d.d

2nd d.d

3rd d.d

4th d.d

7
1

16
1

17

1
0

1
1

18

44

0
1

4
13

0
1

8
37

81
Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Since, the fourth order differences are zeros, the data represents a
third degree polynomial. Newtons divided difference formula
gives the polynomial as
f (x) = f (x0 ) +

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Since, the fourth order differences are zeros, the data represents a
third degree polynomial. Newtons divided difference formula
gives the polynomial as
f (x) = f (x0 ) + (x x0 )f [x0 , x1 ] + (x x0 )(x x1 )f [x0 , x1 , x2 ]

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Since, the fourth order differences are zeros, the data represents a
third degree polynomial. Newtons divided difference formula
gives the polynomial as
f (x) = f (x0 ) + (x x0 )f [x0 , x1 ] + (x x0 )(x x1 )f [x0 , x1 , x2 ]
+

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Since, the fourth order differences are zeros, the data represents a
third degree polynomial. Newtons divided difference formula
gives the polynomial as
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 ]

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Since, the fourth order differences are zeros, the data represents a
third degree polynomial. Newtons divided difference formula
gives the polynomial as
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 ]
= ...
= x3 + 17

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. Find the missing term in the following table:


x
y

0
1

1
3

2
9

3
-

4
81

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Sol. Divided difference table:

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Sol. Divided difference table:


By Newtons divided difference formula
f (x) =
f (x0 ) + (x x0 ) f (x0 , x1 ) + (x x0 ) (x x1 ) f (x0 , x1 , x2 ) + ...

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Spline Interpolation

Spline interpolation is a form of interpolation where the


interpolant is a special type of piecewise polynomial called a
spline
Consider the problem of interpolating between the data points
(x0 , y0 ), (x1 , y1 ), . . . , (xn , yn ) by means of spline fitting.
Then the cubic spline f (x) is such that
(i) f (x) is a linear polynomial outside the interval (x0 , xn )
(ii) f (x) is a cubic polynomial in each of the subintervals,
(iii) f 0 (x) and f 00 (x) are continuous at each point.
Since f (x) is cubic in each of the subintervals f 00 (x) shall be
linear.

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Spline Interpolation
f (x) =

(xi+1 x)3 Mi
+
6h

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Spline Interpolation
f (x) =

(xi+1 x)3 Mi (x xi )3 Mi+1


+
6h
6h

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Spline Interpolation
(xi+1 x)3 Mi (x xi )3 Mi+1
+
6h
6h


(xi+1 x)
h2
+
y i Mi +
h
6

f (x) =

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Spline Interpolation
(xi+1 x)3 Mi (x xi )3 Mi+1
+
6h
6h




h2
(x xi )
(xi+1 x)
h2
yi+1 Mi+1
+
y i Mi +
h
6
h
6

f (x) =

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Spline Interpolation
(xi+1 x)3 Mi (x xi )3 Mi+1
+
6h
6h




h2
(x xi )
(xi+1 x)
h2
yi+1 Mi+1
+
y i Mi +
h
6
h
6

f (x) =

where Mi1 + 4Mi + Mi+1 =

Dr. N. B. Vyas

6
(yi1 2yi + yi+1 ),
h2

Numerical Methods - Interpolation Unequal Intervals

Spline Interpolation
(xi+1 x)3 Mi (x xi )3 Mi+1
+
6h
6h




h2
(x xi )
(xi+1 x)
h2
yi+1 Mi+1
+
y i Mi +
h
6
h
6

f (x) =

where Mi1 + 4Mi + Mi+1 =

6
(yi1 2yi + yi+1 ),
h2

i = 1, 2, 3, ..., (n 1)
and M0 = 0, Mn = 0, xi+1 xi = h.
which gives n + 1 equations in n + 1 unknowns Mi (i = 0, 1, ..., n)
which can be solved. Substituting the value of Mi gives the
concerned cubic spline.
Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. Obtain cubic spline for the following data:


x 0 1 2 3
y 2 -6 -8 2

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3,

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1,

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2,

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 72 (2)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 72 (2)
solving these, we get

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 72 (2)
solving these, we get M1 =

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 72 (2)
solving these, we get M1 =4.8 and M2 =

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 72 (2)
solving these, we get M1 =4.8 and M2 =16.8

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 72 (2)
solving these, we get M1 =4.8 and M2 =16.8
Now the cubic spline in (xi x xi+1 ) is

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 72 (2)
solving these, we get M1 =4.8 and M2 =16.8
Now the cubic spline in (xi x xi+1 ) is
(xi+1 x)3 Mi
f (x) =
+
6h

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 72 (2)
solving these, we get M1 =4.8 and M2 =16.8
Now the cubic spline in (xi x xi+1 ) is
(xi+1 x)3 Mi (x xi )3 Mi+1
f (x) =
+
6h
6h

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 72 (2)
solving these, we get M1 =4.8 and M2 =16.8
Now the cubic spline in (xi x xi+1 ) is
(xi+1 x)3 Mi (x xi )3 Mi+1
f (x) =
+
6h
6h


(xi+1 x)
h2
+
y i Mi +
h
6
Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 72 (2)
solving these, we get M1 =4.8 and M2 =16.8
Now the cubic spline in (xi x xi+1 ) is
(xi+1 x)3 Mi (x xi )3 Mi+1
f (x) =
+
6h
6h




(x xi )
h2
(xi+1 x)
h2
yi+1 Mi+1 (3)
+
y i Mi +
h
6
h
6
Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 36; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 72 (2)
solving these, we get M1 =4.8 and M2 =16.8
Now the cubic spline in (xi x xi+1 ) is
(xi+1 x)3 Mi (x xi )3 Mi+1
f (x) =
+
6h
6h




(x xi )
h2
(xi+1 x)
h2
yi+1 Mi+1 (3)
+
y i Mi +
h
6
h
6
Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. The following values of x and y are given:


x 1 2 3 4
y 1 2 5 11
Find the cubic splines and evaluate y(1.5) and y 0 (3)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3,

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1,

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2,

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 18 (2)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 18 (2)
solving these, we get

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 18 (2)
solving these, we get M1 =

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 18 (2)
solving these, we get M1 =2 and M2 =

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 18 (2)
solving these, we get M1 =2 and M2 =4

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 18 (2)
solving these, we get M1 =2 and M2 =4
Now the cubic spline in (xi x xi+1 ) is

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 18 (2)
solving these, we get M1 =2 and M2 =4
Now the cubic spline in (xi x xi+1 ) is
(xi+1 x)3 Mi
f (x) =
+
6h

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 18 (2)
solving these, we get M1 =2 and M2 =4
Now the cubic spline in (xi x xi+1 ) is
(xi+1 x)3 Mi (x xi )3 Mi+1
f (x) =
+
6h
6h

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 18 (2)
solving these, we get M1 =2 and M2 =4
Now the cubic spline in (xi x xi+1 ) is
(xi+1 x)3 Mi (x xi )3 Mi+1
f (x) =
+
6h
6h


(xi+1 x)
h2
+
y i Mi +
h
6
Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 18 (2)
solving these, we get M1 =2 and M2 =4
Now the cubic spline in (xi x xi+1 ) is
(xi+1 x)3 Mi (x xi )3 Mi+1
f (x) =
+
6h
6h




(x xi )
h2
(xi+1 x)
h2
yi+1 Mi+1 (3)
+
y i Mi +
h
6
h
6
Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubic
spline can be determined from
6
Mi1 + 4Mi + Mi+1 = 2 (yi1 2yi + yi+1 ), i = 1, 2
h
also M0 = 0 , M3 = 0
for i = 1, M0 + 4M1 + M2 = 6(y0 2y1 + y2 )
therefore, 4M1 + M2 = 12; (1)
for i = 2, M1 + 4M2 + M3 = 6(y1 2y2 + y3 )
M1 + 4M2 = 18 (2)
solving these, we get M1 =2 and M2 =4
Now the cubic spline in (xi x xi+1 ) is
(xi+1 x)3 Mi (x xi )3 Mi+1
f (x) =
+
6h
6h




(x xi )
h2
(xi+1 x)
h2
yi+1 Mi+1 (3)
+
y i Mi +
h
6
h
6
Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example

Ex. Find whether the following functions are cubic splines ?


f (x) = 5x3 3x2 , 1 x 0
1.
= 5x3 3x2 , 0 x 1
2.

f (x)

= 2x3 x2 , 1 x 0
= 2x3 + 3x2 , 0 x 1

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. In both the examples, f (x) is a cubic polynomial in both
intervals (1, 0) and (0, 1).
1. We have
lim f (x)
x0+

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. In both the examples, f (x) is a cubic polynomial in both
intervals (1, 0) and (0, 1).
1. We have
lim f (x) = 0
x0+

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. In both the examples, f (x) is a cubic polynomial in both
intervals (1, 0) and (0, 1).
1. We have
lim f (x) = 0 = lim f (x)
x0+

x0

therefore, given function f (x) is continuous on (1, 1).


f 0 (x)
Now

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. In both the examples, f (x) is a cubic polynomial in both
intervals (1, 0) and (0, 1).
1. We have
lim f (x) = 0 = lim f (x)
x0+

x0

therefore, given function f (x) is continuous on (1, 1).


f 0 (x) = 15x2 6x, 1 x 0
= 15x2 6x, 0 x 1
Now

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. In both the examples, f (x) is a cubic polynomial in both
intervals (1, 0) and (0, 1).
1. We have
lim f (x) = 0 = lim f (x)
x0+

x0

therefore, given function f (x) is continuous on (1, 1).


f 0 (x) = 15x2 6x, 1 x 0
= 15x2 6x, 0 x 1
Now
we have,
lim f 0 (x)
x0+

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. In both the examples, f (x) is a cubic polynomial in both
intervals (1, 0) and (0, 1).
1. We have
lim f (x) = 0 = lim f (x)
x0+

x0

therefore, given function f (x) is continuous on (1, 1).


f 0 (x) = 15x2 6x, 1 x 0
= 15x2 6x, 0 x 1
Now
we have,
lim f 0 (x) = 0
x0+

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. In both the examples, f (x) is a cubic polynomial in both
intervals (1, 0) and (0, 1).
1. We have
lim f (x) = 0 = lim f (x)
x0+

x0

therefore, given function f (x) is continuous on (1, 1).


f 0 (x) = 15x2 6x, 1 x 0
= 15x2 6x, 0 x 1
Now
we have,
lim f 0 (x) = 0 = lim f 0 (x)
x0+

x0

therefore, the function f 0 (x) is continuous on (1, 1).


f 00 (x)

Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. In both the examples, f (x) is a cubic polynomial in both
intervals (1, 0) and (0, 1).
1. We have
lim f (x) = 0 = lim f (x)
x0+

x0

therefore, given function f (x) is continuous on (1, 1).


f 0 (x) = 15x2 6x, 1 x 0
= 15x2 6x, 0 x 1
Now
we have,
lim f 0 (x) = 0 = lim f 0 (x)
x0+

x0

therefore, the function f 0 (x) is continuous on (1, 1).


f 00 (x) = 30x 6, 1 x 0
= 30x 6, 0 x 1
Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Example
Sol. In both the examples, f (x) is a cubic polynomial in both
intervals (1, 0) and (0, 1).
1. We have
lim f (x) = 0 = lim f (x)
x0+

x0

therefore, given function f (x) is continuous on (1, 1).


f 0 (x) = 15x2 6x, 1 x 0
= 15x2 6x, 0 x 1
Now
we have,
lim f 0 (x) = 0 = lim f 0 (x)
x0+

x0

therefore, the function f 0 (x) is continuous on (1, 1).


f 00 (x) = 30x 6, 1 x 0
= 30x 6, 0 x 1
Dr. N. B. Vyas

Numerical Methods - Interpolation Unequal Intervals

Das könnte Ihnen auch gefallen