

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Numerical Computing S’09 MATH/CSCI 4800- Homework-
Due in class on Thursday March 5, 2009
Illegible reports will be returned without grading. Show all work. All Matlab scripts, Matlab output and plots should be printed out and stapled to the report.
x (k+1) i =^
bi −
∑i− 1 j=1 aij^ x
(k) j −^
∑n j=i+1 aij^ x
(k) j aii
while the corresponding formula for the GS iteration is
x( ik +1)=
bi −
∑i− 1 j=1 aij^ x
(k+1) j −^
∑n j=i+1 aij^ x
(k) j aii
In many practical problems the matrix A is sparse, i.e., many of its entries are zeros. In such cases the iterative methods can be particularly attractive, from the points of view of both storage (zero entries need not be stored) and operation count. One frequently occurring example of a sparse matrix is the tridiagonal matrix, which has nonzero entries only along the main diagonal and the diagonals immediately above (superdiagonal) and below (subdiagonal) the main diagonal. For example, such a matrix of order 5 can be written as
d 1 u 1 0 0 0 2 d 2 u 2 0 0 0 3 d 3 u 3 0 0 0 4 d 4 u 4 0 0 0 5 d 5
Only the entries di, `i and ui need be stored. The notation can be extended in an obvious way to a square matrix of arbitrary order n. Sparse matrices are discussed in section 2.5.4 of the Text but here we take a slightly different approach.
(a) Rewrite the formulas (1) and (2) for a tridiagonal matrix A of order n, using the notation introduced in (3). (You may need to treat x (k+1) 1 and^ x
(k+1) n differently.) (b) Let A be a tridiagonal matrix with 4 as each entry on the main diagonal and -1 on the diagonals above and below the main. Let b be a vector of all ones. Write a well-commented Matlab script to solve Ax = b to a relative error of 10−^6 using the Jacobi iteration and the formulas derived in part (a). You may use the relative error to be
||x(k+^1 )^ − x(k)|| ||xk+^1 || + 10 −^16
(The term 10 −^16 is added to the denominator to guard against the case ||x(k+^1 )|| = 0. ) You may use the infinity norm, for which the Matlab notation is norm(x,inf). Print out the iteration number and the solution for each iteration. Comment on your results. (c) Repeat part (b) above using the GS method. Comment on your results and compare with those of part (a). (d) (Extra credit) Repeat part (b) above using the SOR method. Choose the relaxation parameter ω to lie in the interval (1, 1 .5). Experiment with several values of ω and comment on the results, comparing them with those of parts (b) and (c) above.
x^21 + 2 sin x 2 + x 3 = 0 , cos x 2 − x 3 = 2 , x^21 + x^22 + x^23 = 2.
We seek the solution for x 1 , x 2 and x 3 using Newton’s method for nonlinear systems. As we discussed in class, (also see section 2.7.1 of the Text), Newton’s method applies to nonlinear systems of form fi(x 1 , x 2 , · · · xn) = 0, i = 1, 2 , · · · n. Given the n th iterate (^)
x (n) 1 x (n) 2 · · · x (n) n
the method computes the increment (^)
∆x( 1 n) ∆x( 2 n) · · · ∆x( nn)
by solving a related linear system J(n)∆x(n)^ = −f (n), where J is the Jacobian matrix. The n + 1 th iterate is then given by x(n+1)^ = x(n)^ + ∆x(n).
(a) Compute by hand the Jacobian matrix of the given 3 × 3 system. (b) Implement Newton’s method numerically to solve the given system. Your code must print at each iteration the following information: the iteration number, the solution at that iteration, and the norm of the increment to the solution at that iteration. Terminate the solution when the infinity norm of the increment to the solution is smaller than 10 −^6. Use the initial guess x 1 = 1. 1 , x 2 = 0. 1 , x 3 = − 0. 9. You may use as a guide the Matlab routines that are available on line under the title Newton2d scripts, or you may write your own script. If the online scripts are used, note that they are provided in a single file for ease of access. You must put each script in an m-file of its own. Further, the scripts must be modified to suit the problem and the display requirements stated above. (c) Repeat part (b) with the initial guess x 1 = 1, x 2 = 1, x 3 = 0. Comment on the result.