Homework assignment 2 (MS word doc file)

advertisement
Homework Set 2
Math / CS 243
1. Suppose that we are using Gaussian elimination to factor a n by n band matrix A that has m= 2
subdiagonals and 2 super diagonals in addition to the main diagonal. Assume that we have already forced
the elements below the diagonal to zero in the first k – 1 columns. To force the elements in the kth column
x x 



  x x



x1 x2 x3


below the diagonal to zero one has a matrix of the form 
z1 w1 w2 x
 . One needs

z 2 w3 w4 x 


x
x  x


 x x 

to calculate multipliers m1  z1 / x1 and m2  z2 / x1 . We then need to multiply the row with x1 x2 x3
in it by appropriate multipliers and subtract from the two rows with z 1 and z2 to zero out z 1 and z2 . This
will require that we update each of the four wi values using an equation like the one for w1 : w1 = w1 – m1
x2.
(a) At step k what is the total number of flops (+, -, x or / ) required. Explain why.
(b) Since we need to do the work in part a for each k, k = 1 .. n, what is the total number of flops for the
factoring a band matrix with band width m = 2.
2. Repeat problem one but do it for general m (smaller than n). Clearly explain why you get the terms in
your count. Include a picture like the picture above.
3. In class we stated a theorem that for a sufficiently smooth function v(t) then v(t + k / 2 ) = 1 / 2 [ v(t) +
v( t + k ) ] + O(k2). Use Taylor’s theorem to prove this result. Find the explicit form for the leading
order term in the O(k2) part.
x
x


x
x

4. In class we argued that a matrix of the form
would have no fillin.

x x


 x x x x
x
x
x


x x
x

(a) Is there fillin in a matrix of the form  x x x
x  ? Briefly explain.


x x

 x x x x x


(b) Suppose that we generalize part (a) to be a symmetric matrix so that in each row every entry to the
right of the leftmost nonzero in the row, up to and including the diagonal entry, is nonzero. Since the
matrix is symmetric we would also have in each column every entry to below of the topmost nonzero
in the column, up to and including the diagonal entry, is nonzero. Is it possible to get fillin? If it is
possible present an example. If it is not possible to get fillin give an argument why it is not possible.
Your argument should be general and not just for a specific matrix. Matrices of this type are called
“skyline” matrices. (Think of a city skyline.)
 x x 0 x 0 0


 x x x 0 x 0
0 x x x 0 x
 . Will we
5. (a) Suppose one applies Gaussian elimination to 6 by 6 matrix 
 x 0 x x x 0
0 x 0 x x x


0 0 x 0 x x


get fillin so that elements that started out zero become nonzero in the final A (after all the entries
below the diagonal are forced to zero? Draw picture of the final matrix A.
(c) Suppose that an n by n matrix has a structure where the matrix is zero everywhere for the main
diagonal, the first super diagonal, the first subdiagonal , a subdiagonal m > 1 diagonals below the main
diagonal and superdiagonal m diagonals above the main diagonal (so the structure is like the structure
of the matrix in part (a)) . For general m describe what fillin occurs by describing the final matrix after
Gaussian elimination is done. Draw a picture of the final A and, in addition, give clear reasons why
you choose the structure that you did. Matrices of this structure are common in solving PDE’s with
two space dimensions.
6.
I have created a program cranknich4ex2.m that uses a fourth order approximation in h for
example 2. Run my program fitit with hv = [.01 .02 .05 .1] , kv = hv .^ 2, method = ‘cranknich4ex2’,
cmethod = ‘compare2’, and tf = .1 as input. Does the order come out to be fourth order.
7. We have derived a number of finite difference approximations, of various orders, for several different
derivatives. We also describe a general procedure to do this. Use the procedure to find the coefficients
a, b, c, d, and e in the approximation
u
au ( x)  bu ( x  h)  cu ( x  2h)  du ( x  3h)  eu ( x  4h)
( x) 
x
h
Note that the common denominator of a, b, c, d and e should come out to be 24. It is best to write
your final approximation for the derivative with a denominator of 24 h.
8. Suppose that we are developing a fourth order method to a problem with mixed boundary conditions
such as the one in our example 3 (page 31 of the text) where ux = u at the left boundary and ux = -u at
the right boundary. Here ux means the partial of u with respect to x. When one is near the left
boundary one will get an equation and equation that involves
( -u0 +16 u1 – 30 u2 + 16 u3 – u4 ) / (12h2) (1)
for an approximation of the second derivative. With mixed boundary conditions we will not know an
explicit value, such as u0 = 0, at the boundary. We therefore need to use the mixed boundary condition and
a finite difference approximation to solve for u0.
(a)
With the given boundary condition ux = u we can approximate ux using the approximation from
problem 7. We then get u0 
(b)
(c)
(d)
(e)
(f)
au0  bu1  cu2  du3  eu 4
(actually it is better to set the
h
denominator to be 24 h not h) where a, b, c, d, and e are the numbers you derived in problem 7. Use
this equation to solve for u0 in terms of u1, u2 , u3 , and u4.
Substitute the formula for u0 into equation (1) to get a new approximation for the second derivative that
does not involve u0. Clearly indicate the new coefficients of u1, u2 , u3 , and u4 in this approximation
fo the second derivative.
What does the corresponding row of the T matrix look like?
I have created a program cranknich2and4ex3c.m that applies to problem 3 with mixed boundary
conditions and is all fourth order except one line “ v2 = [12 ,-24 ,12, 0] ; % this line of code is still
2nd order.” is still second order. Use your results for part ( c ) to change this line of code so that all
of T corresponds to a fourth order method. Save your new program as cranknich4ex3c.m.
Run my program fitit with hv = [.01 .02 .05 .1] , kv = hv .^ 2, method = ‘cranknich2and4ex3c’,
cmethod = ‘compare3’, and tf = .1 as input. Does the order come out to be fourth order. Discuss.
Run my program fitit with hv = [.01 .02 .05 .1] , kv = hv .^ 2, method = ‘cranknich4ex3c’, cmethod
= ‘compare3’, and tf = .1 as input. Does the order come out to be fourth order. It should if your
changes in part (d) were correct!!
Download