4.0 Finite Difference Methods and Interpolation
4.0 Finite Difference Methods and Interpolation
4.0 Finite Difference Methods and Interpolation
MATHEMATICS
CODE: EHAEM4A
Lecturer: Lawrence (R201)
Topic 3: Finite Difference Methods and Interpolation
Introduction
• This forms a basis for both differential calculus and finite difference calculus
Symbolic operators
𝑥 − 𝑥𝑜 2 𝑓 ′′𝑥𝑜 𝑥 − 𝑥𝑜 3 𝑓 ′′′
𝑥𝑜
𝑓(𝑥) = 𝑓(𝑥𝑜 ) + 𝑥 − 𝑥𝑜 𝑓 ′𝑥𝑜 + + +⋯
2! 3!
𝑥 − 𝑥𝑜 2 𝑓 ′′𝑥𝑜
…+ + 𝑅𝑛 (𝑥)
2!
• Where 𝑅𝑛 (𝑥) is the remainder summing up the remaining terms in the infinite
series from (𝑛 + 1) to infinity. This can be represented using mean-value
theorem to give:
𝑥 − 𝑥0 𝑛+1 𝑓 𝑛+1 (𝜉)
𝑅𝑥 𝑥 =
𝑛+1 !
• The value of 𝜉 is an unknown function therefore it is impossible to evaluate
the remainder, or truncation term error.
• The order of the remainder will always be specified.
Symbolic operators
• The calculus of finite differences is evaluated with Taylor series of discrete values e.g.
𝑦𝑖−3 𝑦𝑖−2 𝑦𝑖−1 𝑦𝑖 𝑦𝑖+1 𝑦𝑖+2 𝑦𝑖+3
• Or as a continuous function:
𝑦(𝑥−3ℎ) 𝑦(𝑥−2ℎ) 𝑦(𝑥−ℎ) 𝑦(𝑥) 𝑦(𝑥+1ℎ) 𝑦(𝑥+2ℎ) 𝑦(𝑥+3ℎ)
• The differential operator D has the following effect when applied to a function
𝑦(𝑥):
𝑑𝑦(𝑥)
𝐷𝑦 𝑥 = = 𝑦′
𝑑𝑥
• And the integral operator is:
𝑥+ℎ
𝐼𝑦 𝑥 = න 𝑦 𝑥 𝑑𝑥
𝑥
• The integral operator is equivalent to the inverse of the differential operator
𝐼 = 𝐷−1
Symbolic operators
• Shift operator causes the function to shift to the next successive value of the
independent variable:
𝐸𝑦 𝑥 = 𝑦(𝑥 + ℎ)
• The inverse of the shift operator, E-1 causes the function to shift in the negative
direction of the independent variable:
𝐸 −1 𝑦 𝑥 = 𝑦(𝑥 − ℎ)
• Higher powers of the shift operator are defined as:
𝐸 𝑛 𝑦 𝑥 = 𝑦(𝑥 + 𝑛ℎ)
• The shift operator can be expressed in terms of the differential operator by
expanding the function 𝑦(𝑥 + ℎ) into a Taylor series about 𝑥:
ℎ ′ ℎ2 ′′ ℎ3 ′′′
𝑦 𝑥 + ℎ = 𝑦 𝑥 + 𝑦 𝑥 + 𝑦 𝑥 + 𝑦 𝑥 +. .
1! 2! 3!
• Using the differential operator D to indicate the derivatives of y, we obtain:
ℎ ℎ2 2 ℎ3 3
𝑦 𝑥 + ℎ = 𝑦 𝑥 + 𝐷𝑦 𝑥 + 𝐷 𝑦 𝑥 + 𝐷 𝑦 𝑥 +. .
1! 2! 3!
Symbolic operators
• Similarly, the inverse of the shift operator can be related to the differential
operator by expanding the function 𝑦 𝑥 − ℎ into a Taylor series about 𝑥:
ℎ ′ ℎ2 ′′ ℎ3 ′′′
𝑦 𝑥 − ℎ = 𝑦 𝑥 − 𝑦 𝑥 + 𝑦 𝑥 − 𝑦 𝑥 +. .
1! 2! 3!
• Replacing the derivatives with differential operators and rearranging we obtain:
ℎ ℎ2 2 ℎ3 3
𝑦 𝑥 − ℎ = 1 − 𝐷 + 𝐷 − 𝐷 +. . 𝑦(𝑥)
1! 2! 3!
• The term in parenthesis are equivalent to the series expansion
−ℎ𝐷
ℎ ℎ2 2 ℎ3 3
𝑒 = 1 − 𝐷 + 𝐷 − 𝐷 +. .
1! 2! 3!
• Therefore it becomes:
𝑦 𝑥 − ℎ = 𝑒 −ℎ𝐷 𝑦(𝑥)
• It can be concluded that the shift operator can be expressed in terms of
differential operator by relation:
𝐸 −1 = 𝑒 −ℎ𝐷
Backward finite differences
Backward finite differences
Backward finite differences
• Alternatively:
Problem:
• Use forward, backward and central difference approximations to estimate the
derivative of the equation below at x=0.5 using a step size h=0.5.
• Repeat the computation using h=0.25
•
Finite differences - Example
Finite differences - Example
Finite differences – To do
Interpolating Polynomials
• Taking the known values of the function f(x) over (n+1) sets of values of the
independent variable x.
x0 f(x0)
x1 f(x1)
X2 f(X2)
xn f(xn)
• The objective is to develop an interpolating polynomial that fits exactly the points of
the function and connects these points with smooth curve.
𝑃𝑛 𝑥 = 𝑎0 + 𝑎0 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3 + ⋯ … . +𝑎𝑛 𝑥 𝑛
• This polynomial can then be used to approximate the function at any value of the
independent variable x between the base points.
• For given (n+1) known base points, the polynomial must satisfy the equation:
𝑃𝑛 𝑥𝑖 = 𝑓 𝑥𝑖 𝑖 = 0, 1, 2, … . , 𝑛
• Substituting the known values of (𝑥𝑖 , 𝑓 𝑥𝑖 ) into the previous equation yields a set of
(n+1) simultaneous linear algebraic equations whose unknown values are the
coefficients 𝑎0 , 𝑎0 , … . , 𝑎𝑛 of the polynomial equation.
Interpolation of equally spaced points
Gregory-Newton Interpolation
• For a set of known values of the function f(x) at equally spaced values of x:
• These points are tabulated for first, second and third forward and backward differences.
• Go through the notes on the textbook (Alkis C. and Navid M) pp 168 – 172.
Interpolation of equally spaced points
Gregory-Newton interpolation formulas
X F(x)
0 0
2 4
4 56
6 204
8 496
10 980
Gregory-Newton interpolation formulas
Problem:
• Find the interpolating polynomial satisfying the following data using Newton’s
forward interpolation formula
x 0 2 4 6 8 10
F(x) 0 4 56 204 496 980
Solution:
X F(x) (y) ∆𝒚 ∆𝟐 𝒚 ∆𝟑 𝒚 ∆𝟒 𝒚
0 0
4
2 4 48
52 48
4 56 96 0
148 48
6 204 144 0
292 48
8 496 192
484
10 980
Gregory-Newton interpolation formulas
Solution:
• Newton’s forward interpolation formula
• ℎ=2
𝑥−𝑥𝑜 𝑥−0 𝑥
• 𝛼= = =
ℎ 2 2
• Substituting these values into the polynomial
• 𝑓 𝑥 = 𝑥 3 − 2𝑥
Newton’s divided-difference interpolation
• Finite differences
Problem:
• Estimate the natural logarithm of 2 given the following: ln 1=0, ln 4=1.386294
and ln 6=1.791759.
• Take note that the true value of ln 2=0.6931472
Solution:
• Using the nth order polynomial:
Interpolation – Examples
Problem:
• Estimate the ln 2 with a parabola using the following sets of data with a third
Newton’s interpolating polynomial
Variable x Ln x
1 0
4 1.386294
6 1.791759
5 1.609438
Solution:
• The third order polynomial with 𝑛 = 3 is:
Problem:
• Using the following set of data, evaluate the 𝑓 𝑥 = ln 𝑥 𝑎𝑡 𝑥 = 2.