Вы находитесь на странице: 1из 9

MAT 3310 (2009-2010, Second Term)

Suggested Solution for Assignment 3

1. (a) Define a partition in the interval [1, 3]


x0 = 1 < x1 < x2 < < xN +1 = 3
with xj = 1 + jh, h =
u(x+h)+2u(x)u(xh)
,
h2

31
N +1

2
N +1 .

By lemma 3.1, we can approximate u (x)

the scheme can be formulated as:

3(uj+1 2uj + uj1 )


+ uj = 1,
h2

i = 1, , N

(1)

Use the boundary condition u(x0 ) = 1, u(xN +1 ) = 0,


3(u2 2u1 + u0 )
+ u1 = 1,
h2
3(uN +1 2uN + uN 1 )
+ uN = 1,
h2

(2)
(3)

i.e.
3
3u2 + 6u1
+ u1 = 1 + 2 ,
2
h
h
6uN 3uN 1
+ uN = 1,
h2
The above equations are collected into the
6
3
0

h2 + 1 h2
6
3
32
h
h2 + 1 h2
A= .
.
..
..
..
.
h32

(4)
(5)

following linear system: A~u = b

0
1 + h32

~b =
,

.
..
3

h2
.
6
+ 1 N N
1
h2

(b) Explanation 1:
Since the diagonal entries of A is ajj = h62 + 1, and the absolute sum of off-diagonal
entries is |aj1,j | + |aj,j+1 | = | h32 | + | h32 | = h62 < |aj,j |, so A is strictly diagonally
dominant matrix, thus it is invertible (The proof is by contradiction argument). Thus
~u = A1~b is uniquely solvable.

Please email to the tutors if there are mistakes: xmdeng@math.cuhk.edu.hk.

Explanation 2:
We prove that A is monotone. Define r =

A=

3
,
h2

then

2r + 1 r
0

r
2r + 1 r
..
..
..
.
.
.
r

0
0
r
2r + 1

N N

A~v 0, let vk = min1jN vj

(2r + 1)v1 rv2 0


rvj1 + (2r + 1)vj rvj+1 0

rvN 1 + (2r + 1)vN 0

Case 1:vk = v1

(6)

(2r + 1)vk rv2 0


(r + 1)vk r(v2 vk ) 0
vk 0
Case 2:vk = vj , 1 < j < N
(2r + 1)vk rvj1 rvj+1 0
vk + r(vk vj1 ) + r(vk vj+1 ) 0
vk r(vj1 vk ) + r(vj+1 vk ) 0
Case 3:vk = vN
(2r + 1)vk rvN 1 0

(7)

(r + 1)vk r(vN 1 vk ) 0

(8)

vk 0

(9)

So ~v 0, and by lemma 3.2 A is monotone, then A is invertible, ~u = A1~b is uniquely


solvable.
(c) % Matlab file
N=99;
h=(3-1)/(N+1);r=3/(h^2);
A=zeros(N,N);sol=ones(N+2,1);sol(N+2)=0;
a=ones(N,1)*(1+2*r);
b=ones(N-1,1)*(-r);
A=diag(a)+diag(b,1)+diag(b,-1);
x=[1:h:3];
2

1
0.9
0.8
0.7

0.6
0.5
0.4
0.3
0.2
0.1
0

1.5

2
x

2.5

Figure 1:
c=ones(N,1);
c(1)=1+r;
sol(2:N+1)=A\c;
plot(x,sol,*);
(d) By Lemma 3.1, [1, 1], s.t.
u (x) =

u(x h) + 2u(x) u(x + h) h2 (4)


+ u (x + h).
h2
12

Let ej = u(xj ) uj , for j = 1, , N , since


(
3u (xj ) + u(xj ) = 1
3uj + uj = 1

(10)

(11)

Substract the latter equation from the previous one,


3(ej+1 2ej + ej1 )
h2 (4)
u (xj + j h) = 0
+
e
+
j
h2
4
i.e.
A~e = f~,

h2 (4)
u (xj + j h), j = 1, , N.
4
k~ek kA1 k kf~k

(12)

fj =

(13)

First we estimate kf~k ,


go back the the differential equation 3u + u = 1, take second derivative on both
sides,
u (x)
u(x) 1
u(4) (x) =
=
.
(14)
3
9
Let C = maxx[1,3] |u(x)|, then
kf~k

h2 (C + 1)
h2 C + 1
=
;
4 9
36
3

(15)

Next we estimate kA1 k ,


in (b) we have proved that A is monotone, then A1 is positive. Let = [1, 1, , 1]T ,
since 1 is the right handside function of the original differential equation, so by
(10),(11),
h2
Au(xj ) + u(4) (xj + j h) = bj , j = 1, , N.
4
~ = (u(x + h), u(x +
~ = (u(x1 ), u(x2 ), , u(xN )), U
substitute (14), and let U
1
1
2
2 h), , u(xN + N h)), then
~ +
AU

h2 ~
(U 1) = ~b
36

Since from the numerical results we know u is a decreasing function, so 0 < u(x) < 1
in the interval [1, 3] (or we can compute the exact solution to get this observation),
kA1 k = kA1~k
kA1~bk


h2 ~
1
~
= kA
AU + (U 1) k
36
2
h
~ 1)k
~ + A1 (U
= kU

36
~ k
kU
C
Combine the above two estimates, we have
k~ek

C(C + 1) 2
h .
36

(16)

2. (a) By integration by part, we can get the V.F.:


Find u(x) with u(1) = 0, and u (2) = 0, s.t.
Z 2
Z 2

u v dx =
cos xvdx
1

(17)

test functions v(x), with v(1) = 0.


(b) Let uh (x) =

N
+1
X

ui i (x) be the approximation of u(x) in finite element space V h =

i=1

Span{1 (x), 2 (x), , N +1 (x)}, where i (x), (i > 1) is the linear finite element
with support in (xi1 , xi+1 ) (See lecture notes pp.76). Suppose v(x) V h , then let
v(x) = i (x), for i = 1, , N + 1, we can get the following linear system:
A~u = ~b,
where
aij =

i j dx

2
h

h1

1i=j <N +1
,
i 6= j, |i j| = 1
4

aN +1,N +1 =

1
h

bj =

cos xj dx =
1

1
h (2 cos xj cos xj1 cos xj+1 )
1
h (h sin xN +1 + cos xN +1 cos xN )

1jN
j =N +1

(c) Explanation 1:
~u 6= 0,

~uT A~u

PN +1

N
+1 N
+1
X
X

ui aij uj
i=1 j=1
R2
~uT A~u = 1 v 2 dx

+1
2 N
X

N
+1
X

ui i (x))(

i=1

uj j (x))dx, let v(x) =


j=1
then v (x) 0, v(x) C, since

uj j (x),
0. If ~uT A~u = 0,
v(x) V h , it is only possible for C = 0. Thus A is positive definite, and invertible,
~u = A1~b.
j=1

Explanation 2:

A=

2
1 0

1 2
1
..
..
..
.
.
.
1

0
0

1
1

it is easy to prove that A is monotone, so A is invertible, the unique solvable argument


follows.
(d) First solve the equation to get the exact solution:
u(x) = cos x + C1 x + C2
C1 = sin 2,

C2 = cos 1 sin 2.

Use Matlab to solve this problem and compare both solutions in the following:
% Matlab file
N=99;
A=zeros(N+1,N+1);
sol=zeros(N+2,1);
c=zeros(N+1,1);
a=ones(N+1,1)*2;
b=-ones(N,1);
A=diag(a)+diag(b,1)+diag(b,-1);
A(N+1,N+1)=1;
x=[1:1/(N+1):2];
for i=1:N
c(i)=2*cos(x(i+1))-cos(x(i+2))-cos(x(i));
end
c(N+1)=sin(x(N+2))*1/(N+1)+cos(x(N+2))-cos(x(N+1));
sol(2:N+2)=A\c;
plot(x,sol,r*);
hold on
u=cos(x)+sin(2)*x-cos(1)-sin(2);
plot(x,u,b-);
figure;
5

(18)
(19)

plot(x(2:N+2),abs((u(2:N+2)-sol(2:N+2))./u(2:N+2)),*);
f=@(x)cos(x)+sin(2)*x-cos(1)-sin(2);
z = fzero(f,[1.1 2])
The exact and numerical solutions are plotted in the following figure 2. The error is
0.01

u(x)

0.01

0.02

0.03

0.04

0.05

1.2

1.4

1.6

1.8

Figure 2:


u u(x )
defined as e(xj ) = ju(xj ) j , graph the error at each mesh point in figure 3.
It is noted that there is one point which has much larger relative error than other
11

x 10

1.2

1.4

1.6

1.8

Figure 3:
points, this is because it is a zero point(or most close to the zero point) of u(x), to
verify this, run the last two lines of our program, and z = 1.2997.
3. (a) Let e(x) = u(x) uI (x), by the definition of uI (x), over the interval [xj1 , xj ],
e(xj1 ) = e(xj ) = 0. Since u(x) C 2 [1, 2], uI (x) is linear and uI (x) 0, e(x)
C 2 [1, 2]. By mean value theorem, zj [xj1 , xj ], s.t. e (zj ) = 0.

Integration by part,

e (x) e (zj ) =
e (x) =

z
Z xj

e (y)dy
u (y)dy

zj

|e (x)| = |

u (y)dy| hmaxxj1 xxj |u (x)|


zj

|u (x) uI (x)| hmaxxj1 xxj |u (x)|


maxxj1 xxj |u (x) uI (x)| hmaxxj1 xxj |u (x)|.
The first inequality is proved.
e(x) C 2 [1, 2], so max e(x) or min e(x) occurs only when e (x) = 0 or at either end
point. e(xj1 ) = e(xj ) = 0 satisfy the inequality, so we only need to consider the
previous case. For any interval [xj1 , xj ], we know that x [xj1 , xj ], s.t. e (x) = 0.
By Taylor expansion,
1
e(xj ) = e(x) + (xj x)e (x) + (xj x)2 e (),
2

[x, xj ]

(20)

Since e(xj ) = 0, e (x) = 0 and e (x) = u (x),


1
e(x) = (xj x)2 e (), [x, xj0 ]
2
1
|e(x)| h2 maxxj1 xxj |u (x)|
2
1 2
maxxj1 xxj |u(x) uI (x)| h maxxj1 xxj |u (x)|.
2
(b) By the definition of uI (x), uI (x) V h , from (a), we know that
ku

uI k2a

|u (x)
1

uI (x)|2 dx

N
+1 Z xj
X
j=1

N
+1 Z
X
j=1
2

xj1
xj

h2 maxxj1 xxj |u (x)|2

xj1

N
+1 Z xj
X
j=1

|u (x) uI (x)|2 dx

maxxj1 xxj |u (x)|2 dx

xj1

h max1x2 |u (x)|2 (2 1)
ku uI ka hmax1x2 |u (x)|.
Let C = max1x2 |u (x)|, ku uI ka Ch.
By theorem 3.3 in lecture notes pp. 80,
ku uh ka = minvV h ku vka ku uI ka Ch
The second equality is proved.
7

(21)

4. (a) Let T be a partition between [1, 5],


1 = t0 < t1 < t2 < < tN +1 = 5
where tm = 1+m , and = N 4+1 . The finite difference scheme can now be formulated
as:
(
um+1 um
2um = sin tm ,

(22)
u0 = 3.
(b) % Matlab file
N=99;
tau=(5-1)/(N+1);t=[1:tau:5];
u=zeros(N+2,1);u(1)=3;
for i=2:N+2
u(i)=(1+2*tau)*u(i-1)+tau*sin(t(i-1));
end
plot(t,u,*);
8000
7000
6000

5000
4000
3000
2000
1000
0

1.5

2.5

3
t

3.5

4.5

Figure 4:
(c) Let f (t, u) = sin t + 2u, then u (t) = f (t, u). Since u C 2 [1, 5], by Taylor expansion,
u(tm+1 ) = u(tm ) + f (tm , u(tm )) +

2
u (),
2

[tm , tm+1 ]

(23)

in (a), we get um+1 = um + f (tm , um ), substract it from (23),


2
u (), [tm , tm+1 ]
2
2
= em + (sin m + 2u(tm ) sin m 2um ) + u ()
2
2

= (1 + 2 )em + u ()
2

em+1 = em + (f (tm , u(tm )) f (tm , um )) +

(24)
(25)
(26)

Let C = max1x5 |u (x)|, by e0 = 0,


2
|u ()|
2
2
(1 + 2 )|em | + C
2
2
(1 + 2 )|e0 |m+1 + C(1 + (1 + 2 ) + (1 + 2 )2 + + (1 + 2 )m )
2
2 (1 + 2 )m+1 1
C

2
2
C
((1 + 2 )m+1 1)

|em+1 | (1 + 2 )|em | +

i.e.
|em |
(d) Since log(1 + 2 ) 2 , and m =

4m
N +1

|em |
=

Let C =

C 8
4 (e

C
((1 + 2 )m 1)
4
4,

C
((1 + 2 )m 1)
4
C m log(1+2 )
(e
1)
4
C m2
(e
1)
4
C 24
(e 1)
4
C 8
(e 1).
4

1), the result is thus proved. 

(27)