Vous êtes sur la page 1sur 2

Karlstad University Eva Mossberg

Scientic Computing fall 2011

Assignment 1: Solution of a linear system


The assignment should be presented in a written report and orally at the follwing seminar. The report should include a short problem description so that it is self-contained, but the important thing is that is shows your work, results, comments and additional thoughts. If you havent solved all the problems, comment on where and why you ran into problems. Put program code as appendices. During the computer session November 15 you have a chance to ask for help in completing the assignment, but you most prabably have to work outside the scheduled time to complete your experiments and your report. Submission deadline: Monday November 21 10.15 at the beginning of the seminar.

Preparations and general information Go to the course homepage and download the les for this assignment. To measure the wall clock time of an operation or a series of operations, use tic and toc (see help tic). Be careful not to accidentally include output printing on screen in the time measurements. The screen echo is suppressed by the use of a semicolon after your command.

Direct solution of large systems of linear equations You will get the matrix A and the vector b for a large system Ax = b or order n from the functions sparseA.m and denseA.m like [A1,b] = sparseA(n) and [A2,b] = denseA(n) (A system very similar to this one is described in Heath Computer Exercise 2.17.)

Try to solve Ax = b in four dierent ways for dierent integers n in the interval [1000 10000] and measure the computational time: With MATLAB \ using A1. With MATLAB \ using A2. With matrix inversion and A1. With matrix inversion and A2. Present your results in a table or graph and explain them! What is done by the MATLAB commands \ and inv? What is the dierence between A1 and A2 and what eects does this dierence have on the solution eciency?

Iterative solution of large systems of linear equations Consider a system of linear equations Ax = b. Starting with an initial guess x(0) of the solution, one may use an iterative method x(k+1) = M x(k) + c, to improve this. What properties of M , c and/or x(0) determine whether this will work? Use n = 100 and create a dense matrix A and a vector b as above. Solve Axd = b with a direct metod (as above) to have as a reference solution. Try to nd the solution xi for Axi = b iteratively with the Gauss-Seidel function (k) gs.m by trying some dierent numbers of iterations. Compare plots of xi with a plot of xd . Does it converge? Shift the rst and the second row of the matrix and the right hand side vector. What is the exact solution? Repeat your Gauss-Seidel iterations. Explain the new behavior. k = 0, 1, 2, . . .

Vous aimerez peut-être aussi