Upload
hisuin
View
214
Download
0
Embed Size (px)
Citation preview
7/26/2019 solution10_wise2011
1/5
Technische Universitt Mnchen WiSe 2011/12
Fakultt fr Informatik Solution for Exercise Sheet 10
Dr. Tobias Lasser
Richard Brosig, Jakob Vogel
February 2, 2012
Exercises in Basic Mathematical Tools
Assignment 1 Poisson Distribution
X Poi(), Y Poi()
a) Compute the distribution ofX+ Y=n
P(X+ Y=n) =n
k=0
P(X= k,Y=n k)
=n
k=0
P(X= k) P(Y=n k)
=n
k=0
ek
k!
enk
(n k)!
=e+n
k=0
knk
k!(n k)!
=e+1
n!
n
k=0
n!
k!(n k)!knk
=e+1
n!
n
k=0
n!
k!(n k)!knk
=e+(+)n
n! Poi(+)
The last equation can be obtained with the binomial theorem1
b) Compute the probability of{X= k} on the condition that {X+ Y=n}.
(i) Guess which distribution typeP[{X= k}|{X+ Y=n}]will follow!
The computation of P(X=k|X+ Y=n)can be seen as the sum of Bernoulli experi-ments. We have n Experiments with either X or Y as result. After this experiments the
sum of both is n and we want to get the probability that X= k. So we can assume thatP(X=k|X+ Y=n) B(n,p).
(ii) Compute the parameter of the conditional distributionP[{X= k}|{X+ Y=n}]!
In the previous exercise we already mentioned that this distribution is Binomially dis-
tributed. This is the sum of coin flip experiments. We can see the event X as head and
Y as tail. Since we already have n and k we have to compute the probability p of the
1http://en.wikipedia.org/wiki/Binomial_theorem
7/26/2019 solution10_wise2011
2/5
Solution 10/ page 2
event X.
P(X= k|X+ Y=n) =P(X=k, and X+ Y=n)
P(X+ Y=n)
=P(X=k, and Y=n k)
P(X
+Y
=n
)=
P(X=k) P(Y=nk)
P(X+ Y=n)
=
ek
k! e
(nk)
(nk)!
e(+)(+)n
n!
= e k e (nk) n!
k!(n k)!e(+)(+)n
= n!
k!(n k)!
knk
(+)n
= n!
k!(n k)!
+
k
+
nk
B
n,
+
Assignment 2 Advection Equation (Exemplary Solution)
In this exercise we have a closer look at the one-dimensional advection equation
u(x, t)t
vu(x, t)x
=0 (1)
withx R,t [0,)and the initial values
u(x,0) =u0(x) u0 C1(R)
a) Proof that
u(x, t) =u0(x + vt)
is an analytical solution of equation (1)!
First compute the partial derivations of the solution
ux(x, t) =u0(x + vt)
ut(x, t) =u0(x + vt)v
After substitution of these two equations in (1) we get
0=u(x,t)
tv
u(x, t)
x
=ut(x, t) vux(x, t)
=u0(x + vt)v vu0(x + vt) =0
So we have proven that this is the exact solution.
7/26/2019 solution10_wise2011
3/5
Solution 10/ page 3
b) One numerical class of methods for solving the advection equation are the finite difference
methods. For deriving a numerical computation scheme the partial derivation are approxi-
mated with the Taylor Expansion.
u(x + h, t) u(x, t) + hu(x, t)
x
u(xh, t) u(x, t)hu(x, t)x
u(x, t+ ) u(x, t) + u(x, t)
t
Derive a numerical scheme for the computation of the advection equation, by substitutingthe temporal partial derivative with the approximation given by the Taylor expansions. For
the spatial derivative use the first two Taylor expansions to get a equation withoutu(x, t)andsubstitute this equation in (1). (This formular is called central differences)
Afterwards, try to get a formula foru(x, t+ ).First the we have derive a equation for the spatial partial derivation, by eliminating u(x, t)with the use of the two spartial Taylor expansions. Subtracting this two equations we get
u(x + h, t)u(xh, t) hu(x, t)
x+ h
u(x, t)
xu(x, t)
t
u(x + h,t)u(xh, t)
2h
For the approximation to the temporal derivation we get
u(x,t)
t
u(x,t+ )u(x, t)
This can be substituted and solved
0=u(x, t)
t v
u(x,t)
t
0=u(x, t+ )u(x, t)
v
u(x + h, t)u(xh, t)
2hu(x, t+ )u(x, t)
=v
u(x + h, t)u(xh, t)
2h
u(x, t+ ) =u(x, t) +v
2h(u(x + h, t)u(xh, t)) (2)
c) Implement this scheme in Matlab and compute the numerical and analytical solution of the
two advection equations with
(i) v=0.5
(ii) v=2
and the boundary conditions
u0=
0 |x|> p/2
cos2(x) else
u(5, t) =u(5, t) =0 t [0,1)
7/26/2019 solution10_wise2011
4/5
Solution 10/ page 4
t
x
= 0.1
h= 0.1
Ddiscrete
(0.5, 0.5)
v = 2
v = 0.5
Dcont,v=0.5= (0.75, 0)
Figure 1: domain of dependence of the explicit FD method
in the region of(x,t) [5; 5] [0,1). For the computation use a regular grid with the stepsize=0.01 in the temporal dimension andh=0.01 in the spatial.
See Matlab
d) One of the numerical solutions does not give a good approximation of the analytical one.
Figure out the boundary grid points on which the numerical and analytical solutions for the
grid point(x, t) = (0.5,0.5)depend on.
Having a look at equation (2) with a regular grid = h= 0.01 we see that the point(x, t) = (0.5,0.5) depends on the points(0.49,0.49),(0.50,0.49),(0.51,0.49). This pointsitself depends on the points(0.48,0.48),(0.49,0.48),(0.50,0.48),(0.51,0.48),(0.52,0.48).Following this recursively we end up with the numerically domain of dependence
Ddiscrete(0.5,0.5) =(x, t)|t= 0,x 0.5 h
0.5, 0.5 +h
0.5= {(x, t)|t= 0,x [0,1]}Having a look the analytical solution
u(x, t)u0(x + vt)
we see that the analytical domain of dependence is
Dcont(0.5,0.5) = (0.5 + 0.5v,0).
This leads for v=0.5to
Dcont(0.5,0.5) = (0.75,0) Ddiscrete(0.5,0.5)
and for v=2Dcont(0.5,0.5) = (1.5,0) Ddiscrete(0.5,0.5).
In the case v=2the numerical solution does not depend on the points where the analyticalsolution depends on. In this case the method cant be stable (see fig. 1).
There is a relationship between v,h and such that the analytical domain of dependence is
a subset of the numerical one. This is called the CFL-condition (Courant-Friedrichs-Lewy).
Give an explicit equation for this condition!
Looking at the discrete domain of dependence we can see that the size of this is changing
with the ratio of the temporal and spartial spacing h/. For a stable method discretisation
we need to havev
h
or
v
h 1
7/26/2019 solution10_wise2011
5/5
Solution 10/ page 5
t
x
= 0.1
h= 0.1
Ddiscrete
(0.5, 0.5)
v = 2
v = 0.5
Dcont,v=0.5= (0.75, 0)
Figure 2: Domain of Dependence of the implicit finite differences method.
e) Find a numerical scheme which satisfies the CFL Condition for everyv!
Using the spatial Taylor expansion for u(xh, t+ )leads to
u(x, t+ ) =u(x, t) +v
2h(u(x + h, t+ )u(xh, t+ ))
In this case the numerical domain of dependence is the whole boundary of the state space,
but we have to solve a linear equation for each time step(see fig 2).
f) PDEs are often used to simulate physical models. Why does a numerical scheme which is
implicit in time not yield a good approximation to a physical solution?
Knowing the fact, that an implicit numerical scheme (5) in the spatial direction seems to
be better than a explicit one (1), someone can think about a method which is also implicit
in time. This methods tends to be instable again, since they are not modeling the physicalbackground correct. It is a bad idea to have a point like(x,t+)in the discretization, sincefuture states should not affect the present state!