Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Applied Numerical Methods (CH3131)

January 29, 2014, 14:00-17:00

• You can choose to do only part 1, or only part 2, or both parts.

• If you do part 1 or part 2 only, the allowed time for the exam is 1.5 hours (14:00-15:30).

• If you do both parts, the allowed time for the exam is 3 hours (14:00-17:00).

• If you do both parts, make part 1 and part 2 on separate sheets.

• On every sheet, clearly state: number of the exercise, your name, your student number.

Part 2 consists of 4 questions, which are each of approximately equal weight.

Part 2 - Question 1

2
f(t) −−>

0
0 2 4 6 8
t −−>

Using Dirichlet’s theorem, the periodic function f (t) sketched above is approximated by a
function
∞     
1 X mπt mπt
fˆ(t) = a0 + am cos + bm sin (1)
2 m=1
P P

(a) Determine the value of the coefficient a0 .


The appropriate formula is
Z 2P
1
a0 = f (t) dt (2)
P 0

This is not sufficient by itself, the actual value is asked for. This requires the correct
value for P (period 2P = 4) and the formula for f (t). Alternatively, from the figure we
may read that the integral gives 4, such that a0 = 2.

1
(b) Determine the value of the coefficient b1 .

1 2P
Z  
πt
b1 = f (t) sin dt (3)
P 0 P

Insert P = 2 and note that the integral can be restricted to [0, 2] where f (t) = 2:
Z 2     2
1 πt 1 4 πt
b1 = 2 sin dt = − cos (4)
2 0 2 2 π 2 0
2 4
= − (cos(π) − cos(0)) = (5)
π π

(c) Which statement is not true? Motivate your answer.


R∞
1. The Fourier transform F (ω) = √12π −∞ f (t) exp(−iωt) dt contains all information
about function f (t).
R∞
2. The Fourier transform F (ω) = √12π −∞ f (t) exp(−iωt) dt of a real signal f (t) is
complex-valued.
3. When two functions f and g have Fourier transforms F (ω) and G(ω), respectively,
then the correlation of f and g is equal to G(ω)F (−ω).
At first sight, all three statements look correct. (1) since f (t) can be recovered exactly
using the inverse Fourier transform, all information on f (t) must be there. (2) all Fourier
transforms are complex-valued, moreover, for F (ω) to be real-valued f (t) must be an
even function, which is not assumed in the statement. (3) this formula appears in the
book. The caveat is that G(ω)F (−ω) is not the correlation Cg,f (t) itself, but its Fourier
transform C̃g,f (ω). Points are awarded for each correct observation.

Part 2 - Question 2
The pdf of a continuous stochastic variable X is given by:


 p(x) = 0 for x ≤ 0
p(x) = ax for 0 < x ≤ 1

(6)

 p(x) = a(3 − x)/2 for 1 < x ≤ 3
p(x) = 0 for x > 3

(a) What is the value of a?


Z ∞ 1 3
a(3 − x)
Z Z
2
1= p(x) dx = ax dx + dx → a = (7)
−∞ 0 1 2 3

Fractions should be written as such, points may be deduced if an approximate value


(0.67) is reported, particularly if this is used in further calculations.

2
(b) What is the probability to find a value of X with 0.5 ≤ X ≤ 1?
Z 1 Z 1  1
2 1 2 1 1 1
P (0.5 ≤ X ≤ 1) = p(x) dx = x dx = x = − = (8)
0.5 0.5 3 3 0.5 3 12 4

(c) What is the expected value E(X) of X?


Z ∞ Z 3
Z 1
2 2 1
E(X) = x p(x) dx = x dx + x(3 − x) dx (9)
−∞ 0 3 1 3
 3 1  2 3
1 x3
   
2x 3x 2 9 27 1 1 4
+ − = −0+ − − − = (10)
3 3 0 3 2 3 3 1 9 2 9 2 9 3

Part 2 - Question 3
We are seeking the minimum for the minimum of the function

φ(x) = x21 − 4x1 x2 + 6x22 − 2x1 + 2x2 + 4 (11)

(a) Determine the gradient γ = ∇φ of φ in the point x = (1, 1).


 
2x1 − 4x2 − 2
∇φ(x) = (12)
−4x1 + 12x2 + 2
   
2−4−2 −4
⇒ ∇φ(1, 1) = = (13)
−4 + 12 + 2 10

(b) Analytically, find the coordinates of the minimum xmin .


     
2x1 − 4x2 −2 0
∇φ(x) = 0 ⇒ + = (14)
−4x1 + 12x2 2 0
     
2 −4 x1 2
⇒ · = (15)
−4 12 x2 −2
 
1 2
⇒ (12 − 8)x2 = −2 + 4, x2 = , x1 = 2, xmin = (16)
2 0.5

(c) We are trying to find the minimum through numerical iteration. At iteration k, our
guessed minimum is xk = (1, 1). We proceed to iteration k + 1 by taking a step of
length a = 0.1 in the direction of the steepest descent. Compute xk+1 and show that
φ(xk+1 ) < φ(xk ) and that |γ(xk+1 )| < |γ(xk )|.

3
• Steepest descent direction: p = −γ(xk ) = [4, −10]T .
• Step length 0.1 gives xk+1 = [1.4, 0]T .
• Function values φ(xk ) = 7, φ(xk+1 ) = 3.16, decreasing.
• Gradient at new point γ k+1 = [0.8, −3.6]T .
√ √
• Size of gradient |γ k | = 116, |γ k+1 | = 13.6, decreasing.

Part 2 - Question 4
We wish to compute the heating up of water in a channel, schematized as two-dimensional
flow between two flat plates.
y=H
u(y)
y=0

y=−H
x=0 x=L

This is described by the two-dimensional steady state convection-conduction equation:


 2
∂ 2T

∂ ∂ T
u(y) (ρcp T ) = λ + . (17)
∂x ∂x2 ∂y 2

The boundary conditions are

BC1: T (0, y) = T0 , −H ≤ y ≤ H, BC3: T (x, −H) = T1 , 0 ≤ x ≤ L, (18)


BC2: T (L, y) = T1 , −H ≤ y ≤ H, BC4: T (x, H) = T1 , 0 ≤ x ≤ L. (19)

We do a finite difference discretization on a uniform mesh with ∆x = L/100 and ∆y = H/5.

(a) You don’t have sufficient information for deciding whether upwind or central differences
are appropriate. Describe which information you need and how you would proceed to
make a choice.
We must know the mesh-Peclet number. For this we need the mesh size ∆x (i.e. L)
and the strength of advection u(y) compared to the strength of diffusion λ/ρcp . We
prefer central differences, but these can be used only if the mesh-Peclet number is low
throughout the domain. Else we must revert to upwind differences.

(b) Formulate the finite difference analogon of equation (16) using upwind differences.

4
Define xm = m · ∆x, m = 0, . . . , 100, and yn = n · ∆y, n = −5, . . . , 5; denote Tm,n ≡
T (xm , yn ) and un ≡ u(yn ).

Tm,n − Tm−1,n
un =
∆x  
λ Tm+1,n − 2Tm,n + Tm−1,n Tm,n+1 − 2Tm,n + Tm,n−1
+ (20)
ρcp ∆x2 ∆y 2
   
un λ un λ λ
− − Tm−1,n + +2 +2 Tm,n
∆x ρcp ∆x2 ∆x ρcp ∆x2 ρcp ∆y 2
λ λ λ
− 2
Tm+1,n − 2
Tm,n−1 − Tm,n+1 = 0 (21)
ρcp ∆x ρcp ∆y ρcp ∆y 2

(c) How many unknowns are there in the problem?


There is one unknown Tm,n per grid point. The unknowns of the boundary points
can and should be eliminated from the problem, by inserting them into the discretized
equation. There are 99 × 9 interior grid points, i.e. 891 unknowns.

(d) Finite difference discretization leads to a linear system of equations Ax = b. What is a


good solution method for solving this system in Matlab? Motivate your answer.
Since the system is small, direct solution using the backslash operator should be used.
If the grid is refined then an iterative solution method may be advantageous. In that
case CG cannot be used because A is not symmetric. GMRES with ILU preconditioning
would be the natural choice.

You might also like