Professional Documents
Culture Documents
Sce5401 Ay21-22-S2 Tutr7-Sol (R0)
Sce5401 Ay21-22-S2 Tutr7-Sol (R0)
Tutorial 7 – Solutions
Question 1
Solve the boundary value problem in Illustrative Example 1 of Topic 3 Part 1 again using Galerkin’s
method with boundary conditions given below. The trial function is to have one basis function. The
ODE is
𝑑! 𝑢
− = 𝑢 − 𝑥 ! ; 𝑥 ∈ (0, 1)
𝑑𝑥 !
and the boundary conditions are
u(0) = 0
u(1) = 1
Compare the solution against the exact solution, which is
2(1 − cos 1)
𝑢(𝑥) = 2 cos 𝑥 + sin 𝑥 + 𝑥 ! − 2
sin 1
Solution
Therefore,
#
𝑑! 𝑢
9 𝑤" 7 ! + 𝑢 − 𝑥 ! 8 = 0
$ 𝑑𝑥
which is the weak form of the differential equation.
Revision : Rev0
Prepared by : Dr. Cliff Leung Page 1 of 7
SCE5401 Computational and Engineering Analysis
Tutorial 7 – Solutions
Step 3 – Apply trial function to the weak form and solve for the coefficients of the trial function
Let 𝑢 = 𝑢:. Therefore, the weak form becomes
#
𝑑! 𝑢:
9 𝑤" 7 ! + 𝑢: − 𝑥 ! 8 = 0
$ 𝑑𝑥
Expand the weak form as follows.
# # #
𝑑! 𝑢:
9 𝑤" ! + 9 𝑤" 𝑢: − 9 𝑤" 𝑥 ! = 0
$ 𝑑𝑥 $ $
Apply integration-by-parts to the first term on the left hand side, we have
𝑑𝑢: # #
𝑑𝑤" 𝑑𝑢: # #
@𝑤" AB − 9 𝑑𝑥 + 9 𝑤" 𝑢: 𝑑𝑥 − 9 𝑤" 𝑥 ! 𝑑𝑥 = 0
𝑑𝑥 $ $ 𝑑𝑥 𝑑𝑥 $ $
In this case, we have one weighting function since there is only one basis function in the trial
function. The weighting function is to be the same as the basis function, therefore
𝑤# = 𝜙# = 𝑥(𝑥 − 1)
Revision : Rev0
Prepared by : Dr. Cliff Leung Page 2 of 7
SCE5401 Computational and Engineering Analysis
Tutorial 7 – Solutions
# # #
𝑑𝑢:(1) 𝑑𝑢:(0) 𝑑𝑤# 𝑑𝑢:
C𝑤# (1) − 𝑤# (0) D−9 𝑑𝑥 + 9 𝑤# 𝑢: 𝑑𝑥 − 9 𝑤# 𝑥 ! 𝑑𝑥 = 0
𝑑𝑥 𝑑𝑥 $ 𝑑𝑥 𝑑𝑥 $ $
# # #
𝑑𝑢: (1) 𝑑𝑢:(0) 𝑑𝑤# 𝑑𝑢:
C(0) − (0) D−9 𝑑𝑥 + 9 𝑤# 𝑢: 𝑑𝑥 − 9 𝑤# 𝑥 ! 𝑑𝑥 = 0
𝑑𝑥 𝑑𝑥 $ 𝑑𝑥 𝑑𝑥 $ $
# # #
𝑑𝑤# 𝑑𝑢:
−9 𝑑𝑥 + 9 𝑤# 𝑢 − 9 𝑤# 𝑥 ! = 0
$ 𝑑𝑥 𝑑𝑥 $ $
# #
− 9 (2𝑥 − 1)(2𝑢# 𝑥 − 𝑢# + 1) 𝑑𝑥 + 9 𝑥(𝑥 − 1)(𝑢# 𝑥(𝑥 − 1) + 𝑥) 𝑑𝑥
$ $
#
− 9 𝑥(𝑥 − 1)𝑥 ! 𝑑𝑥 = 0
$
# #
4 1 2 1 1 1
− @ 𝑢# 𝑥 ' − 2𝑢# 𝑥 ! + 𝑥 ! + 𝑢# 𝑥 − 𝑥AB + @ 𝑢# 𝑥 ( − 𝑢# 𝑥 ) + 𝑥 ) + 𝑢# 𝑥 ' − 𝑥 ' AB
3 $ 5 4 4 3 3 $
#
1 1
− @ 𝑥 ( − 𝑥 ) AB = 0
5 4 $
3 1
− 𝑢# − =0
10 30
1
𝑢# = −
9
Therefore, by Galerkin’s method, the approximate solution, which is the trial function, is
𝟏
𝒖
J = − 𝒙(𝒙 − 𝟏) + 𝒙
𝟗
(ANS.)
The exact function and trial function are plotted below for comparison. The two functions are very
close.
1.5
1
u
0.5
0
0 0.2 0.4 0.6 0.8 1
x
Revision : Rev0
Prepared by : Dr. Cliff Leung Page 3 of 7
SCE5401 Computational and Engineering Analysis
Tutorial 7 – Solutions
Question 2
Determine an admissible trial function for a boundary value problem with the following boundary
conditions.
(a) u(1) = 1; u(2) = 3; trial function is to be formed by 2 basis functions
(b) u(3) = 1; u(5) = 3; trial function is to be formed by 1 basis functions
(c) u′(1) = 1; u(2) = 3; trial function is to be formed by 1 basis functions
(d) u′(1) = 1; u(2) = 3; trial function is to be formed by 2 basis functions
Since we are using 2 basis functions in this case, the trial function has the form
𝑢: = 𝑢# 𝜙# + 𝑢! 𝜙! + 𝜙$
Step 1 – Determine the basis functions 𝜙# and 𝜙!
We know that 𝜙# and 𝜙! must be 0 at where E.B.C. are imposed.
E.B.C. are imposed at x = 1 and x = 2, therefore
𝜙# can be 𝜙# = (𝑥 − 1)(𝑥 − 2)
𝜙! can be 𝜙! = (𝑥 − 1)! (𝑥 − 2)!
Check:
𝜙# (1) = (1 − 1)(1 − 2) = 0 ∴ OK
𝜙# (2) = (2 − 1)(2 − 2) = 0 ∴ OK
𝜙! (1) = (1 − 1)! (1 − 2)! = 0 ∴ OK
𝜙! (2) = (2 − 1)! (2 − 2)! = 0 ∴ OK
Step 2 – Determine the function 𝜙$
𝜙$ can be a constant or a function that makes the trial function satisfies the E.B.C.
The E.B.C. are u(1) = 1 and u(2) = 3. Therefore, the trial function,
𝑢: = 𝑢# 𝜙# + 𝑢! 𝜙! + 𝜙$
needs to be such that
(i) 𝑢:(1) must give the value 1 and
(ii) 𝑢:(2) must give the value 3
Therefore, 𝜙$ must be a linear function in order to satisfy (i) and (ii), i.e. 𝜙$ is in the form of
𝜙$ = 𝑚𝑥 + 𝑏
We need to solve for m and b to find the function of 𝜙$ .
Apply condition (i),
𝑢:(1) = 1
𝑢: = 𝑢# (𝑥 − 1)(𝑥 − 2) + 𝑢! (𝑥 − 1)! (𝑥 − 2)! + 𝜙$
1 = 𝑢# (1 − 1)(1 − 2) + 𝑢! (1 − 1)! (1 − 2)! + 𝑚(1) + 𝑏
1 = 𝑢# (0) + 𝑢! (0) + 𝑚(1) + 𝑏
1=𝑚+𝑏 (Eq. 1)
Revision : Rev0
Prepared by : Dr. Cliff Leung Page 4 of 7
SCE5401 Computational and Engineering Analysis
Tutorial 7 – Solutions
Since we are using 1 basis function in this case, the trial function has the form
𝑢: = 𝑢# 𝜙# + 𝜙$
Step 1 – Determine the basis functions 𝜙#
We know that 𝜙# must be 0 at where E.B.C. are imposed.
E.B.C. are imposed at x = 3 and x = 5, therefore
𝜙# can be 𝜙# = (𝑥 − 3)(𝑥 − 5)
Check:
𝜙# (3) = (3 − 3)(3 − 5) = 0 ∴ OK
𝜙# (5) = (5 − 3)(5 − 5) = 0 ∴ OK
Revision : Rev0
Prepared by : Dr. Cliff Leung Page 5 of 7
SCE5401 Computational and Engineering Analysis
Tutorial 7 – Solutions
1 = 𝑢# (3 − 3)(3 − 5) + 𝑚(3) + 𝑏
1 = 𝑢# (0) + 𝑢! (0) + 𝑚(3) + 𝑏
1 = 3𝑚 + 𝑏 (Eq. 1)
Apply condition (ii),
𝑢:(5) = 3
𝑢: = 𝑢# (𝑥 − 3)(𝑥 − 5) + 𝜙$
3 = 𝑢# (5 − 3)(5 − 5) + 𝑚(5) + 𝑏
3 = 5𝑚 + 𝑏 (Eq. 2)
Solving Eq. 1 and 2 we have
m = 1 and b = -2
Therefore, 𝜙$ is
𝜙$ = 𝑥 − 2
Since we are using 1 basis function in this case, the trial function has the form
𝑢: = 𝑢# 𝜙# + 𝜙$
Step 1 – Determine the basis functions 𝜙#
We know that 𝜙# must be 0 at where E.B.C. are imposed.
E.B.C. are imposed at x = 2, therefore
𝜙# can be 𝜙# = 𝑥 − 2
Check:
𝜙# (2) = 2 − 2 = 0 ∴ OK
Revision : Rev0
Prepared by : Dr. Cliff Leung Page 6 of 7
SCE5401 Computational and Engineering Analysis
Tutorial 7 – Solutions
Since we are using 2 basis functions in this case, the trial function has the form
𝑢: = 𝑢# 𝜙# + 𝑢! 𝜙! + 𝜙$
Step 1 – Determine the basis functions 𝜙# and 𝜙!
We know that 𝜙# and 𝜙! must be 0 at where E.B.C. are imposed.
E.B.C. are imposed at x = 2, therefore
𝜙# can be 𝜙# = 𝑥 − 2
𝜙! can be 𝜙! = (𝑥 − 2)!
Check:
𝜙# (2) = 2 − 2 = 0 ∴ OK
𝜙! (2) = (2 − 2)! = 0 ∴ OK
Revision : Rev0
Prepared by : Dr. Cliff Leung Page 7 of 7