ENGR20005
Numerical Methods in Engineering
Workshop 8 Solutions
8.4 (a) The derivatives using the central difference method and spectral differentiation with 10 points are
1
(b) The convergence of the central difference method is given by
And for spectral differentiation with Gauss–Legendre nodes
2
8.5 (a) The Taylor series expansions of f at xi−2, xi−1, xi+1, and xi+2 are given by
(2∆)2
f(xi+2) = f(xi) + 2∆f′(xi)+ 2 f′′(xi)+
(∆)2
f(xi+1) = f(xi) + ∆f′(xi) + 2 f′′(xi) + 3! f′′′(xi) + 4! f(iv)(xi) + O(∆5)
(∆)2 (∆)3 (∆)4
f(xi−1) = f(xi) − ∆f′(xi) + 2 f′′(xi) − 3! f′′′(xi) + 4! f(iv)(xi) + O(∆5)
(2∆)2 (2∆)3 (2∆)4 f(xi−2) = f(xi) − 2∆f′(xi)+ 2 f′′(xi)− 3! f′′′(xi) + 4!
Substituting into the 4th order central difference formula gives df = f(xi−2)−8f(xi−1)+8f(xi+1)−f(xi+2)
dx i 12∆
1 (2∆)2 (2∆)3 = 12∆[f(xi) − 2∆f′(xi) + 2 f′′(xi) − 3!
f(iv)(xi) + O(∆5)
(2∆)4
4! f(iv)(xi) + O(∆5)]
8 (∆)2
+ 12∆[f(xi) + ∆f′(xi) + 1
2 (2∆)2
− 12∆[f(xi) + 2∆f′(xi) + = f′(xi) + O(∆5)
(2∆)3
2 f′′(xi) + 3! f′′′(xi) +
(2∆)4
4! f(iv)(xi) + O(∆5)]
(∆)2 f(xi+1) = f(xi) + ∆f′(xi)+ 2
(∆)2 f(xi−1) = f(xi) − ∆f′(xi)+ 2
And for f′
f′(xi+1) = f′(xi) + ∆f′′(xi)+ 2
f′′(xi)+ f′′(xi)−
(∆)3 (∆)4
f′(xi−1) = f′(xi) − ∆f′′(xi)+ 2
(∆)2 (∆)2
(∆)3 f′′′(xi)+ 3!
(∆)3 f′′′(xi)− 3!
(∆)4 f(iv)(xi) + 4!
(∆)4 f(iv)(xi) + 4!
f(v)(xi) + O(∆5) f(v)(xi) + O(∆5)
3
(2∆)3 (2∆)4
3! f′′′(xi) + (∆)3
4! f(iv)(xi) + O(∆5) (∆)4
8 (∆)2 − 12∆[f(xi) − ∆f′(xi) + 2
f′′′(xi) + (∆)4
f′′(xi) − f′′(xi) +
(b) The Taylor series expansions of f at xi−1 and xi+1 are given by
f(iv)(xi) + O(∆5)] f(iv)(xi) + O(∆5)]
(∆)3
3! f′′′(xi) + 4!
(∆)3 (∆)4 3! f′′′(xi) + 4!
3! f′′′(xi) + (∆)3
4! f(iv)(xi) + O(∆5) (∆)4
3! f′′′(xi) +
4! f(iv)(xi) + O(∆5)
Thus, the truncation error for the 4th order Pad ́e scheme is given by
df dx i−1
+4df +df −3[f(xi+1)−f(xi−1)] dx i dx i+1 ∆
(∆)2
= f′(xi) − ∆f′′(xi) + 2 f′′′(xi) −
+4f′(xi)
+ f′(xi) + ∆f′′(xi) + 2 f′′′(xi) +
(∆)3 (∆)4
3! f(iv)(xi) + (∆)3 (∆)4
(∆)2
3 (∆)2 (∆)3 (∆)4
3! f(iv)(xi) +
− ∆ f(xi) + ∆f′(xi) + 2 f′′(xi) + 3! f′′′(xi) + 4! f(iv)(xi) + O(∆5)
3 (∆)2 (∆)3 (∆)4 + ∆ f(xi) − ∆f′(xi) + 2 f′′(xi) − 3! f′′′(xi) + 4! f(iv)(xi) + O(∆5)
6′ 6 ∆3 ∆4
= 6f′(xi) − ∆ (xi) + ∆2f′′′(xi) − ∆ 6 f′′′(xi) + 12 f(v)(xi) + O(∆4)
= O(∆4)
4
4! f(v)(xi) + O(∆5) 4! f(v)(xi) + O(∆5)
(c) For the 6th order Pad ́e scheme
df dx i−1
+3df +df dx i dx i+1
= f′(xi) − ∆f′′(xi) + (∆)6
(∆)2
+ f′(xi) + ∆f′′(xi) + 2 f′′′(xi) +
+ 6! f(vii)(xi) + O(∆7) +3f′(xi)
+ + + − + + + +
(∆)6
6! f(vii)(xi) + O(∆7)
(2∆)5 5!
28 12∆
(2∆)6 f(xi) + ∆f′(xi) +
f(v)(xi) +
(∆)6
6! f(vi)(xi) + O(∆7)
28
12∆ f(xi) − ∆f′(xi) +
(∆)6 6! f(vi)(xi) + O(∆7)
1
12∆ f(xi) − 2∆f′(xi) +
−f(xi+2)+28f(xi+1)−28f(xi−1)−f(xi−2) 12∆
(∆)2 2
f′′′(xi) −
(∆)3 3!
(∆)3 3!
(∆)4 (∆)5
(2∆)2
6! f(vi)(xi) + O(∆7)]
(2∆)3
(2∆)4 f′′′(xi) + 4!
1
12∆ f(xi) + 2∆f′(xi) + 2 f′′(xi) + 3!
(2∆)5 (2∆)6
5! f(v)(xi) + 6! f(vi)(xi) + O(∆7)
−
= O(∆6)
5
(∆)2
2 f′′(xi) +
(∆)2
2 f′′(xi) −
(∆)3
3! f′′′(xi) +
(∆)3
3! f′′′(xi) + 4!
(2∆)2 2
(2∆)3
f′′(xi) − 3! f′′′(xi) +
f(iv)(xi) − (2∆)4
f(iv)(xi) +
f(iv)(xi) +
4!
(∆)4 4!
f(v)(xi) +
5! f(vi)(xi) (∆)5
f(v)(xi) −
(∆)4
4! f(iv)(xi) +
(∆)5
5! f(v)(xi)
(∆)5
5! f(v)(xi)
(∆)4
5! f(vi)(xi) f(iv)(xi)
4! f(iv)(xi)
8.6 (a) (b)
The product rule doesn’t hold for finite difference operators.
d(fg) = dx i
= + + = + = + =
f(xi+1)g(xi+1) − g(xi−1)g(xi−1) 2∆
1 [f(xi+1)g(xi+1)−f(xi+1)g(xi+1) 2∆
12f(xi+1)g(xi−1) − 12f(xi+1)g(xi−1) 21f(xi−1)g(xi+1) − 12f(xi−1)g(xi+1)]
f(xi+1)g(xi+1) − f(xi−1)g(xi−1) + f(xi+1)g(xi+1) − f(xi−1)g(xi−1) 4∆ 4∆ 4∆ 4∆
f(xi+1)g(xi−1) − f(xi−1)g(xi+1) + f(xi−1)g(xi+1) − f(xi+1)g(xi−1) 4∆ 4∆ 4∆ 4∆
1g(xi+1)f(xi+1) − f(xi−1) + 1g(xi−1)f(xi+1) − f(xi−1) 2 2∆ 2 2∆
1f(xi+1)g(xi+1) − f(gi−1) + 1f(xi−1)g(xi+1) − g(xi−1) 2 2∆ 2 2∆
1[g(xi+1) + g(xi−1)]f(xi+1) − f(xi−1) + 1[f(xi+1) + f(xi−1)]g(xi+1) − g(xi−1) 2 2∆2 2∆
8.7 (a)
(b) Consider the mapping
x(ξ) = (1 − ξ) + 5(1 + ξ) Then the derivative is given by
See Q8 7 sol.m
(c) Write
Then by the chain rule
dx = 4 dξ
g(x(ξ)) = (6 − 4ξ)7 dg = dg dξ
dx dξ dx
= 14[D]{g(ξ)}
See Q8 7 sol.m for the solution.
6