Introduction To Finite Difference Method
Introduction To Finite Difference Method
FINITE DIFFERENCE
METHOD
Two Methods in Solving
Differential Equations
■ Analytical
– Only few equations can be solved
– Too hard
■ Numerical
– Can be done to vast majority of differential equations
– Will have some error
Numerical Methods
𝑢 𝑥 + ℎ − 𝑢(𝑥)
𝑢′ 𝑥 ≈
ℎ
Finite Difference
Approximation
′
𝑢 𝑥 + ℎ − 𝑢(𝑥)
𝑢 𝑥 ≈
ℎ
Recall Taylor Series
∞ 𝑛
𝑓 𝑎
𝑓 𝑥 = (𝑥 − 𝑎)𝑛
𝑛!
𝑛=0
∞ 𝑛
𝑢 𝑥
𝑢 𝑥+ℎ = (ℎ)𝑛
𝑛!
𝑛=0
Taylor Series
′
𝑢 𝑥 + ℎ − 𝑢(𝑥)
𝑢 𝑥 ≈
ℎ
′
𝑢 𝑥+ℎ −𝑢 𝑥
𝑢 𝑥 = + 𝑂(ℎ)
ℎ
Example
2 3
ℎ ℎ
𝑢 𝑥 − ℎ = 𝑢 𝑥 − 𝑢′ 𝑥 ℎ + 𝑢′′ 𝑥 − 𝑢′′′ 𝑥 + 𝑂 ℎ4
2 6
𝑢 𝑥 + ℎ + 𝑢 𝑥 − ℎ = 2𝑢 𝑥 + 𝑢′′ 𝑥 ℎ2 + 𝑂 ℎ4
𝑢 𝑥 + ℎ − 2𝑢 𝑥 + 𝑢(𝑥 − ℎ)
𝑢′′ 𝑥 = + 𝑂(ℎ 2)
ℎ2
Example
2
■ Given 𝑢 𝑥 = 𝑒 𝑥 . Approximate u’’(1).
■ Try h = 0.00001?
– Why is the error higher?
Improving u’(x) Approximation
ℎ2
𝑢 𝑥 + ℎ = 𝑢 𝑥 + 𝑢′ 𝑥 ℎ + 𝑢′′ 𝑥 + 𝑂 ℎ3
2
ℎ 2
𝑢 𝑥 − ℎ = 𝑢 𝑥 − 𝑢′ 𝑥 ℎ + 𝑢′′ 𝑥 + 𝑂 ℎ3
2
𝑢 𝑥 + ℎ − 𝑢 𝑥 − ℎ = 2𝑢′ 𝑥 ℎ + 𝑂 ℎ3
𝑢 𝑥 + ℎ − 𝑢(𝑥 − ℎ)
𝑢′ 𝑥 = + 𝑂(ℎ2 )
2ℎ
Example
𝑢′′(𝑥) 2
′
𝑢 𝑥+ℎ =𝑢 𝑥 +𝑢 𝑥 ℎ+ ℎ + 𝑂 ℎ3
2
𝑢′′ 𝑥
𝑢 𝑥 + 2ℎ = 𝑢 𝑥 + 𝑢′ 𝑥 2ℎ + 4ℎ2 + 𝑂 ℎ3
2
Machine Exercise Solution
′
−3𝑢 𝑥 + 4𝑢 𝑥 + ℎ − 𝑢 𝑥 + 2ℎ
𝑢 𝑥 = + 𝑂 ℎ2
2ℎ
Machine Exercise Solution
−2𝑢 𝑥 + ℎ + 𝑢 𝑥 + 2ℎ = −𝑢 𝑥 + 𝑢′′ 𝑥 ℎ2 + 𝑂 ℎ3
′
𝑢 𝑥 − 2𝑢 𝑥 + ℎ + 𝑢 𝑥 + 2ℎ
𝑢 𝑥 = +𝑂 ℎ
ℎ2