You are on page 1of 3

Homework 1

Due: October 2, 2023

˝ Class : COMPUTATIONAL METHODS FOR ENGINEERS


˝ Lecturer : Tran Quoc Viet
˝ Email : viet204@gmail.com

Fall 2023
COMPUTATIONAL METHODS FOR ENGINEERS Homework 1

Problem 1: (40%)
As depicted in the following figure, the velocity of water, v pm{sq, discharged from a cylin-
drical tank through a long pipe can be computed as
ˆ ?
av “ 2gHbtanh t 2L
˙
a 2gH

H
L

where g “ 9.81m{s2 , H “ initial head (m), L “ pipe length (m), and t “ elapsed time (s).
Determine the head needed to achieve v “ 5m{s in 2.5s for a 4-m-long pipe
(a) graphically,
(b) by the bisection method,
(c) by the false-position method,
(d) by the fixed-point iteration method, and
(e) by the Newton-Raphson method,
with a stopping criterion of es “ 1%. (Problem 5.15, Textbook)

Problem 2: (30%) Solve Problems 8.9 and 8.10, Textbook.

Problem 3: (10%) Solve Problem 8.22, Textbook.

Problem 4: (20%) You are asked to calculate the matrix eA numerically using the definition
8
ÿ 1 k 1 1 1
eA “ A “ In ` A ` A2 ` A3 ` . . . , (1)
k“0
k! 1! 2! 3!

where A is a given n ˆ n square matrix, n P N, In is the identity matrix. Here Ak`1 “ Ak @A


for k “ 1, 2, . . ., and @ stands for the matrix multiplication operator.

(a) Design a subroutine to perform the sum (1) for a given A with a relative error ϵs .
(Hint: You might want to check your subroutine with scipy.linalg.expm)

Due: October 2, 2023 1


COMPUTATIONAL METHODS FOR ENGINEERS Homework 1

(b) Your subroutine may be useful to simulate the solution of the following system:
x1 ptq “ a1 xptq ` a2 yptq,
y 1 ptq “ b1 xptq ` b2 yptq, t ě 0,
xp0q “ x0 , yp0q “ y0 . (2)
Put „ ȷ „ ȷ „ ȷ
xptq x0 a1 a2
Xptq “ , X0 “ , A“ .
yptq y0 b1 b2
Then we write (2) as follows
X 1 ptq “ A@Xptq, Xp0q “ X0 ,
which can be solved analytically in the following steps:
X 1 ptq “ A@Xptq, e´tA @X 1 ptq “ e´tA @A@Xptq,
d “ ´sA ‰
e´tA @X 1 ptq ´ e´tA @A@Xptq “ 0, e @Xpsq “ 0, @s ě 0,
żt ds
d “ ´sA ‰
e @Xpsq ds “ 0, e´tA @Xptq ´ e´0A @Xp0q “ 0,
0 ds
e´tA @Xptq ´ In @Xp0q “ 0, e´tA @Xptq “ In @Xp0q,
e´tA @Xptq “ Xp0q,
etA @e´tA @Xptq “ etA @Xp0q, In @Xptq “ etA @Xp0q,
Xptq “ etA @Xp0q.
Thus, substituting Xp0q “ X0 into the latter equation gives
Xptq “ etA @X0 . (3)
For every θ “ π{2, π{3, π{4, π{10, assign
a1 “ cospθq, a2 “ ´ sinpθq, b1 “ sinpθq, b2 “ cospθq,
use your subroutine in (a) with ϵs “ 10´8 to simulate (3), for t P r0, 10s, with the
following six initial positions
X0 P tp1, 1q, p1, 0q, p´1, 0q, p0, 1q, p0, ´1q, p´1, ´1qu
in the same figure.
Hint: For θ “ π{7, your simulation should be like this

(x(t), y(t)) for t [0, 10]


10000

5000

0
y(t)

5000

10000
7500 5000 2500 0 2500 5000 7500
x(t)

Due: October 2, 2023 2

You might also like