Professional Documents
Culture Documents
Numerical
Analysis
Piecewise
Polynomial
Interpolation
Piecewise Linear
ES-341: Numerical Analysis
Interpolation
Piecewise Quadratic
Interpolation
Piecewise Cubic
Interpolation
Dr. Mazhar Ali
Mehboob ul Haq (TA)
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 1 / 27
ES-341:
Numerical
Analysis
Piecewise
Polynomial
Interpolation
Piecewise Linear
Interpolation
Piecewise Quadratic
Interpolation
Piecewise Cubic
1 Piecewise Polynomial Interpolation
Interpolation
Piecewise Linear Interpolation
Piecewise Quadratic Interpolation
Piecewise Cubic Interpolation
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 2 / 27
ES-341:
Numerical
Analysis
Piecewise
Polynomial
Interpolation
Piecewise Linear
Interpolation
Piecewise Quadratic
Interpolation
Piecewise Cubic
Interpolation
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 3 / 27
ES-341:
Numerical
Analysis
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 4 / 27
ES-341:
Numerical
Analysis
Piecewise
Polynomial
Interpolation
Piecewise Linear
𝑠0 (𝑥)
Interpolation 𝑠1 (𝑥) 𝑠0 (𝑥)
𝑠0 (𝑥)
Piecewise Quadratic
Interpolation 𝑠𝑗 (𝑥)
Piecewise Cubic
Interpolation
Definition
We can divide an interval [x0 , xn ] into set of n number of small
intervals {[x0 , x1 ], [x1 , x2 ], . . . , [xn−1 , xn ]} and then for each
sub-interval [xj , xj+1 ], j = 0, 1, 2, . . . , n − 1 we approximate with
collection of n number of spline polynomials sj (x) (either linear,
quadratic, or cubic) as shown in the Fig.
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 5 / 27
ES-341:
Numerical
Analysis
a0 + b0 (x − x0 ) x0 ≤ x ≤ x1
a1 + b1 (x − x1 ) x1 ≤ x ≤ x2
s(x) = ..
.
an−1 + bn−1 (x − xn−1 ) xn−1 ≤ x ≤ xn
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 6 / 27
ES-341:
Numerical
Analysis
if x = xj ⇒ sj (xj ) = f (xj ) j = 0, 1, 2, . . . , n − 1
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 7 / 27
ES-341:
Numerical
Analysis
Solution
In this case we will construct only two linear splines i.e., s0 (x) between
[x0 , x1 ] = [1, 2] and another ons1 (x) between [x1 , x2 ] = [2, 3],
( )
s0 (x) = a0 + b0 (x − 1) 1≤x ≤2
s(x) =
s1 (x) = a1 + b1 (x − 2) 2≤x ≤3
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 8 / 27
ES-341:
Numerical
Analysis
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 9 / 27
ES-341:
Numerical
Analysis Hence, the spline is,
Dr. Mazhar Ali
Mehboob ul Haq
( )
(TA) s0 (x) = 2 + 1(x − 1) 1≤x ≤2
s(x) =
Piecewise s1 (x) = 3 + 2(x − 2) 2≤x ≤3
Polynomial
Interpolation
Piecewise Linear
Interpolation We can evaluate f (2.5) as,
Piecewise Quadratic
Interpolation
Piecewise Cubic
Interpolation s1 (2.5) = 4
a0 + b0 (x − x0 ) + c0 (x − x0 )2 x0 ≤ x ≤ x1
2
a1 + b1 (x − x1 ) + c1 (x − x1 ) x1 ≤ x ≤ x2
s(x) = ..
.
..
.
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 11 / 27
ES-341:
Numerical
Analysis
if x = xj ⇒ sj (xj ) = f (xj ) j = 0, 1, 2, . . . , n − 1
We are still short of n more conditions to solve for all the unknown
coefficients.
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 12 / 27
ES-341:
Numerical
Analysis Conditions
Dr. Mazhar Ali
Mehboob ul Haq We can exploit this fact that adjacent splines i.e., sj (x) and
(TA)
sj+1 (x) must coincide at xj+1 (for instance, s0 (x1 ) = s1 (x1 ))
Piecewise
Polynomial
Interpolation sj (xj+1 ) = sj+1 (xj+1 ) j = 0, 1, . . . , n − 2
Piecewise Linear
Interpolation
Piecewise Quadratic
Interpolation
The above criteria can be used to ensure that the set of splines
Piecewise Cubic
Interpolation
s(x) = {sj (x)} are smooth on the adjacent nodes xj+1 , we can
derive the condition about differentiability from the following
relation,
s ′ (xn ) = 0
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 13 / 27
ES-341:
Numerical
Analysis
Solution
In this case we will construct only two quadratic splines i.e., s0 (x)
between [x0 , x1 ] = [1, 2] and another ons1 (x) between [x1 , x2 ] = [2, 3],
( )
s0 (x) = a0 + b0 (x − 1) + c0 (x − 1)2 1≤x ≤2
s(x) =
s1 (x) = a1 + b1 (x − 2) + c1 (x − 2)2 2≤x ≤3
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 14 / 27
ES-341:
Numerical
Analysis
s0 (x0 ) = a0 = f (x0 ) = 2
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 15 / 27
ES-341:
Numerical
Analysis
s ′ (xn ) = 0
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 16 / 27
ES-341:
Numerical
Analysis Hence, the spline is,
Dr. Mazhar Ali
Mehboob ul Haq
( )
(TA) s0 (x) = 2 − 2(x − 1) + 3(x − 1)2 1≤x ≤2
s(x) =
Piecewise s1 (x) = 3 + 4(x − 2) − 2(x − 2)2 2≤x ≤3
Polynomial
Interpolation
Piecewise Linear
Interpolation We can evaluate f (2.5) as,
Piecewise Quadratic
Interpolation
Piecewise Cubic
Interpolation s1 (2.5) = 4.5
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 17 / 27
ES-341:
Numerical
Analysis
a0 + b0 (x − x0 ) + c0 (x − x0 )2 + d0 (x − x0 )3 [x0 , x1 ]
2 3
a1 + b1 (x − x1 ) + c1 (x − x1 ) + d1 (x − x1 ) [x1 , x2 ]
s(x) = ..
.
..
.
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 18 / 27
ES-341:
Numerical
Analysis
if x = xj ⇒ sj (xj ) = f (xj ) j = 0, 1, 2, . . . , n − 1
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 19 / 27
ES-341:
Numerical
Analysis
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 20 / 27
ES-341:
Numerical
Analysis
Conditions
Piecewise
Polynomial
Interpolation Finally, we can apply the following boundary conditions,
Piecewise Linear
Interpolation
Piecewise Quadratic
Interpolation
s ′′ (x0 ) = 0 & s ′′ (xn ) = 0
Piecewise Cubic
Interpolation
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 21 / 27
ES-341:
Numerical
Analysis
Solution
In this case we will construct only two cubic splines i.e., s0 (x) between
[x0 , x1 ] = [1, 2] and another on s1 (x) between [x1 , x2 ] = [2, 3],
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 22 / 27
ES-341:
Numerical
Analysis
Solution
In this case we will construct only two cubic splines i.e., s0 (x) between
[x0 , x1 ] = [1, 2] and another on s1 (x) between [x1 , x2 ] = [2, 3],
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 22 / 27
ES-341:
Numerical
Analysis
Solution
In this case we will construct only two cubic splines i.e., s0 (x) between
[x0 , x1 ] = [1, 2] and another on s1 (x) between [x1 , x2 ] = [2, 3],
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 22 / 27
ES-341:
Numerical
Analysis We have eight unknowns a0 , a1 , b0 , b1 c0 , c1 and d0 , d1 ,
Dr. Mazhar Ali
Mehboob ul Haq
Applying conditions
(TA)
Piecewise
if x = xj ⇒ sj (xj ) = f (xj ) j = 0, 1, 2
Polynomial
Interpolation
Piecewise Linear
Interpolation
Piecewise Quadratic
Interpolation
Piecewise Cubic
Interpolation
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 23 / 27
ES-341:
Numerical
Analysis We have eight unknowns a0 , a1 , b0 , b1 c0 , c1 and d0 , d1 ,
Dr. Mazhar Ali
Mehboob ul Haq
Applying conditions
(TA)
Piecewise
if x = xj ⇒ sj (xj ) = f (xj ) j = 0, 1, 2
Polynomial
Interpolation
Piecewise Linear
Interpolation
Piecewise Quadratic if x = xj+1 ⇒ sj (xj+1 ) = f (xj+1 ) j = 0, 1, 2
Interpolation
Piecewise Cubic
Interpolation
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 23 / 27
ES-341:
Numerical
Analysis We have eight unknowns a0 , a1 , b0 , b1 c0 , c1 and d0 , d1 ,
Dr. Mazhar Ali
Mehboob ul Haq
Applying conditions
(TA)
Piecewise
if x = xj ⇒ sj (xj ) = f (xj ) j = 0, 1, 2
Polynomial
Interpolation
Piecewise Linear
Interpolation
Piecewise Quadratic if x = xj+1 ⇒ sj (xj+1 ) = f (xj+1 ) j = 0, 1, 2
Interpolation
Piecewise Cubic
Interpolation
s0 (x0 ) = a0 = f (x0 ) = 2
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 23 / 27
ES-341:
Numerical
Analysis We have eight unknowns a0 , a1 , b0 , b1 c0 , c1 and d0 , d1 ,
Dr. Mazhar Ali
Mehboob ul Haq
Applying conditions
(TA)
Piecewise
if x = xj ⇒ sj (xj ) = f (xj ) j = 0, 1, 2
Polynomial
Interpolation
Piecewise Linear
Interpolation
Piecewise Quadratic if x = xj+1 ⇒ sj (xj+1 ) = f (xj+1 ) j = 0, 1, 2
Interpolation
Piecewise Cubic
Interpolation
s0 (x0 ) = a0 = f (x0 ) = 2
Similarly,
s1 (x1 ) = a1 = f (x1 ) = 3
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 24 / 27
ES-341:
Numerical
Analysis Applying the differentiability conditions for cubic splines,
Dr. Mazhar Ali
Mehboob ul Haq
(TA) sj′ (xj+1 ) = sj+1
′
(xj+1 ) j = 0, 1, . . . , n − 2
Piecewise
Polynomial
Interpolation
s0′ (x1 ) = s1′ (x1 )
Piecewise Linear
Interpolation
s0′ (x) = b0 + 2c0 (x − x0 ) + 3d0 (x − x0 )2
Piecewise Quadratic
Interpolation
Piecewise Cubic
Interpolation
s1′ (x) = b1 + 2c1 (x − x1 ) + 3d1 (x − x1 )2
s0′ (x1 ) = s1′ (x1 ) ⇒ b0 + 2c0 + 3d0 = b1
applying second differentiability condition,
Piecewise
Applying necessary free/natural boundary conditions
Polynomial
Interpolation
Piecewise Linear
Interpolation
s ′′ (x0 ) = 0
Piecewise Quadratic
Interpolation
Piecewise Cubic
Interpolation
s0′′ (x) = 2c0 + 6d0 (x − 1)
s0′′ (x0 ) = 2c0 = 0 ⇒ c0 = 0
s ′′ (xn ) = 0
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 25 / 27
ES-341:
Numerical
Analysis
6d0 − 2c1 = 0
2c1 + 6d1 = 0
From all the conditions we can assemble following system of linear
equations,
1 1 0 0 0 b0 1
0 0 1 1 1 d0 2
1 3
−1 0 0
b1 = 0
0 6 0 −2 0 c1 0
0 0 0 2 6 d1 0
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 26 / 27
ES-341:
Numerical After solving the system of equations we get,
Analysis
Dr. Mazhar Ali Mehboob ul Haq (TA) (Ghulam Ishaq Khan Institute
ES-341:
of Engineering
NumericalSciences
Analysis
and Technology) 20 − 24th April 2022 27 / 27
ES-341:
Numerical After solving the system of equations we get,
Analysis