Solutions To Exercise Set 1, TMA4220: September 2, 2015
Solutions To Exercise Set 1, TMA4220: September 2, 2015
September 2, 2015
1 1
|x| α 2 dx = |x| 2α dx
−1 −1
1
=2 x 2α dx = (∗)
0
We now see that we have to distinguish two cases: α > 0 and α < 0.
If α > 0, the last integral is finite and (∗) = 2α+1 2
.
If α < 0 we see that the integrand is singular at the origin, therefore we must write the integral as
a limit:
1 1
(∗) = 2 x −2 |α | dx = lim 2 x −2 |α | dx
0 s→0 s
2 f g1
= lim x −2 |α |+1
s→0 −2 |α| + 1 s
2 2
= − lim s−2|α |+1 .
−2 |α| + 1 s→0 −2 |α| + 1
The second term is bounded only if −2 |α| + 1 > 0 (why not > ?) which implies − 12 < α < 0.
Combining the two results above, we obtain that |x| α ∈ L 2 ([−1, 1]) ∀ α > − 21 .
• L 2 ([1, ∞)): Done in a similar way as above. One finds |x| α ∈ L 2 ([1, ∞)) ∀ α < − 12 .
• B1 (0): Also done in a similar way. Make sure to switch to polar coordinates; then you will see
that the only integral that needs special care is the one in dr. One finds |x| α ∈ L 2 (B1 (0)) ∀ α > −1.
(b) If D ⊂ R is a closed, bounded subset of R and f ∈ C(D), show that f ∈ L 2 (D).
Solution: D is a bounded subset of R2 , therefore it has finite area: area(D) = M < ∞. f is continuous
on a compact (being compact and being closed and bounded are equivalent in Rn , by the Heine-Borel
Theorem), therefore by the Extreme Value Theorem, it attains absolute maximum and minimum in D.
Such maximum and minimum are finite (why?), so say K = max x ∈D f (x). Then
|| f || L 2 (D) = | f (x)| 2 dx 6 K 2 dx = K 2 M < ∞
D D
.
(c) Let Ω ⊂ Rd be an open, bounded set and let u ∈ C(Ω), the space of continuous functions on Ω. Show
that if Ω uvdx = 0 for all v ∈ C(Ω) then u ≡ 0 on Ω.
Solution: Do it by contradiction: Assume there exist a point x̄ ∈ Ω such that u( x̄) > 0. Then, by
the Theorem of Sign Permanence, ∃Ux̄ ⊂ Ω neighbourhood of x̄ with volume(Ux̄ ) > 0 and such that
u(x) > 0 ∀x ∈ Ux̄ . Now, choosing v(x) = 1, the constant unit function in Ω, we reach a contradiction
since Ω uvdx , 0.
1
(d) Let Ω ⊂ R be some open interval. A weak derivative of a function u : Ω → R is a function v : Ω → R
such that
u(x)ϕ 0 (x) dx = − v(x)ϕ(x) dx
Ω Ω
for every ϕ ∈ Cc∞ (Ω), the set of infinitely differentiable functions with compact support in Ω. Show that
the weak derivative (if it exists) is unique. Show that if u is continuously differentiable (i.e. u ∈ C 1 (Ω)),
then du
dx is its weak derivative.
Solution: For the uniqueness part we apply the standard strategy in those cases: Assume two different
functions v1, v2 are both weak derivatives of u, then apply the above formula and the results from point
c) to obtain that they must be equal. For the second part, since u ∈ C 1 (Ω) we can apply integration by
parts and find the desired result.
(e) Let
x if 0 < x < 1
x if 0 < x < 1
f 1 (x) := 1 if 1 6 x < 2, f 2 (x) := 2 if 1 6 x < 2
for x ∈ Ω := (0, 2). Show that f 1, f 2 ∈ L (Ω). Show that f 1 ∈ H 1 (Ω) by finding its weak derivative,
2
1
if 0 < x < 1
v1 (x) =
0
if 1 6 x < 2
You can use the same procedure on f 2 , and you will discover that it has no weak derivative, hence it
cannot be in H 1 . Proving that all the functions in this part belong to the corresponding function spaces
is done as in the rest of the exercise.
2. Classical and weak solutions.
Consider the equation
−u + u = f
00 in Ω := (0, 1)
du (0) = du (1) = 0 (1)
dx dx
2
for some f ∈ L (Ω). We consider the following weak formulation of (1):
where V = H 1 (Ω). Show that if u is a weak solution of (1) (i.e., it satisfies (2)) and in addition u ∈ C 2 (Ω),
then u is a classical solution of (1) (i.e., it satisfies (1) pointwise). Note carefully that the Neumann boundary
condition does not appear explicitly in the weak formulation (2) – it is a natural boundary condition.
Solution: In the lecture you have seen how to go from the classical (strong) formulation (1), to the weak
formulation (2). Each step in that process is reversible (i.e. it is possible to follow the implications in one
2
direction or the opposite), except when we apply the integration by parts. If we want to reverse that point,
we need to make sure that u has sufficient regularity in order to have a well-defined second order derivative.
Therefore, if u ∈ C 2 (Ω) all the implications can be read in one sense or the other, showing that a classical
solution is also a weak solution, and vice-versa.
3. Finite difference and finite element methods for Poisson’s equation.
Consider the one-dimensional Poisson equation
−u = f
00 in (0, 1)
u(0) = u(1) = 0 (3)
for some f ∈ L 2 ((0, 1)). Write down a finite difference method for (3) on a uniform mesh, and compare with
a P1 finite element method. What are the differences and similarities?
Solution: You have seen in the lecture that they are equivalent: the P1 Finite Element scheme produces the
same system matrix as a Finite Difference scheme with central differences. To write down the method, choose
a uniform mesh in (0, 1) (you might choose actual coordinates if it’s easier for you, or just say that you use a
mesh 0 < x 1 < x 2 · · · < x N < 1 with x i − x i−1 = h = constant ). Then, you know how many basis functions
ϕi you have, and also how they are defined (you have seen this in the lectures). Start from the strong form
(3) and derive the weak form, i.e. multiply with the test functions, integrate, etc. Note that, since you are
searching for uh ∈ X h1 , this means that you can write
N
X
uh (x) = u j ϕ j (x),
j=1
where now the ui ’s are coefficients in R. This is a crucial step in the construction of the method. Then you
can rearrange the integrals and the sum, and obtain a linear system of equations in the form
Au = f, u = [u1, u2, . . . , u N ]T ,
and you can compare the system matrix A obtained in the FEM setting with the one obtained with a central
differences scheme. See pages 61, 62, 71-73 in Quarteroni.
4. Optimal rate of convergence for Poisson’s equation. (Taken from C. Johnson, exercise 1.19.)
Consider the model problem (3). We discretize the domain Ω = (0, 1) into nodes 0 < x 1 < x 2 · · · < x N < 1
with size h = maxi=1, ..., N +1 (x i − x i−1 ) (here, we set x 0 = 0, x N +1 = 1). For each i = 1, . . . , N, let
G i ∈ H01 (Ω) be the solution of the weak formulation
G i0 v 0 dx = v(x i ) ∀ v ∈ H01 (Ω) (4)
Ω
(note that the right-hand side point x i is fixed). It may be shown that G i is given by
(1 − x i )x
for 0 6 x 6 x i
G i (x) =
x i (1 − x)
for x i < x 6 1.
(G i is called the Green’s function for (3) and satisfies (formally) −G i00 = δ x i , where δ x i is the Dirac delta
function at x i .)
(a) Consider a finite element approximation of (3) with the test space Vh = X h1 . Show that in fact G i ∈ X h1 .
( )
Solution: The space X h1 is defined as X h1 = span ϕ j | ϕ j ∈ P1 ((x i−1, x i )) ∀i = 1, . . . , N . Therefore, to
show that G i ∈ X h1 , you have to show that G i can be written as a linear combinations of the functions
ϕ j , of which you know the explicit expression.
(b) Let u ∈ H01 be the weak solution of (3), and let uh ∈ X h1 be the finite element approximation of (3).
Then also e := u − uh lies in H01 (Ω), so we can let v = e in (4). Show that in fact
e(x i ) = (e 0, G i0 ) = 0 ∀ i = 1, . . . , N .
3
This remarkable fact – a special property of (3) – means that the finite element approximation is actually
exact at the points x 1, x 2, . . . , x N .
Solution:
(e 0, G i0 ) = ((u − uh ) 0, G i0 ) = (u 0 − uh0 , G i0 ) (5)
= (u , G i0 )
0
− (uh0 , G i0 ). (6)
Now remember that by point a), G i ∈ X h1 , and moreover both u and uh are solutions of a variational
formulation, with X h1 ⊂ V = H 1 .
(c) Show that, as a consequence of the accuracy of linear interpolation, we have
ku − uh k L 2 (Ω) 6 Ch2 ku 00 k L 2 (Ω)
for some C > 0. Note that this O(h2 ) accuracy is better than the O(h) result coming from Cea’s lemma.
Solution: Read and follow the proof of theorem 4.2 in Quarteroni. The point here is that in 1D, the
finite element solution uh is the interpolant. You will see this proof in detail in class.
5. Programming exercise.
over the reference element K̂ := [0, 1] using n Gauss quadrature points; see Table 1. The parameter n
is an integer equal to 1, 2, 3 or 4, and f is a Matlab function handle (consult the Matlab user manual).
Test your code for different choices of f . Recall that Gauss quadrature is exact when f is a polynomial
of degree 2n − 1 or less.
n xq wq
1
1 2 1
q
2 1
± 12 + 1
2
1
2
1 8
3 2 18
q
± 203
+ 21 5
18
r q √
5 +
3 1 6 1 18+ 30
± 28 − 14 2 72
4 r q √
3
± 28 + 14
1
5 +
6 1
2
18− 30
72
(b) We partition the domain Ω = (0, 1) into N + 1 intervals K j = (x j−1, x j ) with notes 0 < x 1 < x 2 <
· · · < x N < 1. Consider the finite element space X h1 on this mesh with basis ϕ1, . . . , ϕ N consisting of
“witch hat” functions. Write a Matlab function
function [A,b] = stiffness(x, f)
that assembles the stiffness matrix A and the load vector b,
Ai, j = ϕi (x)ϕ j (x) dx,
0 0
bi = f (x)ϕi (x) dx.
Ω Ω
4
(c) Collect the above pieces into a Matlab function
function poisson1d(x, f)
which approximates (3) on the given mesh with the given f , and plots the resulting solution. You can
test your code with the following data:
i. f 1 (x) = 2
ii. f 2 (x) = 6 x − 2
iii. f 3 (x) = −9π 2 sin(3π x)
For the above functions f it’s easy to calculate the exact analytical solution of problem (3). You
can use this to check if your code is working. You can use a uniform mesh in (0, 1], for instance,
x = linspace(0, 1, N+2) where N is the number of nodes x 1, x 2, . . . , x N ∈ (0, 1) you want to use.
Try starting with few points (2, 3, . . . ) and see how the solution improves adding more points (20, 50,
100, . . . ).
Solution: The exact solutions of problem (3) are the following (plots are done on a 100-points grid in
[0, 1]):