18.303 Problem Set 2 Solutions Problem 1: (5+5+10+5)

advertisement
18.303 Problem Set 2 Solutions
Problem 1: (5+5+10+5)
RL
RL
RL
L
(a) We have hu, Âvi = 0 ūiv 0 = ūiv|0 − 0 u0 iv = 0 iu0 v by the boundary conditions on v in
∂
. However, for this to be true, we didn’t need zero
the domain of Â, and hence Â∗ = i ∂x
boundary conditions on u(x), and hence hu, Âvi = hÂ∗ u, vi for any (differentiable) u, so the
domain of Â∗ is bigger than the domain of Â.
(b) The eigenfunctions of differentiation are exponentials eiλx , but these are nonzero everywhere,
so we can’t satisfy the boundary conditions! (Note that u = 0 doesn’t count as an eigenfunction.)
p
p
(c) If we write un = sin(nπx/L) 2/L for n = 1, 2, . . . and vn = i cos(nπx/L) 2/L, we have
Âun = σn vn , where σn = nπ/L is the “singular value” (which must be real and positive by definition), and correspondingly Â∗ vn = ivn0 = σn un . They are also orthonormal:
hum , un i p
= hvm , vn i = δm,n by the usual properties of the Fourier sine and cosine bases (note
that the 2/L factor is needed to normalize them).
This is exactly analogous to the finite-dimensional SVD A = V ΣU ∗ , or equivalently AU = V Σ
and A∗ V = U ΣT : if the singular vectors are un (columns of U ) and vn (columns of V ) and
the singular values are σn (diagonals of Σ), then the n-th column of AU = V Σ is Aun = vn σn
and the n-th column of A∗ V = U ΣT is A∗ vn = un σn . The columns of V are an orthonormal
basis for the “output” (column space) of A and the columns of U are an orthonormal basis
for the “input” (row space) of A.
(d) Consider instead the same operator Â, but for periodic functions u(L) = u(0).
L
(i) The analysis is the same as above, except that in this case the boundary term ūiv|0 only
cancels if ūv is periodic, and if v is periodic this means that u must be periodic too.
(ii) The eigenfunctions of  are eiλx , with eigenvalues λ. To be periodic, we need λm =
2πm/L for any integer m (positive or negative). The basis of these eigenfunctions is
simply the ordinary Fourier series.
Problem 2 (5+5+5+5+5 points)
(a) We have hx, xi = x∗ Bx > 0 for x 6= 0 by definition of positive-definiteness. We have hx, yi =
x∗ By = (B ∗ x)∗ y = (Bx)∗ y = y ∗ (Bx) = hy, xi by B = B ∗ .
(b) hx, M yi = x∗ BM y = hM † x, yi = x∗ M †∗ By for all x, y, and hence we must have BM =
M †∗ B, or M †∗ = BM B −1 =⇒ M † = (BM B −1 )∗ = (B −1 )∗ M ∗ B ∗ . Using the fact that
B ∗ = B (and hence (B −1 )∗ = B −1 ), we have M † = B −1 M ∗ B .
(c) If M = B −1 A where A = A∗ , then M † = B −1 AB −1 B = B −1 A = M . Q.E.D.
(d) You should see that eigvals(B\A) gives 5 real numbers (of both signs). Optional: you can
also get l,X = eig(B\A) to get the matrix X whose columns are the eigenvalues. You can
then check all of the dot products by X ∗ BX (or X’*B*X in Julia): the (i, j) entry of this is
hxi , xj i, and you should see that all of the off-diagonal elements are nearly zero (about 10−15
due to roundoff errors). The diagonal elements are not 1 because eig does not normalize the
eigenvectors in the B inner product (it doesn’t know about B).
(e) Most of the time, you should get at least one pair of complex eigenvalues. (The complex
eigenvalues come in conjugate pairs because the matrices are real.) About 8.5% of the time
you will get purely real eigenvalues just by chance, however.
1
Problem 3: 10+10
Consider
Âu = a
d(cu)
d
b
+d
dx
dx
for some real-valued functions a(x) > 0, b(x), c(x) > 0, and d(x), acting on functions u(x) defined
on Ω = [0, L].
h
i
R L c(x)
d
b d(cu)
. Let hu, vi = 0 a(x)
(a) The difficult term is the derivative Â0 = a dx
u(x)v(x)dx. The
dx
d(x) term is obviously Hermitian because it is real: hu, dvi = hdu, vi for any u, v. For Â0 , by
integrating by parts twice, we then have:
Z
Z
Z
cu
0
0
0 L
0 0
0 L
0
hu, Â0 vi =
a[b(cv) ] = cūb(cv) |0 − b(cu) (cv) = [cūb(cv) − cvb(cū) ]|0 − [b(cu)0 ]0 cv
a
Z
c
L
L
= [cūb(cv)0 − cvb(cū)0 ]|0 −
a[b(cu)0 ]0 v = hÂ0 u, vi + [cūb(cv)0 − cvb(cū)0 ]|0
a
The boundary terms then vanish if:
(i) u and v vanish on the boundaries (Dirichlet conditions).
(ii) (cu)0 and (cv)0 vanish on the boundaries (Neumann conditions). Note that there was an
error in the problem statement: cu has zero derivative, not uby itself (unless c0 = 0 at
the boundaries).
(iii) u and v are periodic. However, in this case we also need the coefficients b and c to be
periodic.
(b) To check definiteness, as in class, we look at the “middle” term after integrating by parts once.
Combined with the d term, this gives:
Z
Z
hu, Âui = − b|(cu)0 |2 + d|u|2 .
Clearly, this is at least positive semidefinite if b < 0 and d ≥ 0. It is positive-definite if b < 0
and d > 0.
Alternatively, if d = 0, we have positivity of the integral unless (cu)0 = 0 (almost) everywhere,
i.e. cu is a constant. If we have Dirichlet conditions on u, then cu = 0 at the endpoints and
the only constant it can be is zero, so we have a positive-definite Â. For Neumann, however,
nonzero constant cu functions are allowed by the boundary conditions, so it is only semidefinite.
[Technically, these are sufficient but not necessary conditions. For example, if b < 0 and
d < 0 for Dirichlet boundary conditions, but d is sufficiently small, we can still have a
positive-definite operator. e.g. if d < 0 is a constant, it just shifts the eigenvalues of Â0 (the
derivative part of Â) by d , so any constant d > −λ1 , where λ1 is the smallest eigenvalue of
Â0 , is sufficient to make all eigenvalues positive. However, I didn’t expect you to try to pin
down strictly necessary conditions.]
Problem 2: (5+5+(3+3+3)+5+5 points)
−um
. Define cm+0.5 = c([m + 0.5]∆x). Now
(a) As in class, let u0 ([m + 0.5]∆x) ≈ u0m+0.5 = um+1
∆x
0
we want to take the derivative of cm+0.5 um+0.5 in order to approximate Âu at m by a center
2
difference:
Âu
cm+0.5
≈
um+1 −um
∆x
− cm−0.5
um −um−1
∆x
∆x
m∆x
.
There are other ways to solve this problem of course, that are also second-order accurate.
(b) In order to approximate Âu, we did three things: compute u0 by a center-difference as in
class, multiply by cm+0.5 at each point m + 0.5, then compute the derivative by another
center-difference. The first and last steps are exactly the same center-difference steps as in
class, so they correspond as in class to multiplying by D and −DT , respectively, where D is
the (M + 1) × M matrix


1
 −1

1 

D=

∆x 


1
−1
1
..
.
..
.
−1




.


1 
−1
The middle step, multiplying the (M + 1)-component vector u0 by cm+0.5 at each point is just
multiplication by a diagonal (M + 1) × (M + 1) matrix



C=


c0.5
c1.5
..


.

.
cM +0.5
Putting these steps together in sequence, from right to left, means that A = −DT CD
(c) In Julia, the diagm(c) command will create a diagonal matrix from a vector c. The function
diff1(M) = [ [1.0 zeros(1,M-1)]; diagm(ones(M-1),1) - eye(M) ]
will allow you to create the (M + 1) × M matrix D from class via D = diff1(M) for any
given value of M . Using these two commands, we construct the matrix A from part (d) for
M = 100 and L = 1 and c(x) = e3x via
L = 1
M = 100
D = diff1(M)
dx = L / (M+1)
x = dx*0.5:dx:L # sequence of x values from 0.5*dx to <= L in steps of dx
c(x) = exp(3x)
C = diagm(c(x))
A = -D’ * C * D / dx^2
You can now get the eigenvalues and eigenvectors by λ, U = eig(A), where λ is an array of
eigenvalues and U is a matrix whose columns are the corresponding eigenvectors (notice that
all the λ are < 0 since A is negative-definite).
(i) The plot is shown in Figure 1. The eigenfunctions look vaguely “sine-like”—they have
the same number of oscillations as sin(nπx/L) for n = 1, 2, 3, 4—but are “squeezed” to
the left-hand side.
(ii) We find that the dot product is ≈ 4.3 × 10−16 , which is zero up to roundoff errors (your
exact value may differ, but should be of the same order of magnitude).
3
0.20
fourth
third
second
first
0.15
eigenfunctions
0.10
0.05
0.00
0.05
0.10
0.15
0.200.0
0.2
0.4
x
0.6
Figure 1: Smallest-|λ| eigenfunctions of  =
0.8
d
dx
1.0
d
c(x) dx
for c(x) = e3x .
(iii) In the posted IJulia notebook for the solutions, we show a plot of |λ2M −λM | as a function
of M on a log–log scale, and verify that it indeed decreases ∼ 1/M 2 . You can also just
look at the numbers instead of plotting, and we find that this difference decreases by a
factor of ≈ 3.95 from M = 100 to M = 200 and by a factor of ≈ 3.98 from M = 200 to
M = 400, almost exactly the expected factor of 4. (For fun, in the solutions I went to
M = 1600, but you only needed to go to M = 800.)
(d) In general, the eigenfunctions have the same number of nodes (sign oscillations) as sin(nπx/L),
but the oscillations pushed towards the region of high c(x). This is even more dramatic if we
increase the c(x) contrast. In Figure 2, we show two examples. First, c(x) = e20x , in which
all of the functions are squished to the left where c is small. Second c(x) = 1 for x < 0.3
and 100 otherwise—in this case, the oscillations are at the left 1/3 where c is small, but the
function is not zero in the right 2/3. Instead, the function is nearly constant where c is large.
The reason for this has to do with the continuity of u: it is easy to see from the operator that
cu0 must be continuous for (cu0 )0 to exist, and hence the slope u0 must decrease by a factor of
100 for x > 0.3, leading to a u that is nearly constant. (We will explore some of these issues
further later in the semester.)
2
2
d
d
T
(e) For  = c dx
2 , we would just discretize dx2 as −D D as in class, and then construct A =
T
−CD D where C is the M × M diagonal matrix.


c1


c2


C=
.
.
..


cM
That is, in Julia, C = diagm(c((1:M)*dx))
4
0.3c(x) =1 for x <0.3, 100 otherwise
c(x) = e20x
0.5
fourth
third
second
first
0.4
0.3
0.2
0.1
eigenfunctions
eigenfunctions
0.2
0.1
0.0
0.1
0.0
0.1
0.2
0.2
0.3
0.4
0.0
fourth
third
second
first
0.2
0.4
x
0.6
0.8
1.0
0.3
0.0
0.2
0.4
x
0.6
0.8
1.0
Figure 2: First four eigenfunctions of Âu = (cu0 )0 for two different choices of c(x).
5
Download