Dr. Nirav Vyas numerical method 4.pdf
-
Upload
ashoka-vanjare -
Category
Documents
-
view
233 -
download
1
Transcript of Dr. Nirav Vyas numerical method 4.pdf
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
1/156
Numerical Methods - Interpolation
Unequal Intervals
Dr. N. B. Vyas
Department of Mathematics,Atmiya Institute of Tech. and Science, Rajkot (Guj.)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
2/156
Interpolation
To find the value of y for an x between different x - valuesx0, x1, . . . , xn is called problem of interpolation.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
3/156
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
4/156
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 thatinterval to any desired accuracy by a polynomial. ”
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
5/156
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 thatinterval to any desired accuracy by a polynomial. ”
Let us assign polynomial P n of degree n (or less) that assumesthe given data values
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
6/156
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 thatinterval to any desired accuracy by a polynomial. ”
Let us assign polynomial P n of degree n (or less) that assumesthe given data values
P n(x0) = y0, P n(x1) = y1, . . ., P n(xn) = yn
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
7/156
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 thatinterval to any desired accuracy by a polynomial. ”
Let us assign polynomial P n of degree n (or less) that assumesthe given data values
P n(x0) = y0, P n(x1) = y1, . . ., P n(xn) = ynThis polynomial P n is called interpolation polynomial.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
8/156
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 thatinterval to any desired accuracy by a polynomial. ”
Let us assign polynomial P n of degree n (or less) that assumesthe given data values
P n(x0) = y0, P n(x1) = y1, . . ., P n(xn) = ynThis polynomial P n is called interpolation polynomial.
x0, x1, . . . , xn is called the nodes ( tabular points, pivotalpoints or arguments).
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
9/156
Interpolation with unequal intervals
Lagrange’s 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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
10/156
Interpolation with unequal intervals
Lagrange’s 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 xand y, where the values of x need not necessarily be equallyspaced.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
11/156
Interpolation with unequal intervals
Lagrange’s 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 xand y, where the values of x need not necessarily be equallyspaced.
It is required to find P n(x), a polynomial of degree n such that y
and P
n(x
) agree at the tabulated points.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
12/156
Interpolation with unequal intervals
Lagrange’s 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 xand y, where the values of x need not necessarily be equallyspaced.
It is required to find P n(x), a polynomial of degree n such that yand P
n(x) agree at the tabulated points.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
13/156
Lagrange’s Interpolation
This polynomial is given by the following formula:
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
14/156
Lagrange’s Interpolation
This polynomial is given by the following formula:
y = f (x) ≈ P n(x) = (x − x1)(x − x2) . . . (x − xn)(x0 − x1)(x0 − x2) . . . (x0 − xn) y0
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
15/156
Lagrange’s Interpolation
This polynomial is given by the following formula:
y = f (x) ≈ P n(x) = (x − x1)(x − x2) . . . (x − xn)(x0 − x1)(x0 − x2) . . . (x0 − xn) y0
+
(x
−x0)(x
−x2) . . . (x
−xn)
(x1 − x0)(x1 − x2) . . . (x1 − xn) y1 + . . .
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
16/156
Lagrange’s Interpolation
This polynomial is given by the following formula:
y = f (x) ≈ P n(x) = (x − x1)(x − x2) . . . (x − xn)(x0 − x1)(x0 − x2) . . . (x0 − xn) y0
+
(x
−x0)(x
−x2) . . . (x
−xn)
(x1 − x0)(x1 − x2) . . . (x1 − xn) y1 + . . .+
(x − x0)(x − x1) . . . (x − xn−1)(xn − x0)(xn − x1) . . . (xn − xn−1) yn
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
’
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
17/156
Lagrange’s Interpolation
This polynomial is given by the following formula:
y = f (x) ≈ P n(x) = (x − x1)(x − x2) . . . (x − xn)(x0 − x1)(x0 − x2) . . . (x0 − xn) y0
+
(x
−x0)(x
−x2) . . . (x
−xn)
(x1 − x0)(x1 − x2) . . . (x1 − xn) y1 + . . .+
(x − x0)(x − x1) . . . (x − xn−1)(xn − x0)(xn − x1) . . . (xn − xn−1) yn
NOTE:
The above formula can be used irrespective of whether the valuesx0, x1, . . . , xn are equally spaced or not.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
L ’ I I
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
18/156
Lagrange’s Inverse Interpolation
In the Lagrange’s interpolation formula y is treated as dependentvariable and expressed as function of independent variable x.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
L ’ I I
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
19/156
Lagrange’s Inverse Interpolation
In the Lagrange’s interpolation formula y is treated as dependentvariable and expressed as function of independent variable x.
Instead if x is treated as dependent variable and expressed as thefunction of independent variable y, then Lagrange’s interpolationformula becomes
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
L ’ I I
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
20/156
Lagrange’s Inverse Interpolation
In the Lagrange’s interpolation formula y is treated as dependentvariable and expressed as function of independent variable x.
Instead if x is treated as dependent variable and expressed as thefunction of independent variable y, then Lagrange’s interpolationformula becomes
x = g(y) ≈ P n(y) = (y − y1)(y − y2) . . . (y − yn)(y0 − y1)(y0 − y2) . . . (y0 − yn) x0
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Lagrange’s Inverse Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
21/156
Lagrange’s Inverse Interpolation
In the Lagrange’s interpolation formula y is treated as dependentvariable and expressed as function of independent variable x.
Instead if x is treated as dependent variable and expressed as thefunction of independent variable y, then Lagrange’s interpolationformula becomes
x = g(y) ≈ P n(y) = (y − y1)(y − y2) . . . (y − yn)(y0 − y1)(y0 − y2) . . . (y0 − yn) x0
+ (y − y0)(y − y2) . . . (y − yn)(y1 − y0)(y1 − y2) . . . (y1 − yn) x1 + . . .
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Lagrange’s Inverse Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
22/156
Lagrange’s Inverse Interpolation
In the Lagrange’s interpolation formula y is treated as dependentvariable and expressed as function of independent variable x.
Instead if x is treated as dependent variable and expressed as thefunction of independent variable y, then Lagrange’s interpolationformula becomes
x = g(y) ≈ P n(y) = (y − y1)(y − y2) . . . (y − yn)(y0 − y1)(y0 − y2) . . . (y0 − yn) x0
+ (y − y0)(y − y2) . . . (y − yn)(y1 − y0)(y1 − y2) . . . (y1 − yn) x1 + . . .
+ (y
−y
0)(y
−y
1) . . . (y
−yn−1
)
(yn − y0)(yn − y1) . . . (yn − yn−1) xn
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Lagrange’s Inverse Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
23/156
Lagrange’s Inverse Interpolation
In the Lagrange’s interpolation formula y is treated as dependentvariable and expressed as function of independent variable x.
Instead if x is treated as dependent variable and expressed as thefunction of independent variable y, then Lagrange’s interpolationformula becomes
x = g(y) ≈ P n(y) = (y − y1)(y − y2) . . . (y − yn)(y0 − y1)(y0 − y2) . . . (y0 − yn) x0
+ (y − y0)(y − y2) . . . (y − yn)(y1 − y0)(y1 − y2) . . . (y1 − yn) x1 + . . .
+ (y
−y
0)(y
−y
1) . . . (y
−yn−1
)
(yn − y0)(yn − y1) . . . (yn − yn−1) xnThis relation is referred as Lagrange’s inverse interpolationformula.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
24/156
Example
Ex. Given the table of values:
x 150 152 154 156y = √ x 12.247 12.329 12.410 12.490
Evaluate√
155 using Lagrange’s interpolation formula.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
25/156
Example
Sol.: Here x0 = 150, x1 = 152, x2 = 154 and x3 = 156
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
26/156
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
27/156
Example
Sol.: Here x0 = 150, x1 = 152, x2 = 154 and x3 = 156
y0 = 12
.247,
y1 = 12
.329,
y2 = 12
.410 and
y3 = 12
.490By Lagrange’s interpolation formula,
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
28/156
Example
Sol.: Here x0 = 150, x1 = 152, x2 = 154 and x3 = 156
y0 = 12
.247,
y1 = 12
.329,
y2 = 12
.410 and
y3 = 12
.490By Lagrange’s interpolation formula,
f (x) ≈ P n(x) = (x − x1)(x − x2)(x − x3)(x0
−x1)(x0
−x2)(x0
−x3)
y0
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
29/156
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 Lagrange’s interpolation formula,
f (x) ≈ P n(x) = (x − x1)(x − x2)(x − x3)(x0
−x1)(x0
−x2)(x0
−x3)
y0
+ (x − x0)(x − x2)(x − x3)
(x1 − x0)(x1 − x2)(x1 − x3) y1
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
30/156
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 Lagrange’s interpolation formula,
f (x) ≈ P n(x) = (x − x1)(x − x2)(x − x3)(x0
−x1)(x0
−x2)(x0
−x3)
y0
+ (x − x0)(x − x2)(x − x3)(x1 − x0)(x1 − x2)(x1 − x3) y1
+ (x − x0)(x − x1)(x − x3)(x2 − x0)(x2 − x1)(x2 − x3) y2
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
31/156
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 Lagrange’s interpolation formula,
f (x) ≈ P n(x) = (x − x1)(x − x2)(x − x3)(x0
−x1)(x0
−x2)(x0
−x3)
y0
+ (x − x0)(x − x2)(x − x3)(x1 − x0)(x1 − x2)(x1 − x3) y1
+ (x − x0)(x − x1)(x − x3)(x2 − x0)(x2 − x1)(x2 − x3) y2
+ (x − x0)(x − x1)(x − x2)(x3 − x0)(x3 − x1)(x3 − x2) y3
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
32/156
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 Lagrange’s interpolation formula,
f (x) ≈ P n(x) = (x − x1)(x − x2)(x − x3)(x0
−x1)(x0
−x2)(x0
−x3)
y0
+ (x − x0)(x − x2)(x − x3)(x1 − x0)(x1 − x2)(x1 − x3) y1
+ (x − x0)(x − x1)(x − x3)(x2 − x0)(x2 − x1)(x2 − x3) y2
+ (x − x0)(x − x1)(x − x2)(x3 − x0)(x3 − x1)(x3 − x2) y3
for x = 155
∴ f (155) =
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
33/156
Ex. Compute f (0.4) for the table below by the Lagrange’sinterpolation:
x 0.3 0.5 0.6
f (x) 0.61 0.69 0.72
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
34/156
Ex. Using Lagrange’s formula, find the form of f (x) for the followingdata:
x 0 1 2 5
f (x) 2 3 12 147
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
35/156
Ex. Using Lagrange’s formula, find x for y = 7 for the following data:
x 1 3 4y 4 12 19
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
36/156
Ex. Using Lagrange’s formula, express the function
3x2
+ x + 1(x − 1)(x − 2)(x − 3)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
37/156
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
38/156
Sol.: Let us evaluate y = 3x2
+ x + 1 for x = 1, x = 2 and x = 3These values are x0 = 1, x1 = 2 and x2 = 3 and
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
39/156
Sol.: Let us evaluate y = 3x2
+ x + 1 for x = 1, x = 2 and x = 3These values are x0 = 1, x1 = 2 and x2 = 3 and
y0 = 5,
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
40/156
Sol.: Let us evaluate y = 3x2
+ x + 1 for x = 1, x = 2 and x = 3These values are x0 = 1, x1 = 2 and x2 = 3 and
y0 = 5, y1 = 15 and y2 = 31
By Lagrange’s interpolation formula,
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
41/156
Sol.: Let us evaluate y = 3x2
+ x + 1 for x = 1, x = 2 and x = 3These values are x0 = 1, x1 = 2 and x2 = 3 and
y0 = 5, y1 = 15 and y2 = 31
By Lagrange’s interpolation formula,
y = (x − x1)(x − x2)(x0 − x1)(x0 − x2) y0 +
(x − x0)(x − x2)(x1 − x0)(x1 − x2) y1
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
42/156
Sol.: Let us evaluate y = 3x2
+ x + 1 for x = 1, x = 2 and x = 3These values are x0 = 1, x1 = 2 and x2 = 3 and
y0 = 5, y1 = 15 and y2 = 31
By Lagrange’s interpolation formula,
y = (x − x1)(x − x2)(x0 − x1)(x0 − x2) y0 +
(x − x0)(x − x2)(x1 − x0)(x1 − x2) y1
+ (x − x0)(x − x1)(x2
−x0)(x2
−x1)
y2
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
43/156
Sol.: Let us evaluate y = 3x2
+ x + 1 for x = 1, x = 2 and x = 3These values are x0 = 1, x1 = 2 and x2 = 3 and
y0 = 5, y1 = 15 and y2 = 31
By Lagrange’s interpolation formula,
y = (x − x1)(x − x2)(x0 − x1)(x0 − x2) y0 +
(x − x0)(x − x2)(x1 − x0)(x1 − x2) y1
+ (x − x0)(x − x1)(x2
−x0)(x2
−x1)
y2
substituting above values, we get
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
44/156
Sol.: Let us evaluate y = 3x2
+ x + 1 for x = 1, x = 2 and x = 3These values are x0 = 1, x1 = 2 and x2 = 3 and
y0 = 5, y1 = 15 and y2 = 31
By Lagrange’s interpolation formula,
y = (x − x1)(x − x2)(x0 − x1)(x0 − x2) y0 +
(x − x0)(x − x2)(x1 − x0)(x1 − x2) y1
+ (x − x0)(x − x1)(x2
−x0)(x2
−x1)
y2
substituting above values, we get
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
45/156
Thus3x2 + x + 1
(x − 1)(x − 2)(x − 3)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
46/156
Thus3x2 + 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
(x
−1)
- 15
(x
−2)
+ 15.5
(x
−3)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Error in Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
47/156
Error in Interpolation:
We assume that f (x) has continuous derivatives of order upton + 1 for all x ∈ (a, b). Since, f (x) is approximated by P n(x), theresults contains errors. We define the error of interpolation ortruncation error as
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Error in Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
48/156
Error in Interpolation:
We assume that f (x) has continuous derivatives of order upton + 1 for all x ∈ (a, b). Since, f (x) is approximated by P n(x), theresults contains errors. We define the error of interpolation ortruncation error as
E (f, x) = f (x) − P n(x) = (x
−x0)(x
−x1) . . . (x
−xn)
(n + 1)! 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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
49/156
Error in Interpolation:
We assume that f (x) has continuous derivatives of order upton + 1 for all x ∈ (a, b). Since, f (x) is approximated by P n(x), theresults contains errors. We define the error of interpolation ortruncation error as
E (f, x) = f (x) − P n(x) = (x
−x0)(x
−x1) . . . (x
−xn)
(n + 1)! 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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
50/156
Error in Interpolation:
We assume that f (x) has continuous derivatives of order upton + 1 for all x ∈ (a, b). Since, f (x) is approximated by P n(x), theresults contains errors. We define the error of interpolation ortruncation error as
E (f, x) = f (x) − P n(x) = (x
−x0)(x
−x1) . . . (x
−xn)
(n + 1)! 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
|E (f, x)| ≤ |(x − x0)(x − x1) . . . (x − xn)|(n + 1)!
maxa≤ξ≤b
|f (n+1)(ξ )|
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
51/156
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
Lagrange’s Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
52/156
Disadvantages:In practice, we often do not know the degree of the interpolationpolynomial that will give the required accuracy, so we should beprepared to increase the degree if necessary.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Lagrange’s Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
53/156
Disadvantages:In practice, we often do not know the degree of the interpolationpolynomial that will give the required accuracy, so we should beprepared to increase the degree if necessary.
To increase the degree the addition of another interpolation pointleads to re-computation.
i.e. no previous work is useful.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Lagrange’s Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
54/156
Disadvantages:In practice, we often do not know the degree of the interpolationpolynomial that will give the required accuracy, so we should beprepared to increase the degree if necessary.
To increase the degree the addition of another interpolation pointleads to re-computation.
i.e. no previous work is useful.
E.g: In calculating P k(x), no obvious advantage can be taken of the fact that one already has calculated P k−1(x).
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Lagrange’s Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
55/156
Disadvantages:In practice, we often do not know the degree of the interpolationpolynomial that will give the required accuracy, so we should beprepared to increase the degree if necessary.
To increase the degree the addition of another interpolation pointleads to re-computation.
i.e. no previous work is useful.
E.g: In calculating P k(x), no obvious advantage can be taken of the fact that one already has calculated P k−1(x).
That means we need to calculate entirely new polynomial.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Divided Difference
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
56/156
Let f
(x
0), f
(x
1), . . . , f
(xn) be the values of a function
f
corresponding to the arguments x0, x1, . . . , xn where the intervalsx1 − x0, x2 − x1, . . . , xn − xn−1 are not necessarily equally spaced.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Divided Difference
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
57/156
Let f
(x
0), f
(x
1), . . . , f
(xn) be the values of a function
f
corresponding to the arguments x0, x1, . . . , xn where the intervalsx1 − x0, x2 − x1, . . . , xn − xn−1 are not necessarily equally spaced.Then the first divided difference of f for the argumentsx0, x1, . . . , xn are defined by ,
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Divided Difference
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
58/156
Let f
(x
0), f
(x
1), . . . , f
(xn) be the values of a function
f
corresponding to the arguments x0, x1, . . . , xn where the intervalsx1 − x0, x2 − x1, . . . , xn − xn−1 are not necessarily equally spaced.Then the first divided difference of f for the argumentsx0, x1, . . . , xn are defined by ,
f (x0, x1) = f (x1) − f (x0)
x1 − x0
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Divided Difference
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
59/156
Let f (x0
), f (x1
), . . . , f (xn
) be the values of a function f corresponding to the arguments x0, x1, . . . , xn where the intervalsx1 − x0, x2 − x1, . . . , xn − xn−1 are not necessarily equally spaced.Then the first divided difference of f for the argumentsx0, 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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
60/156
The second divided difference of f for three argumentsx0, x1, x2 is defined by
f (x0, x1, x2) = f (x1, x2) − f (x0, x1)
x2
−x0
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Divided Difference
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
61/156
The second divided difference of f for three argumentsx0, 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, . . . , xn−1)
xn − x0
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Divided Difference
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
62/156
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
63/156
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
64/156
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 areconstant, equal to the coefficient of xn.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
A i t l ti f l hi h h th t th t
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
65/156
An interpolation formula which has the property that apolynomial of higher degree may be derived from it by simply
adding new terms.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
A i t l ti f l hi h h th t th t
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
66/156
An interpolation formula which has the property that apolynomial of higher degree may be derived from it by simply
adding new terms.Newton’s general interpolation formula is one such formula andterms in it are called divided differences.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
A i t l ti f l hi h h th t th t
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
67/156
An interpolation formula which has the property that apolynomial of higher degree may be derived from it by simply
adding new terms.Newton’s general interpolation formula is one such formula andterms 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 intervalsx1 − x0, x2 − x1, . . . , xn − xn−1 are not necessarily equally spaced.By the definition of divided difference,
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
An interpolation formula which has the property that a
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
68/156
An interpolation formula which has the property that apolynomial of higher degree may be derived from it by simply
adding new terms.Newton’s general interpolation formula is one such formula andterms 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 intervalsx1 − x0, x2 − x1, . . . , xn − xn−1 are not necessarily equally spaced.By the definition of divided difference,
f (x, x0) =
f (x)
−f (x0)
x − x0
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
An interpolation formula which has the property that a
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
69/156
An interpolation formula which has the property that apolynomial of higher degree may be derived from it by simply
adding new terms.Newton’s general interpolation formula is one such formula andterms 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 intervalsx1 − x0, x2 − x1, . . . , xn − xn−1 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
Newton’s Divided Difference Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
70/156
Further
f (x, x0, x1) =
f (x, x0)
−f (x0, x1)
x − x1
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
71/156
Further
f (x, x0, x1) =
f (x, x0)
−f (x0, x1)
x − x1which yields
f (x, x0) = f (x0, x1) + (x − x1)f (x, x0, x1) −−(2)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
72/156
Further
f (x, x0, x1) =
f (x, x0)
−f (x0, x1)
x − x1which 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
Newton’s Divided Difference Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
73/156
Further
f (x, x0, x1) =
f (x, x0)
−f (x0, x1)
x − x1which 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,...,xn−1) = f (x0, x1,...,xn) + (x−xn)f (x, x0, x1,...,xn)−−(4)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
74/156
multiplying equation (2) by (x − x0)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
75/156
multiplying equation (2) by (x − x0) , (3) by (x − x0) (x − x1)and so on,
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
76/156
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 − xn−1) and
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
77/156
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 − xn−1) and adding (1), (2) , (3) up to (4)we obtain
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
78/156
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 − xn−1) 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 − xn−1) f (x0, x1,...,xn)This formula is called Newton’s divided difference formula.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Newton’s Divided Difference Interpolation
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
79/156
The divided difference upto third order
x y 1stdiv.diff. 2nddiv.diff. 3rddiv.diff.
x0 y0
[x0, x1]x1 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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
80/156
Ex. Obtain the divided difference table for the data:
x -1 0 2 3y -8 3 1 12
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
S l W h th f ll i di id d diff t bl f th d t
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
81/156
Sol. We have the following divided difference table for the data:
x y First d.d Second d.d Third d.d
-1 -83 + 8
0 + 1 = 11
0 3 −1 − 112 + 1
= −41 − 32 − 0 = −1
4 + 4
3 + 1 = 2
2 1 11 + 1
3−
0 = 4
12 − 13 − 2 = 11
3 12
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
82/156
Ex. Find f (x) as a polynomial in x for the following data by Newtonsdivided difference formula:
x -4 -1 0 2 5
f (x) 1245 33 5 9 1335
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
83/156
Sol. We have the following divided difference table for the data:
x y 1st d.d 2nd d.d 3rd d.d 4th d.d
-4 1245−404
-1 33 94−28 −140 5 10 3
2 132 9 88
4425 1335
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
84/156
The Newtons divided difference formula gives:
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
85/156
The Newtons divided difference formula gives:
f (x) = f (x0) +
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
86/156
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
87/156
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
88/156
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
89/156
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
90/156
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
91/156
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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
92/156
Ex. Find f (x) as a polynomial in x for the following data by Newtonsdivided difference formula:
x -2 -1 0 1 3 4f (x) 9 16 17 18 44 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.
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
93/156
x f (x) 1st d.d 2nd d.d 3rd d.d 4th d.d
−2 97
−1 16 −31 1
0 17 0 01 1
1 18 4 013 1
3 44 837
4 81
Dr N B Vyas Numerical Methods Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
94/156
Since, the fourth order differences are zeros, the data represents athird degree polynomial. Newtons divided difference formulagives the polynomial as
f (x) = f (x0) +
Dr N B Vyas Numerical Methods Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
95/156
Since, the fourth order differences are zeros, the data represents athird degree polynomial. Newtons divided difference formulagives 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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
96/156
Since, the fourth order differences are zeros, the data represents athird degree polynomial. Newtons divided difference formulagives 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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
97/156
Since, the fourth order differences are zeros, the data represents athird degree polynomial. Newtons divided difference formulagives 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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
98/156
Since, the fourth order differences are zeros, the data represents athird degree polynomial. Newtons divided difference formulagives 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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
99/156
Ex. Find the missing term in the following table:
x 0 1 2 3 4y 1 3 9 - 81
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
100/156
Sol. Divided difference table:
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
101/156
Sol. Divided difference table:
By Newton’s 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
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
102/156
Spline interpolation is a form of interpolation where the
interpolant is a special type of piecewise polynomial called aspline
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 (x) and f (x) are continuous at each point.
Since f (x) is cubic in each of the subintervals f
(x) shall belinear.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Spline Interpolation
f (x) = (xi+1 − x)3M i
6h +
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
103/156
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Spline Interpolation
f (x) = (xi+1 − x)3M i
6h +
(x − xi)3M i+16h
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
104/156
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Spline Interpolation
f (x) = (xi+1 − x)3M i
6h +
(x − xi)3M i+16h
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
105/156
+(xi+1 − x)
h
yi − h
2
6 M i
+
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Spline Interpolation
f (x) = (xi+1 − x)3M i
6h +
(x − xi)3M i+16h
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
106/156
+(xi+1 − x)
h
yi − h
2
6 M i
+
(x − xi)h
yi+1 − h
2
6 M i+1
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Spline Interpolation
f (x) = (xi+1 − x)3M i
6h +
(x − xi)3M i+16h
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
107/156
+(xi+1 − x)
h
yi − h
2
6 M i
+
(x − xi)h
yi+1 − h
2
6 M i+1
where M i−1 + 4M i + M i+1 = 6
h2(yi−1 − 2yi + yi+1),
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Spline Interpolation
f (x) = (xi+1 − x)3M i
6h +
(x − xi)3M i+16h
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
108/156
+(xi+1 − x)
h
yi − h
2
6 M i
+
(x − xi)h
yi+1 − h
2
6 M i+1
where M i−1 + 4M i + M i+1 = 6
h2(yi−1 − 2yi + yi+1),
i = 1, 2, 3, ..., (n − 1)
and M 0 = 0, M n = 0, xi+1
−xi = h.
which gives n + 1 equations in n + 1 unknowns M i(i = 0, 1,...,n)which can be solved. Substituting the value of M i gives theconcerned cubic spline.
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
109/156
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,
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
110/156
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
6
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
111/156
M i−1 + 4M i + M i+1 = h2 (yi−1 − 2yi + yi+1), i = 1, 2
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M M M 6
y y y i
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
112/156
M i−1 + 4
M i +
M i+1 = h2 (
yi−1 − 2
yi +
yi+1)
, i = 1
,2
also M 0 = 0 , M 3 = 0
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M M M 6
y y y i
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
113/156
M i−1 + 4
M i +
M i+1 = h2 (
yi−1 − 2
yi +
yi+1)
, i = 1
,2
also M 0 = 0 , M 3 = 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 cubicspline can be determined from
M M M 6
y y y i
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
114/156
M i−1 + 4
M i +
M i+1 = h2 (
yi−1 − 2
yi +
yi+1)
, i = 1
,2
also M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 36; —(1)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M + 4M + M = 6
(y 2y + y ) i = 1 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
115/156
M i−1
+ 4M i + M
i+1
h2(y
i−1 −2y
i + y
i+1), i 1, 2
also M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 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 cubicspline can be determined from
M + 4M + M = 6
(y 2y + y ), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
116/156
M i−1
+ 4M i + M
i+1
h2(y
i−1 −2y
i + y
i+1), i 1, 2
also M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 36; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 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 cubicspline can be determined from
M − + 4M + M = 6
(y − 2y + y ), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
117/156
i 1+
i+
i+1 h2(y
i 1 −yi
+ yi+1
), i ,
also M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 36; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1−
2y2 + y3)
M 1 + 4M 2 = 72 —(2)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i− + 4M i + M i = 6
(yi− 2yi + yi ), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
118/156
i1
+ i + i+1 h2
(yi1 −
yi + yi+1
), ,
also M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 36; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1−
2y2 + y3)
M 1 + 4M 2 = 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 cubicspline can be determined from
M i− + 4M i + M i = 6
(yi− 2yi + yi ), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
119/156
i1
i i+1 h2
(yi1 −
yi yi+1
), ,
also M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 36; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1−
2y2 + y3)
M 1 + 4M 2 = 72 —(2)
solving these, we get M 1 =
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i− + 4M i + M i = 6
(yi− 2yi + yi ), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
120/156
1 +1 h2(y
1 −y y
+1)
also M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 36; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1−
2y2 + y3)
M 1 + 4M 2 = 72 —(2)
solving these, we get M 1 =4.8 and M 2 =
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
(yi−1 2yi + yi+1), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
121/156
h2 −also M 0 = 0 , M 3 = 0∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)
therefore, 4M 1 + M 2 = 36; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1−
2y2 + y3)
M 1 + 4M 2 = 72 —(2)
solving these, we get M 1 =4.8 and M 2 =16.8
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
(yi−1 2yi + yi+1), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
122/156
h2 −also M 0 = 0 , M 3 = 0∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)
therefore, 4M 1 + M 2 = 36; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1−
2y2 + y3)
M 1 + 4M 2 = 72 —(2)
solving these, we get M 1 =4.8 and M 2 =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 cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
(yi−1 2yi + yi+1), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
123/156
h2 −also M 0 = 0 , M 3 = 0∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)
therefore, 4M 1 + M 2 = 36; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1−
2y2 + y3)
M 1 + 4M 2 = 72 —(2)
solving these, we get M 1 =4.8 and M 2 =16.8
Now the cubic spline in (xi ≤ x ≤ xi+1) isf (x) =
(xi+1 − x)3M i6h
+
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h(yi−1 2yi + yi+1), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
124/156
h2 −also M 0 = 0 , M 3 = 0∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)
therefore, 4M 1 + M 2 = 36; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1−
2y2 + y3)
M 1 + 4M 2 = 72 —(2)
solving these, we get M 1 =4.8 and M 2 =16.8
Now the cubic spline in (xi ≤ x ≤ xi+1) isf (x) =
(xi+1 − x)3M i6h
+(x − xi)3M i+1
6h
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2(yi−1 2yi + yi+1), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
125/156
h2 −also M 0 = 0 , M 3 = 0∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)
therefore, 4M 1 + M 2 = 36; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1−
2y2 + y3)
M 1 + 4M 2 = 72 —(2)
solving these, we get M 1 =4.8 and M 2 =16.8
Now the cubic spline in (xi ≤ x ≤ xi+1) isf (x) =
(xi+1 − x)3M i6h
+(x − xi)3M i+1
6h
+(xi+1 − x)
h
yi − h
2
6 M i
+
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2(yi−1 2yi + yi+1), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
126/156
h2 −also M 0 = 0 , M 3 = 0∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)
therefore, 4M 1 + M 2 = 36; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 72 —(2)
solving these, we get M 1 =4.8 and M 2 =16.8
Now the cubic spline in (xi ≤ x ≤ xi+1) isf (x) =
(xi+1 − x)3M i6h
+(x − xi)3M i+1
6h
+(xi+1 − x)
h
yi − h
2
6 M i
+
(x − xi)h
yi+1 − h
2
6 M i+1
—(3)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2(yi−1 2yi + yi+1), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
127/156
h2 −also M 0 = 0 , M 3 = 0∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)
therefore, 4M 1 + M 2 = 36; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 72 —(2)
solving these, we get M 1 =4.8 and M 2 =16.8
Now the cubic spline in (xi ≤ x ≤ xi+1) isf (x) =
(xi+1 − x)3M i6h
+(x − xi)3M i+1
6h
+(xi+1 − x)
h
yi − h
2
6 M i
+
(x − xi)h
yi+1 − h
2
6 M i+1
—(3)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
128/156
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(3)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3,
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
129/156
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2(yi−1 2yi + yi+1), i = 1, 2
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
130/156
h2 −
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2(yi−1 2yi + yi+1), i = 1, 2
l M M
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
131/156
h2 −also M 0 = 0 , M 3 = 0
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2(yi−1 2yi + yi+1), i = 1, 2
l M 0 M 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
132/156
h2 −also M 0 = 0 , M 3 = 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 cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2(yi−1
−2yi + yi+1), i = 1, 2
l M 0 M 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
133/156
h2 −also M 0 = 0 , M 3 = 0∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)
therefore, 4M 1 + M 2 = 12; —(1)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2(yi−1
−2yi + yi+1), i = 1, 2
l M 0 M 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
134/156
h2also M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 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 cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2(yi−1
−2yi + yi+1), i = 1, 2
also M 0 M 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
135/156
halso M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 12; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 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 cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2(yi−1
−2yi + yi+1), i = 1, 2
also M = 0 M = 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
136/156
halso M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 12; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 18 —(2)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2
(yi−1−
2yi + yi+1), i = 1, 2
also M0 = 0 M3 = 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
137/156
halso M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 12; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 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 cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2
(yi−1−
2yi + yi+1), i = 1, 2
also M0 = 0 M3 = 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
138/156
also M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 12; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 18 —(2)solving these, we get M 1 =
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2
(yi−1−
2yi + yi+1), i = 1, 2
also M0 = 0 M3 = 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
139/156
also M 0 = 0 , M 3 = 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 12; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 18 —(2)solving these, we get M 1 =2 and M 2 =
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2
(yi−1−
2yi + yi+1), i = 1, 2
also M0 = 0 M3 = 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
140/156
also M 0 0 , M 3 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 12; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 18 —(2)solving these, we get M 1 =2 and M 2 =4
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2
(yi−1−
2yi + yi+1), i = 1, 2
also M0 = 0 , M3 = 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
141/156
also M 0 0 , M 3 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 12; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 18 —(2)solving these, we get M 1 =2 and M 2 =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 cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2
(yi−1
−2yi + yi+1), i = 1, 2
also M 0 = 0 , M 3 = 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
142/156
0 0 , 3 0
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 12; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 18 —(2)solving these, we get M 1 =2 and M 2 =4
Now the cubic spline in (xi ≤ x ≤ xi+1) isf (x) =
(xi+1 − x)3M i6h
+
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2
(yi−1
−2yi + yi+1), i = 1, 2
also M 0 = 0 , M 3 = 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
143/156
0 , 3∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)
therefore, 4M 1 + M 2 = 12; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 18 —(2)solving these, we get M 1 =2 and M 2 =4
Now the cubic spline in (xi ≤ x ≤ xi+1) isf (x) =
(xi+1 − x)3M i6h
+(x − xi)3M i+1
6h
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2
(yi−1
−2yi + yi+1), i = 1, 2
also M 0 = 0 , M 3 = 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
144/156
0 , 3∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)
therefore, 4M 1 + M 2 = 12; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 18 —(2)solving these, we get M 1 =2 and M 2 =4
Now the cubic spline in (xi ≤ x ≤ xi+1) isf (x) =
(xi+1 − x)3M i6h
+(x − xi)3M i+1
6h
+(xi+1 − x)
h
yi − h
2
6 M i
+
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2
(yi−1
−2yi + yi+1), i = 1, 2
also M 0 = 0 , M 3 = 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
145/156
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 12; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 18 —(2)solving these, we get M 1 =2 and M 2 =4
Now the cubic spline in (xi ≤ x ≤ xi+1) isf (x) =
(xi+1 − x)3M i6h
+(x − xi)3M i+1
6h
+(xi+1 − x)
h
yi − h
2
6 M i
+
(x − xi)h
yi+1 − h
2
6 M i+1
—(3)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. Since points are equispaced with h = 1 and n = 3, the cubicspline can be determined from
M i−1 + 4M i + M i+1 = 6
h2
(yi−1
−2yi + yi+1), i = 1, 2
also M 0 = 0 , M 3 = 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
146/156
∴ for i = 1, M 0 + 4M 1 + M 2 = 6(y0 − 2y1 + y2)therefore, 4M 1 + M 2 = 12; —(1)
for i = 2, M 1 + 4M 2 + M 3 = 6(y1
−2y2 + y3)
M 1 + 4M 2 = 18 —(2)solving these, we get M 1 =2 and M 2 =4
Now the cubic spline in (xi ≤ x ≤ xi+1) isf (x) =
(xi+1 − x)3M i6h
+(x − xi)3M i+1
6h
+(xi+1 − x)
h
yi − h
2
6 M i
+
(x − xi)h
yi+1 − h
2
6 M i+1
—(3)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Ex Find whether the following functions are cubic splines ?
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
147/156
Ex. Find whether the following functions are cubic splines ?
1. f (x) = 5x3 − 3x2, −1 ≤ x ≤ 0
= −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 bothintervals (1, 0) and (0, 1).
1. We have
limx→0+
f (x)
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
148/156
x→0
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. In both the examples, f (x) is a cubic polynomial in bothintervals (1, 0) and (0, 1).
1. We have
limx→0+
f (x) = 0
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
149/156
x→0
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. In both the examples, f (x) is a cubic polynomial in bothintervals (1, 0) and (0, 1).
1. We have
limx→0+
f (x) = 0 = limx→0−
f (x)
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
150/156
x→0 x→0
therefore, given function f (x) is continuous on (−1, 1).
Nowf (x)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. In both the examples, f (x) is a cubic polynomial in bothintervals (1, 0) and (0, 1).
1. We have
limx→0+
f (x) = 0 = limx→0−
f (x)
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
151/156
therefore, given function f (x) is continuous on (−1, 1).
Nowf (x) = 15x2 − 6x, −1 ≤ x ≤ 0
=
−15x2
−6x, 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 bothintervals (1, 0) and (0, 1).
1. We have
limx→0+
f (x) = 0 = limx→0−
f (x)
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
152/156
therefore, given function f (x) is continuous on (−1, 1).
Nowf (x) = 15x2 − 6x, −1 ≤ x ≤ 0
=
−15x2
−6x, 0
≤x
≤1
we have,
limx→0+
f (x)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. In both the examples, f (x) is a cubic polynomial in bothintervals (1, 0) and (0, 1).
1. We have
limx→0+
f (x) = 0 = limx→0−
f (x)
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
153/156
therefore, given function f (x) is continuous on (−1, 1).
Nowf (x) = 15x2 − 6x, −1 ≤ x ≤ 0
=
−15x2
−6x, 0
≤x
≤1
we have,
limx→0+
f (x) = 0
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. In both the examples, f (x) is a cubic polynomial in bothintervals (1, 0) and (0, 1).
1. We have
limx→0+
f (x) = 0 = limx→0−
f (x)
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
154/156
therefore, given function f (x) is continuous on (−1, 1).
Nowf (x) = 15x2 − 6x, −1 ≤ x ≤ 0
=
−15x2
−6x, 0
≤x
≤1
we have,
limx→0+
f (x) = 0 = limx→0−
f (x)
therefore, the function f (x) is continuous on (
−1, 1).
f (x)
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals
Example
Sol. In both the examples, f (x) is a cubic polynomial in bothintervals (1, 0) and (0, 1).
1. We have
limx→0+
f (x) = 0 = limx→0−
f (x)
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
155/156
therefore, given function f (x) is continuous on (−1, 1).
Nowf (x) = 15x2 − 6x, −1 ≤ x ≤ 0
=
−15x2
−6x, 0
≤x
≤1
we have,
limx→0+
f (x) = 0 = limx→0−
f (x)
therefore, the function f (x) is continuous on (
−1, 1).
f (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 bothintervals (1, 0) and (0, 1).
1. We have
limx→0+
f (x) = 0 = limx→0−
f (x)
-
8/20/2019 Dr. Nirav Vyas numerical method 4.pdf
156/156
therefore, given function f (x) is continuous on (−1, 1).
Nowf (x) = 15x2 − 6x, −1 ≤ x ≤ 0
=
−15x2
−6x, 0
≤x
≤1
we have,
limx→0+
f (x) = 0 = limx→0−
f (x)
therefore, the function f (x) is continuous on (
−1, 1).
f (x) = 30x−6, −1 ≤ x ≤ 0= −30x − 6, 0 ≤ x ≤ 1
Dr. N. B. Vyas Numerical Methods - Interpolation Unequal Intervals